Skip to content

Instantly share code, notes, and snippets.

@xdite
Created November 13, 2019 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdite/40d45ba483351448189df6c08e8673ee to your computer and use it in GitHub Desktop.
Save xdite/40d45ba483351448189df6c08e8673ee to your computer and use it in GitHub Desktop.
自动生成 AI 标题
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}"
@xdite
Copy link
Author

xdite commented Nov 13, 2019

效果图

@xdite
Copy link
Author

xdite commented Nov 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment