mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
Also use exclamation point as end of sentence indicator
This commit is contained in:
parent
0cc7232409
commit
f626ad95ff
1 changed files with 5 additions and 1 deletions
|
@ -257,14 +257,18 @@ def microblog_content_to_title(html: str) -> str:
|
|||
|
||||
period_index = title.find('.')
|
||||
question_index = title.find('?')
|
||||
exclamation_index = title.find('!')
|
||||
|
||||
# Find the earliest occurrence of either '.' or '?'
|
||||
end_index = min(period_index if period_index != -1 else float('inf'),
|
||||
question_index if question_index != -1 else float('inf'))
|
||||
question_index if question_index != -1 else float('inf'),
|
||||
exclamation_index if exclamation_index != -1 else float('inf'))
|
||||
|
||||
if end_index != -1:
|
||||
if question_index != -1:
|
||||
end_index += 1 # Add the ? back on
|
||||
if exclamation_index != -1:
|
||||
end_index += 1 # Add the ! back on
|
||||
title = title[:end_index]
|
||||
|
||||
if len(title) > 150:
|
||||
|
|
Loading…
Add table
Reference in a new issue