Skip to content

Commit

Permalink
sort terms by length to make sure longer terms are indexed first
Browse files Browse the repository at this point in the history
  • Loading branch information
Glottotopia committed Jun 6, 2023
1 parent 9e1b607 commit bcf8c70
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions langsci/wrapperscripts/autoindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def process_file(filename):
if "(" in lg:
print(f"{lg} contains parentheses. Parentheses are not allowed in indexed language names. Exiting.")
sys.exit()
terms = open("localsubjectterms.txt").read().split('\n')[::-1]#reverse to avoid double indexing
for term in terms:
terms = open("localsubjectterms.txt").read().split('\n')
for term in reversed(sorted(terms, key=len)): #start with longest term to avoid double indexing
if "(" in term:
print(f"{term} contains parentheses. Parentheses are not allowed in indexed language names. Exiting.")
sys.exit()
Expand Down

0 comments on commit bcf8c70

Please sign in to comment.