Created
November 13, 2019 13:10
-
-
Save xdite/40d45ba483351448189df6c08e8673ee to your computer and use it in GitHub Desktop.
自动生成 AI 标题
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'yiban' | |
require 'tx_nlp' | |
keyword = ARGV[0] | |
json = Yiban::Text.new(keyword).json | |
title_list_array = json["title_list"] | |
new_array = title_list_array.sort_by { |hash| hash["score"] }.reverse | |
new_array.each do |arr| | |
score = (arr["score"].to_f * 100).round(2) | |
title = arr["title"] | |
puts "#{score}分: #{title}" | |
end | |
similar_words = TxNlp::Text.new(keyword).indent_result | |
puts "你还可以尝试相似词:#{similar_words}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
效果图