gpt4 book ai didi

Python/flask汇总算法错误

转载 作者:太空宇宙 更新时间:2023-11-03 21:41:03 27 4
gpt4 key购买 nike

@app.route('/dependent', methods = ['POST'])
def mySumD():
if request.form['action'] == 'LSA':
para = ""
url = request.form['url_link']
parser = HtmlParser.from_url(url, Tokenizer(LANGUAGE))
stemmer = Stemmer(LANGUAGE)
summarizer = Summarizer(stemmer)
summarizer.stop_words = get_stop_words(LANGUAGE)

for sentence in summarizer(parser.document, SENTENCES_COUNT):
data = str(sentence)
para += data
return render_template('dependent.html', para = para)

elif request.form['action'] == 'Luhn':
para = ""
url = request.form['url_link']
parser = HtmlParser.from_url(url, Tokenizer(LANGUAGE))
stemmer = Stemmer(LANGUAGE)
summarizer = LuhnSummarizer(stemmer)
summarizer.stop_words = get_stop_words(LANGUAGE)

for sentence in summarizer(parser.document, SENTENCES_COUNT):
data = str(sentence)
para += data
return render_template('dependent.html', para = para)

elif request.form['action'] == 'LexRank':
para = ""
url = request.form['url_link']
parser = HtmlParser.from_url(url, Tokenizer(LANGUAGE))
stemmer = Stemmer(LANGUAGE)
summarizer = LexSummarizer(stemmer)
summarizer.stop_words = get_stop_words(LANGUAGE)

for sentence in summarizer(parser.document, SENTENCES_COUNT):
data = str(sentence)
para += data
return render_template('dependent.html', para = para)

>

<form action = "{{ url_for('mySumD') }}" method = "POST" id="urlForm" class="standard">

<input type="url" id = "url" name="url_link" class= "form-control" placeholder="Insert URL here...">
<div id="url_field_is_empty" class="error" style="display: none"> You must submit a valid URL</div>
<h1>Choose Your Summarization Method</h1>
<div class="btn-group" style="width:100%" id="subscribersoptions">
<button style="width:20%" type ="submit" name="action" value="LSA">LSA</button>
<button style="width:20%" type ="submit" name="action" value="Luhn">Luhn</button>
<button style="width:20%" type ="submit" name="action" value="LexRank">Lex Rank</button>
<button style="width:20%" type ="submit" name="action" value="TextRank">Text Rank</button>
<button style="width:20%" type ="submit" name="action" value="SumBasic">SumBasic</button>
<button style="width:20%" type ="submit" name="action" value="KL-Sum">KL-Sum</button>
</div>
<br>
{{para}}

</form>

您好,我在让我的 flask 和 html 输出正确的数据时遇到问题。我正在使用 Sumy 摘要库。基本上我试图总结 url 网页并将文本输出到 html 文档上。一切都运行良好,特别是对于我的 LSA 总结。问题是除了lsa之外它只输出第一句话。这就是为什么我创建了 para = ""变量来附加字符串以创建完整的段落。这有效,但仅适用于 LSA。我想知道是否有人询问我如何让其他摘要方法输出超过 1 个句子。所有这些算法在 IDLE 中都可以正常工作,只是不是我的 Flask 应用程序。抱歉英语不好。

最佳答案

原来鲍勃不是我叔叔。我的 return 语句位于 for 循环内部而不是外部。这个问题已经解决了。

关于Python/flask汇总算法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52863400/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com