Browse Source

Add check_plural_word_in_goldlit() and check_plural_in_academic()

Sergienko Anton 7 years ago
parent
commit
d0464da272
1 changed files with 24 additions and 1 deletions
  1. 24 1
      src/program_efremova.py

+ 24 - 1
src/program_efremova.py

@@ -367,6 +367,24 @@ def check_plural_word_in_wiktionary(word, html):
     return answer
 
 
+def check_plural_word_in_goldlit(word, html):
+    answer = None
+
+    if '<strong>Начальная форма</strong>: {}'.format(word.upper()) in html:
+        answer = 'include'
+
+    return answer
+
+
+def check_plural_in_academic(word, html):
+    answer = None
+    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 = 'include'
+    return answer
+
+
 @function_execution_time
 @if_exist_json
 def check_plural_words_on_site(url, function_check_html):
@@ -488,6 +506,11 @@ def main():
         {'text': 'Проверить слова во мн. числе', 'function': check_words_in_plural},
         {'text': 'Проверить слова во мн. числе на wiktionary.org', 'function': check_plural_words_on_site,
          'params': {'url': 'https://ru.wiktionary.org/wiki/', 'function_check_html': check_plural_word_in_wiktionary}},
+        {'text': 'Проверить слова во мн. числе на dic.academic.ru', 'function': check_plural_words_on_site,
+         'params': {'url': 'https://dic.academic.ru/searchall.php?SWord=',
+                    'function_check_html': check_plural_in_academic}},
+        {'text': 'Проверить слова во мн. числе на goldlit.ru', 'function': check_plural_words_on_site,
+         'params': {'url': 'https://goldlit.ru/component/slog?words=', 'function_check_html': check_plural_word_in_goldlit}},
     ]
 
     while True:
@@ -507,7 +530,7 @@ def main():
 
 
 def test():
-    pass
+    check_word_in_site('стуаввввввлья', 'https://goldlit.ru/component/slog?words=', check_plural_word_in_goldlit)
 
 
 if __name__ == '__main__':