Sha256: 40933b6a2beef0f48f51082f8de65205d22d85cb31b612f029b66c07a05a90aa
Contents?: true
Size: 1.86 KB
Versions: 4
Compression:
Stored size: 1.86 KB
Contents
module Opener class LanguageIdentifier ## # CLI wrapper around {Opener::LanguageIdentifier} using Slop. # # @!attribute [r] parser # @return [Slop] # class CLI attr_reader :parser def initialize @parser = configure_slop end ## # @param [Array] argv # def run(argv = ARGV) parser.parse(argv) end ## # @return [Slop] # def configure_slop return Slop.new(:strict => false, :indent => 2, :help => true) do banner 'Usage: language-identifier [OPTIONS]' separator <<-EOF.chomp About: Language detection for various languages such as English and Dutch. This command reads input from STDIN. Output can be a language code as plain text, a KAF document containing the input text and language code, or a list of probabilities. Example: cat some_file.kaf | language-identifier EOF separator "\nOptions:\n" on :v, :version, 'Shows the current version' do abort "language-identifier v#{VERSION} on #{RUBY_DESCRIPTION}" end on :'no-kaf', 'Disables KAF output' on :p, :probs, 'Displays probabilities instead of a language code' run do |opts, args| enable_kaf = true enable_probs = false if opts[:'no-kaf'] enable_kaf = false end if opts[:probs] enable_kf = false enable_probs = true end identifier = LanguageIdentifier.new( :args => args, :kaf => enable_kaf, :probs => enable_probs ) input = STDIN.tty? ? nil : STDIN.read puts identifier.run(input) end end end end # CLI end # LanguageIdentifier end # Opener
Version data entries
4 entries across 4 versions & 1 rubygems