Skip to content

Bug fix for text expander and new text contractor function#1

Open
tura89 wants to merge 2 commits intoAnbani:mainfrom
tura89:main
Open

Bug fix for text expander and new text contractor function#1
tura89 wants to merge 2 commits intoAnbani:mainfrom
tura89:main

Conversation

@tura89
Copy link
Copy Markdown

@tura89 tura89 commented Jan 16, 2025

Updated the regex pattern in expand_text function to correctly handle abbreviations with multiple commas, such as ჩ.წ.ა.
The new implementation also accounts for abbreviations not found in the data file.
Previously such abbreviations would cause the function to run indefinitely.

Of note - this doesn't account for abbreviations with spaces in them, such as ძვ. სტ.. In this specific example, it would get expanded to "ძველი სტამბა" since those are the expansions of those two respective contractions.
Probably the only way to fix this would be to loop through each contraction and look them up individually, similar to how the newly implemented contract_text works.

New functionality example:


text = "ილია ჭავჭავაძე (დ. 8 ნოემბერი, 1837, სოფელი ყვარელი — გ. 12 სექტემბერი, 1907, წიწამური; მ.ა.ე. ას.ს.წს. ძვ. სტ.)"

print(text)
expanded_text = expand_text(text)
print(expanded_text)
print(contract_text(expanded_text))

# ილია ჭავჭავაძე (დ. 8 ნოემბერი, 1837, სოფელი ყვარელი — გ. 12 სექტემბერი, 1907, წიწამური; მ.ა.ე. ას.ს.წს. ძვ. სტ.)
# ილია ჭავჭავაძე (დაბადება 8 ნოემბერი, 1837, სოფელი ყვარელი — გარდაცვალება 12 სექტემბერი, 1907, წიწამური; მასის ატომური ერთეული ას.ს.წს. ძველი სტამბა)
# ილია ჭავჭავაძე (დაბ. 8 ნოემბ., 1837, სოფ. ყვარელი — გარდ. 12 სექ., 1907, წიწამური; მ.ა.ე. ას.ს.წს. ძვ. სტ.)

@tura89 tura89 changed the title Bug fix for text expander and text contractor function Bug fix for text expander and new text contractor function Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant