예제 #1
0
 def post(self, request, *args, **kwargs):
     logger.debug('¶')
     steps = list()
     for step in request.POST:
         if step not in Steps.get_steps():
             continue
         steps.append(step)
     steps = sorted(steps, key=lambda step: Steps.step_index(step))
     app = Steps()
     for step in steps:
         print '#' * 80
         print '#' * 1, step
         print '#' * 80
         getattr(app, step)()
     return super(MainView, self).get(request, *args, **kwargs)
#     news_id = item.base_id
#     valid_keywords.setdefault(news_id, list())
#     valid_keywords[news_id].append(item.word)
# tp()
#
# ParagraphKeywords.objects.create_keyword_items(all_paragraphs, news_by_paragraph, valid_keywords)
#
# # todo: third mode: all news that intersects with 704
#
# ## calculate cosinuses for news
# NewsKeywordItem.objects.news_calculate_cosinuses(docs, news_by_docs,
#                                                  several_doc_ids)
# # NewsKeywordItem.objects.news_calculate_cosinuses(docs, news_by_docs)
#
# ## calculate cosinuses for paragraphs
# docs = dict()
# for news in News.objects.only('doc_id'):
#     docs[news.pk] = news.doc_id
# ParagraphKeywordItem.objects.paragraph_calculate_cosinuses(docs, 1, save_good_news=False)
# # ParagraphKeywordItem.objects.paragraph_calculate_cosinuses(docs, 1, several=False)
#
# # todo: calc all cosinuses and then try to check different coefficient "d"
#
# # just for fun :)



app = Steps()
app.build_docs_news_dependencies()
app.calculate_paragraph_cos()