Procházet zdrojové kódy

Refactor check_word_in_academic()

Sergienko Anton před 7 roky
rodič
revize
1f42dbe728
1 změnil soubory, kde provedl 3 přidání a 4 odebrání
  1. 3 4
      src/program_efremova.py

+ 3 - 4
src/program_efremova.py

@@ -192,10 +192,9 @@ def check_word_in_wiktionary(word, html):
 
 def check_word_in_academic(word, html):
     answer = None
-    if re.search(
-            re.escape(
-                word) + r'</a><\/strong> — сущ\.(.*?)<\/p>\n<p class="src"><a href="\/\/dic\.academic\.ru\/contents.nsf\/dic_synonims\/">Словарь синонимов<\/a><\/p>',
-            html, re.S):
+    regexp = r'</a><\/strong> — сущ\.(.*?)<\/p>\n<p class="src">' \
+             r'<a href="\/\/dic\.academic\.ru\/contents.nsf\/dic_synonims\/">Словарь синонимов<\/a><\/p>'
+    if re.search(re.escape(word) + regexp, html, re.S):
         answer = 'noun'
     return answer