Sentence Handler¶
-
sentence_handler.
sentence_pairing
(sentences: List[str]) → pandas.core.frame.DataFrame[source]¶ Create a matrix of paired sentences, where same sentences are omitted.
- Parameters
sentences – list of sentences
- Returns
DataFrame with the columns [“sent_1”, “sent_2”] where each row is a paired sentences.
-
sentence_handler.
sentence_rank_with_page_rank
(sentence_pairs_with_score: pandas.core.frame.DataFrame) → pandas.core.frame.DataFrame[source]¶ Rank the sentences based on their similarity score to each other using page-rank algorithm and output their new scores.
- Parameters
sentence_pairs_with_score – DataFrame with the columns [“sent_1”, “sent_2”, “score”] where each row is a paired sentences with their initial similarity score.
- Returns
DataFrame with the columns [“sentence”, “rank”] where each sentence has its rank.
-
sentence_handler.
sentence_sorter
(df: pandas.core.frame.DataFrame, top_n: int, sentences: List[str]) → str[source]¶ Sort the sentences based on their rank and return the full summarized text in which the sentences appear as they are in the given text.
- Parameters
-
df – DataFrame with the columns [“sentence”, “rank”] where each sentence has its rank.
top_n – total number of sentences in the summarized text.
sentences – the given text tokenized into sentences.
- Returns
the summarized text