我无法理解如何打印以下代码的输出
$query = (new Tour)->newQuery();
if($request->has('destination')){
$query->where('destination', '=', $request->get('destination'));
}
if($request->has('date')){
$query->where('departure', '=', $request->get('date'));
}
if($request->has('hotel')){
$query->where('hotel', '=', $request->get('hotel'));
}
$tours = $query->get();
我想打印关键短语和他们的tfidf分数
谢谢
答案 0 :(得分:2)
我正在处理博客文章中发现的相同代码并遇到与您相同的问题。
以下是整个代码: https://gist.github.com/bbengfort/efb311aaa1b52814c284d3b21ae752d6
基本上你只需要添加
if __name__ == '__main__':
tfidfs, id2word = score_keyphrases_by_tfidf(texts)
fileids = texts.fileids()
# Print top keywords by TF-IDF
for idx, doc in enumerate(tfidfs):
print("Document '{}' key phrases:".format(fileids[idx]))
# Get top 20 terms by TF-IDF score
for wid, score in heapq.nlargest(20, doc, key=itemgetter(1)):
print("{:0.3f}: {}".format(score, id2word[wid]))
print("")