Reputation: 1207
I am trying to get the output as string using LexRankSummarizer
in sumy
library.
I am using the following code (pretty straightforward)
parser = PlaintextParser.from_string(text,Tokenizer('english'))
summarizer = LexRankSummarizer()
sum_1 = summarizer(parser.document,10)
sum_lex=[]
for sent in sum_1:
sum_lex.append(sent)
using the above code I am getting an output which is in the form of tuple
. Consider a summary as given below from a text
as input
The Mahājanapadas were sixteen kingdoms or oligarchic republics that existed in ancient India from the sixth to fourth centuries BCE.
Two of them were most probably ganatantras (republics) and others had forms of monarchy.
Using the above code I am getting an output as
sum_lex = [<Sentence: The Mahājanapadas were sixteen kingdoms or oligarchic republics that existed in ancient India from the sixth to fourth centuries BCE.>,
<Sentence: Two of them were most probably ganatantras (republics) and others had forms of monarchy.>]
However, if I use print(sent)
I am getting proper output as given above.
How to tackle this issue?
Upvotes: 2
Views: 771
Reputation: 1824
Replacing sum_lex.append(sent)
with sum_lex.append(str(sent))
should do.
Upvotes: 4