Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update abbreviation handling #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/dackar/text_processing/Abbreviation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ def abbreviationSub(self, text):
corrected = sent
splitSent = sent.split()
for word in splitSent:
if word not in not_acronyms:
if word in self.abbrDict.keys():
full = self.abbrDict[word]
splitWord = re.split(r'[-\d+]', word) # split word if word contains '-' or numbers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we perform this treatment before the abbreviation handling (in the text pre-processing steps)?

checkAbbr = word if len(splitWord) == 1 else splitWord[-1]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

if checkAbbr not in not_acronyms:
if checkAbbr in self.abbrDict.keys():
full = self.abbrDict[checkAbbr]
# correct the word with the full name if the abbreviation presented in the word
full = re.sub(r'%s$' %str(checkAbbr), full, word)
if isinstance(full, str):
corrected = re.sub(r"\b%s\b" % str(word) , full, corrected)
elif isinstance(full, list) and len(full) == 1:
Expand Down
Loading