def get_unknown_inflection_simple(): items = WordInflection.objects.filter(kind__in=[u'f ?', u'm ?', u'n ?']) words = sorted(items, key=lambda item: item.word[::-1]) report = dict() for word in words: print word.word valid_num = check_correct_inflection(word.word, word.gender) if valid_num < 0: continue key = "%s%d" % (word.gender, valid_num) report.setdefault(key, list()) report[key].append((word.word, word.content)) file_path = join(PAGES_DIR, u'Массовое редактирование (simple)') wiki_prefix = u"Участник:Vitalik/Массовое редактирование/Словоизменение/сущ/simple" # desc = u"Полное обновление данных" desc = u"Создание списков для массового редактирования" for key in report.keys(): print key items = report.get(key) content = gen_report_simple(items, key[0], key[1]) filename = "%s.txt" % (key) print filename debug_write(file_path, filename, content) # sys.exit() wiki_title = "%s/%s" % (wiki_prefix, key) save_wiki_page(wiki_title, content, desc)
def get_unknown_inflection_full(): items = WordInflection.objects.filter(kind__in=[u'f ?', u'm ?', u'n ?']) words = sorted(items, key=lambda item: item.word[::-1]) report = dict() for word in words: print word.word valid_num = check_correct_inflection(word.word, word.gender) if valid_num < 0: continue key = "%s%d" % (word.gender, valid_num) report.setdefault(key, list()) report[key].append((word.word, word.content)) file_path = join(PAGES_DIR, u'Массовое редактирование') wiki_prefix = u"Участник:Vitalik/Массовое редактирование/Словоизменение/сущ" desc = u"Полное обновление данных" for key in report.keys(): print key items = report.get(key) i = 1 page_count = len(items) / 100 + 1 for chunk in chunks(items, 100): content = gen_report_full(chunk, key[0], key[1], page_count) filename = "%s_%d.txt" % (key, i) print filename debug_write(file_path, filename, content) # sys.exit() wiki_title = "%s/%s/%s" % (wiki_prefix, key, i) changed = save_wiki_page(wiki_title, content, desc) if changed: db_title = u'сущ/%s/%s' % (key, i) item, created = WordInflectionMassEdit.objects.get_or_create( title=db_title) item.content = content item.save() i += 1