def generate_red_links_index(): ignore_words_content = get_wiki_page_content(u'Участник:Vitalik/Индекс/Красные ссылки/Игнорируемые слова') ignore_words = list() for line in ignore_words_content.split('\n'): m = re.match('^\* \[\[(.*)\]\]$', line) if not m: print u'ERROR in ignore_words: %s' % line ignore_words.append(m.group(1).encode('utf8')) # print '\n'.join(ignore_words) # exit() page_names = [ u'Участник:Vitalik/Индекс/Красные ссылки/Дополнительные источники/Cinematique', u'Участник:Vitalik/Индекс/Красные ссылки/Дополнительные источники/Cinematique/Недостающие глаголы из причастий', ] cin_words = list() for page_name in page_names: cin_words_content = get_wiki_page_content(page_name) for line in cin_words_content.split('\n'): m = re.match('^[*#] \[\[(.*)\]\]$', line) if not m: print u'ERROR in cin_words: %s' % line cin_words.append(m.group(1).encode('utf8')) # print '\n'.join(cin_words) # exit() index_words = load_lines(join(settings.DATA_PATH, 'wikt_words', 'ru+redirects.txt')) dict_words = load_from_dictionaries() red_words = list((set(dict_words) | set(cin_words)) - set(index_words) - set(ignore_words)) print "Red count: ", len(red_words) # exit() # bos_words = load_from_dictionaries(['bos_barhudarov_filtering_words.txt']) # new_words = list(set(bos_words) - set(red_words) - set(index_words)) # for word in sorted(new_words): # print word # exit() # save_lines(join(settings.DATA_PATH, 'words_red_a.txt'), red_words) save_lines(join(settings.FILES_PATH, 'reports', 'red_links_ru'), sorted(red_words)) # create_index(red_words, u'Индекс/Красные ссылки (без подстраниц)', create_index(red_words, u'Индекс/Красные ссылки', desc=u'Обновление списка красных ссылок', push=True, debug=False, header=u'Красные ссылки', )
# coding: utf-8 from os.path import join from django.conf import settings from dictionaries.utils.file import load_lines, save_lines from reports.red_links.create_index import \ create_index from reports.red_links.load_from_dictionaries import \ load_from_dictionaries index_words = load_lines(join(settings.DATA_PATH, 'wikt_words', 'ru+redirects.txt')) bukchina_words = load_from_dictionaries(['rus_orthography_academic.txt']) print len(bukchina_words) bukchina_red_words = list(set(bukchina_words) - set(index_words)) print len(bukchina_red_words) bukchina_red_words_a = filter(lambda x: x.decode('utf-8').lower()[0] == u'а',# or x[0] == u'А', bukchina_red_words) print len(bukchina_red_words_a) save_lines(join(settings.DATA_PATH, 'words_red_bukchina_a.txt'), bukchina_red_words_a) create_index(bukchina_red_words_a, u'Индекс/Красные ссылки/Букчина', desc=u'Создание списка красных ссылок Букчиной', max_words_on_page=100000, use_other=False, force_letters=u'А', push=True )