首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gensim逐行数据汇总

Gensim逐行数据汇总
EN

Stack Overflow用户
提问于 2020-03-08 14:35:36
回答 1查看 194关注 0票数 0

我使用“Gensim”来生成我拥有的不同行的摘要。下面是原始数据文件的样子:

代码语言:javascript
复制
df.head()

                                   Example Content
0   Not happy they have just reduced rates for Und...
1   One of the worst banks. I had a very bad exper...
2   Some one in lloyds has signed a form in My nam...
3   Card blocked due to ordering a takeaway from m...
4   There are plenty of better banks than Lloyds.\...

我可以使用gensim对每一行进行摘要。问题是,我希望每一个行摘要都显示在它原来的位置上,而这并没有发生。下面是我的代码:

代码语言:javascript
复制
a = []

for i in df['Example Content']:

    i= i + str(". This is second sentence. This is third")             # this is to add two more sentences so that gensim summarizes it. These sentence add no value to summary.
    a = summarize(i, ratio=0.4, split = True)

df['Summary'] = a

下面是对上述代码的输出:

代码语言:javascript
复制
                                     Example Content                                 Summary
0   Not happy they have just reduced rates for Und...       Today I got a new phone and switched my sim an...
1   One of the worst banks. I had a very bad exper...       Today I got a new phone and switched my sim an...
2   Some one in lloyds has signed a form in My nam...       Today I got a new phone and switched my sim an...
3   Card blocked due to ordering a takeaway from m...       Today I got a new phone and switched my sim an...
4   There are plenty of better banks than Lloyds.\...       Today I got a new phone and switched my sim an...

下面显示的是由gensim生成的每一行的所有单独摘要:

代码语言:javascript
复制
The 2nd address was a shopping centre and they didnt even give me the name of the business.
I wasn't to know as I through Gallarias Novas was the shop name but that was just the place.
They said that they had issued a new card that I hadn't received and even though they new I was abroad using my card they stopped it anyway.
When my new card did arrive after getting home I now know the reason was that they were making me have a con tactless card whcih I did nto request.

 Today I got a new phone and switched my sim and set up my banking apps inc Halifax and LloydÕs.
Halifax worked fine, usual 4 digit code and confirmation call came through and all set up in mins.

我应该如何抓取与原始内容相对应的单个摘要,并将它们放在dataframe中?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-08 15:25:22

你一直在重写你的名单。替换

代码语言:javascript
复制
a = summarize(i, ratio=0.4, split = True)

使用

代码语言:javascript
复制
a.append(summarize(i, ratio=0.4, split = True))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60588557

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档