Commits

spirit committed 74409b2

Typographic apostrophe issue with enchant

  • Participants
  • Parent commits e9e10b0

Comments (0)

Files changed (1)

File guess_language/__init__.py

 def guess_language(text: str):
     """Return the language code, i.e. 'en'.
     """
-    words = WORD_RE.findall(text[:MAX_LENGTH])
+    words = WORD_RE.findall(text[:MAX_LENGTH].replace("’", "'"))
     return identify(words, find_runs(words))
 
 
     """Create a list of trigrams in content sorted by frequency.
     """
     trigrams = defaultdict(int)  # QHash<QString,int>
-    content = content.lower().replace("’", "'")
+    content = content.lower()
 
     for i in range(len(content) - 2):
         trigrams[content[i:i+3]] += 1