Сводка кадров данных Gensim по строкам

Я использую «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.

Как мне получить отдельные сводки, соответствующие исходному контенту, и поместить их в фрейм данных?


person Moaz Mohammed Husain    schedule 08.03.2020    source источник


Ответы (1)


Вы продолжаете переписывать свой список. Заменять

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

с

a.append(summarize(i, ratio=0.4, split = True))
person Josh Friedlander    schedule 08.03.2020