def get_keyphrases_textrank():
    text = request.form['textrank_text']
    top_n = request.form['top_n_textrank']
    top_keywords = TextRank.extractKeyphrases(text, int(top_n))
    context = dict()
    context['keywords'] = top_keywords
    return render_template("keyword_textrank.html", **context)
Esempio n. 2
0
def get_keyphrases_textrank():
    filename = request.form['textrank_name']
    top_n = request.form['top_n_textrank']
    surveys = pd.read_excel(filename, header=0)
    col_name = request.form['textrank_question']
    text = ""
    col = surveys[col_name]
    for i in range(len(col)):
        text = text + " " + col[i]
    top_keywords = TextRank.extractKeyphrases(text, int(top_n))
    context = dict()
    context['keywords'] = top_keywords

    return render_template("keyword_textrank.html", **context)
Esempio n. 3
0
def textRank(inpath,outpath):
    string = codecs.open(inpath, 'r', 'utf-8',errors='ignore').read()
    textrank_results = TextRank.extractKeyphrases(string)
    sorted_keywords = sorted(textrank_results.items(), key=lambda x: x[1], reverse=True)
    print(sorted_keywords)
    outString=''
    for i in range(len(sorted_keywords)):
        print(sorted_keywords[i])
        print(sorted_keywords[i][0])
        print(sorted_keywords[i][1])
        outString+=sorted_keywords[i][0]
        outString+=':'
        outString+=str(sorted_keywords[i][1])
        outString+='\n'

    # out_path='output/5AbstractsGroup-test1/Business/0401.txt'
    with open(outpath,'w',encoding='utf-8') as f:
        f.write(outString)