MCPcopy
hub / github.com/codelucas/newspaper / split_title

Method split_title

newspaper/extractors.py:269–285  ·  view source on GitHub ↗

Split the title to best part possible

(self, title, splitter)

Source from the content-addressed store, hash-verified

267 return title
268
269 def split_title(self, title, splitter):
270 """Split the title to best part possible
271 """
272 large_text_length = 0
273 large_text_index = 0
274 title_pieces = splitter.split(title)
275
276 # find the largest title piece
277 for i in range(len(title_pieces)):
278 current = title_pieces[i]
279 if len(current) > large_text_length:
280 large_text_length = len(current)
281 large_text_index = i
282
283 # replace content
284 title = title_pieces[large_text_index]
285 return TITLE_REPLACEMENTS.replaceAll(title).strip()
286
287 def get_feed_urls(self, source_url, categories):
288 """Takes a source url and a list of category objects and returns

Callers 1

get_titleMethod · 0.95

Calls 2

splitMethod · 0.80
replaceAllMethod · 0.45

Tested by

no test coverage detected