一列文本的 BERT 摘要
BERT Summarization for a column of texts
我正在尝试从数据集中总结 100 种产品描述。为此,我只是尝试使用摘要器
!pip install summarizers -q
from summarizers import Summarizers
import pandas as pd
一次一个句子效果很好。
textpanasonic="The NN-CS89L offers next-level cooking convenience. Its four distinct cooking methods - steaming, baking, grilling and microwaving ensure your meals are cooked or reheated to perfection. Its multi-function capabilities can be combined to save time without compromising taste, texture or nutritional value. It’s the all-in-one kitchen companion designed for people with a busy lifestyle."
summ(textpanasonic)
The NN-CS89L offers next-level cooking convenience.
但是 您知道是否可以为每条评论创建一个包含摘要的新列吗?
ValueError:文本输入必须为 str
(单个示例)、List[str]
(批处理或单个预标记示例)或 List[List[str]]
(预标记示例批处理)类型。
提前谢谢你^^
您可以简单地 apply
summ
到带有摘要的列。由于 summ
可以将列表作为输入,因此它还将处理 pandas 系列。提供多行示例:
import pandas as pd
from summarizers import Summarizers
summ = Summarizers()
data = ["The NN-CS89L offers next-level cooking convenience. Its four distinct cooking methods - steaming, baking, grilling and microwaving ensure your meals are cooked or reheated to perfection. Its multi-function capabilities can be combined to save time without compromising taste, texture or nutritional value. It’s the all-in-one kitchen companion designed for people with a busy lifestyle.", "These slim and stylish bodies are packed with high performance. The attractive compact designs and energy-saving functions help Panasonic Blu-ray products consume as little power as possible. You can experience great movie quality with this ultra-fast booting DMP-BD89 Full HD Blu-ray disc player. After starting the player, the time it takes from launching the menu to playing a disc is much shorter than in conventional models. The BD89 also allows for smart home networking (DLNA) and provides access to video on demand, so that home entertainment is more intuitive, more comfortable, and lots more fun."]
df = pd.DataFrame(data, columns=['summaries'])
df['abstracts'] = df['summaries'].apply(summ)
summaries
abstracts
0
The NN-CS89L offers next-level cooking convenience. Its four distinct cooking methods - steaming, baking, grilling and microwaving ensure your meals are cooked or reheated to perfection. Its multi-function capabilities can be combined to save time without compromising taste, texture or nutritional value. It’s the all-in-one kitchen companion designed for people with a busy lifestyle.
The NN-CS89L offers next-level cooking convenience.
1
These slim and stylish bodies are packed with high performance. The attractive compact designs and energy-saving functions help Panasonic Blu-ray products consume as little power as possible. You can experience great movie quality with this ultra-fast booting DMP-BD89 Full HD Blu-ray disc player. After starting the player, the time it takes from launching the menu to playing a disc is much shorter than in conventional models. The BD89 also allows for smart home networking (DLNA) and provides access to video on demand, so that home entertainment is more intuitive, more comfortable, and lots more fun.
Panasonic DMP-BD89 Full HD Blu-ray disc player.
我正在尝试从数据集中总结 100 种产品描述。为此,我只是尝试使用摘要器
!pip install summarizers -q
from summarizers import Summarizers
import pandas as pd
一次一个句子效果很好。
textpanasonic="The NN-CS89L offers next-level cooking convenience. Its four distinct cooking methods - steaming, baking, grilling and microwaving ensure your meals are cooked or reheated to perfection. Its multi-function capabilities can be combined to save time without compromising taste, texture or nutritional value. It’s the all-in-one kitchen companion designed for people with a busy lifestyle."
summ(textpanasonic)
The NN-CS89L offers next-level cooking convenience.
但是 您知道是否可以为每条评论创建一个包含摘要的新列吗?
ValueError:文本输入必须为 str
(单个示例)、List[str]
(批处理或单个预标记示例)或 List[List[str]]
(预标记示例批处理)类型。
提前谢谢你^^
您可以简单地 apply
summ
到带有摘要的列。由于 summ
可以将列表作为输入,因此它还将处理 pandas 系列。提供多行示例:
import pandas as pd
from summarizers import Summarizers
summ = Summarizers()
data = ["The NN-CS89L offers next-level cooking convenience. Its four distinct cooking methods - steaming, baking, grilling and microwaving ensure your meals are cooked or reheated to perfection. Its multi-function capabilities can be combined to save time without compromising taste, texture or nutritional value. It’s the all-in-one kitchen companion designed for people with a busy lifestyle.", "These slim and stylish bodies are packed with high performance. The attractive compact designs and energy-saving functions help Panasonic Blu-ray products consume as little power as possible. You can experience great movie quality with this ultra-fast booting DMP-BD89 Full HD Blu-ray disc player. After starting the player, the time it takes from launching the menu to playing a disc is much shorter than in conventional models. The BD89 also allows for smart home networking (DLNA) and provides access to video on demand, so that home entertainment is more intuitive, more comfortable, and lots more fun."]
df = pd.DataFrame(data, columns=['summaries'])
df['abstracts'] = df['summaries'].apply(summ)
summaries | abstracts | |
---|---|---|
0 | The NN-CS89L offers next-level cooking convenience. Its four distinct cooking methods - steaming, baking, grilling and microwaving ensure your meals are cooked or reheated to perfection. Its multi-function capabilities can be combined to save time without compromising taste, texture or nutritional value. It’s the all-in-one kitchen companion designed for people with a busy lifestyle. | The NN-CS89L offers next-level cooking convenience. |
1 | These slim and stylish bodies are packed with high performance. The attractive compact designs and energy-saving functions help Panasonic Blu-ray products consume as little power as possible. You can experience great movie quality with this ultra-fast booting DMP-BD89 Full HD Blu-ray disc player. After starting the player, the time it takes from launching the menu to playing a disc is much shorter than in conventional models. The BD89 also allows for smart home networking (DLNA) and provides access to video on demand, so that home entertainment is more intuitive, more comfortable, and lots more fun. | Panasonic DMP-BD89 Full HD Blu-ray disc player. |