Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.72 KB | None | 0 0
  1. for b in const_list.names_bibliography:
  2.         if b.lower() in text.lower():
  3.             test_text = text
  4.             while test_text.lower().find(b.lower()) != -1:
  5.                 print(test_text)
  6.                 num = test_text.lower().find(b.lower())
  7.                 l_num = num + len(b)
  8.                 if (test_text[l_num] == ',') or (num - 2 > 0 and test_text[num - 2:num] == ', ') \
  9.                         or (l_num + 2 < len(test_text) and test_text[l_num: l_num + 2] == ' ('):
  10.                     test_text = test_text[l_num:]
  11.                     continue
  12.                 while l_num < len(test_text):
  13.                     if test_text[l_num] == ' ' or test_text[l_num] == ' ' or test_text[l_num] == '…' \
  14.                             or test_text[l_num:l_num + 2] == '..':
  15.                         if test_text[l_num:l_num + 2] == '..' or test_text[l_num] == '…':
  16.                             test_text = test_text[num + len(b):]
  17.                             break
  18.                         else:
  19.                             l_num += 1
  20.                         continue
  21.                     else:
  22.                         if test_text[l_num].isdigit() or (test_text[l_num].isalpha() and test_text[l_num].islower()):
  23.                             test_text = test_text[num + len(b):]
  24.                             break
  25.                         else:
  26.                             m_num = num - 1
  27.                             if test_text[m_num] == ' ' and test_text[m_num - 1].isalpha() \
  28.                                     and test_text[m_num - 1].islower():
  29.                                 test_text = test_text[num + len(b):]
  30.                                 break
  31.                             if test_text[m_num-4:num] == '     ' and test_text[m_num - 5] == '.':
  32.                                 test_text = test_text[num + len(b):]
  33.                                 break
  34.                             while m_num >= 0:
  35.                                 if test_text[m_num] == ' ' or test_text[m_num] == ' ' or test_text[m_num] == '\n':
  36.                                     m_num -= 1
  37.                                     continue
  38.                                 else:
  39.                                     if not test_text[m_num].isdigit():
  40.                                         flag_bibliography = 0
  41.                                         main += text[:(len(text) - len(test_text) + num)]
  42.                                         text = test_text[num + len(b):]
  43.                                     test_text = test_text[num + len(b):]
  44.                                     break
  45.                             break
  46.                 if flag_bibliography == 0:
  47.                     break
  48.             if flag_bibliography == 0:
  49.                 break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement