繁体   English   中英

Gensim 逐行数据框摘要

[英]Gensim row wise dataframe summary

我正在使用“Gensim”来生成我拥有的不同行的摘要。 这是原始数据框的样子:

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 对每一行应用汇总。 问题是,我希望每一行摘要都与其原始内容相对应,而这并没有发生。 这是我的代码的样子:

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

这是上面代码的输出:

                                     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 生成的每行的所有单独摘要:

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.

我应该如何获取与原始内容相对应的个人摘要并将它们放入数据框中?

你不断地覆盖你的清单。 代替

a = summarize(i, ratio=0.4, split = True)

a.append(summarize(i, ratio=0.4, split = True))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM