MCPcopy Create free account
hub / github.com/geekcomputers/Python / summarize_text

Function summarize_text

news_oversimplifier.py:86–101  ·  view source on GitHub ↗

Summarizes the given text using the summa library. args: text (str): The input text to summarize. ratio (float): Ratio of the original text to retain in the summary. returns: str: The summarized text, or a fallback message if intro is present or summary is empt

(text, ratio=0.6)

Source from the content-addressed store, hash-verified

84
85
86def summarize_text(text, ratio=0.6): # pytest in test file
87 """
88 Summarizes the given text using the summa library.
89
90 args:
91 text (str): The input text to summarize.
92 ratio (float): Ratio of the original text to retain in the summary.
93
94 returns:
95 str: The summarized text, or a fallback message if intro is present or summary is empty.
96 """
97 summary = summarize(text, ratio=ratio)
98 if summary.lower().startswith("hello, and welcome to decoder!"):
99 return "No description available for this headline"
100 else:
101 return summary.strip() if summary else text
102
103
104def capitalize_title(title): # pytest in test file

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected