Skip to content

Commit 421b2ca

Browse files
authored
Merge pull request #35 from hmlendea/length-reduction
Improved toot length reduction
2 parents aa44e18 + 38ba419 commit 421b2ca

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

main.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,50 @@ def parse_args():
269269
toot_body += '\n\n' + filtered_tags_to_add.lstrip().rstrip()
270270

271271
if len(toot_body) > 500:
272-
toot_body = toot_body.replace(' și ', ' & ');
272+
if toot_language == 'ro':
273+
toot_body = toot_body.replace(' aproximativ ', ' aprox. ');
274+
toot_body = toot_body.replace(' de exemplu ', ' de ex. ');
275+
toot_body = toot_body.replace(' deoarece ', ' ptc. ');
276+
toot_body = toot_body.replace(' din cauza că ', ' ptc. ');
277+
toot_body = toot_body.replace(' din motiv că ', ' ptc. ');
278+
toot_body = toot_body.replace(' este ', ' e ');
279+
toot_body = toot_body.replace(' în timp ce ', ' cât timp ');
280+
toot_body = toot_body.replace(' pe motiv că ', ' ptc. ');
281+
toot_body = toot_body.replace(' pe motivul că ', ' ptc. ');
282+
toot_body = toot_body.replace(' pentru ', ' pt. ');
283+
toot_body = toot_body.replace(' pentru că ', ' ptc. ');
284+
toot_body = toot_body.replace(' pentru motivul că ', ' ptc. ');
285+
toot_body = toot_body.replace(' spre exemplu ', ' de ex. ');
286+
toot_body = toot_body.replace(' și ', ' & ');
287+
toot_body = toot_body.replace('Aproximativ ', 'Aprox. ');
288+
toot_body = toot_body.replace('De exemplu ', 'De ex. ');
289+
toot_body = toot_body.replace('Este ', 'E ');
290+
toot_body = toot_body.replace('Pentru ', 'Pt. ');
291+
toot_body = toot_body.replace('Pentru că ', 'Ptc. ');
292+
toot_body = toot_body.replace('Spre exemplu ', 'Spre ex. ');
293+
elif toot_language == 'en':
294+
toot_body = toot_body.replace(' and ', ' & ');
295+
toot_body = toot_body.replace(' are not ', ' aren\'t ');
296+
toot_body = toot_body.replace(' because ', ' b/c ');
297+
toot_body = toot_body.replace(' do not ', ' don\'t ');
298+
toot_body = toot_body.replace(' had not ', ' hadn\'t ');
299+
toot_body = toot_body.replace(' has not ', ' hasn\'t ');
300+
toot_body = toot_body.replace(' have not ', ' haven\'t ');
301+
toot_body = toot_body.replace(' I am ', ' I\'m ');
302+
toot_body = toot_body.replace(' information ', ' info ');
303+
toot_body = toot_body.replace(' is not ', ' isn\'t ');
304+
toot_body = toot_body.replace(' it is ', ' it\'s ');
305+
toot_body = toot_body.replace(' that is ', ' that\'s ');
306+
toot_body = toot_body.replace(' they are ', ' they\'re ');
307+
toot_body = toot_body.replace(' we are ', ' we\'re ');
308+
toot_body = toot_body.replace(' will not ', ' won\'t ');
309+
toot_body = toot_body.replace(' without ', ' w/o ');
310+
toot_body = toot_body.replace(' you are ', ' you\'re ');
311+
toot_body = toot_body.replace('. ', '.');
312+
toot_body = toot_body.replace(', ', ',');
313+
toot_body = toot_body.replace('? ', '?');
314+
toot_body = toot_body.replace('! ', '!');
315+
273316

274317
toot_body = re.sub('[#][#]*', '#', toot_body);
275318
print(toot_body)

0 commit comments

Comments
 (0)