소스 검색

Refactor check_word_in_academic()

Sergienko Anton 7 년 전
부모
커밋
1f42dbe728
1개의 변경된 파일3개의 추가작업 그리고 4개의 파일을 삭제
  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