Exemplo n.º 1
0
def phase1_update(source_prob, wiki_list, keywords, n_iter, verbosity, mode_of_operation):
        
        logfile = open("test_4.txt","a")
        for kw in keywords:
                wiki_content = sm.get_wiki_article(kw, verbose=verbosity, search_list=wiki_list)
                print "\n\n Done with Content Extraction. Begin keyword extraction algorithm..."
                [source_prob, sorted_list] = gurmeet.tfidf(source_prob, wiki_content, mode_of_operation=mode_of_operation, return_term=0)
                print "\n\n---------\n"
                logfile.writelines(kw)
                for i in range(len(source_prob)):
                        print wiki_list[i], source_prob[i]/source_prob[0]
                        logfile.writelines(wiki_list[i]+" "+str(source_prob[i]/source_prob[0]))
                
        #tr_list = TextRank.text_rank(wiki_content[0])
        return source_prob, sorted_list
Exemplo n.º 2
0
__author__ = 'nikhil'
import search_module as sm
import TextRank, gurmeet

verbosity = True
keyword = "Britain"

mode_of_operation = 1
wiki_content = sm.get_wiki_article(keyword, verbose=verbosity)

print "\n\n Done with Content Extraction. Begin keyword extraction algorithm..."
tr_list = gurmeet.tfidf(wiki_content[0], wiki_content[1], wiki_content[2], mode_of_operation=mode_of_operation, return_term=0)
#tr_list = TextRank.text_rank(wiki_content[0])

for g, v in tr_list:
    print g, v