module NlpToolz

author LeFnord email pscholz.le@gmail.com date 2014-10-12

author: LeFnord email: pscholz.le@gmail.com date: 2012-12-10

ToDo 2012-10-24: add train capabilities

ToDo 2012-10-24: add train capabilities

author: LeFnord email: pscholz.le@gmail.com date: 2012-11-30

author: LeFnord email: pscholz.le@gmail.com date: 2012-10-23

Constants

CLASS_PATH
CONFIG
HOME
JARS
MODELS
VERSION

Public Instance Methods

check_dependencies() click to toggle source
# File lib/nlp_toolz.rb, line 37
def check_dependencies
  unless Dir.exist?(File.join(NlpToolz::HOME,'models')) && Dir.exist?(File.join(NlpToolz::HOME,'jars'))
    $stdout.puts "\n--> models and jars not installed,"
    $stdout.puts "    install it by running:"
    $stdout.puts "--> $ nlp_toolz init\n".green
    exit
  end
end
get_lang(input) click to toggle source
# File lib/nlp_toolz.rb, line 46
def get_lang(input)
  NlpToolz::Language.get_language(input)
end
get_sentences(input,lang = nil) click to toggle source
# File lib/nlp_toolz.rb, line 50
def get_sentences(input,lang = nil)
  text = NlpToolz::Sentences.new(input,lang)
  text.split_into_sentences if text.has_model?
end
parse_sentence(input,lang = nil) click to toggle source
# File lib/nlp_toolz.rb, line 83
def parse_sentence(input,lang = nil)
  text = NlpToolz::Parser.new(input,lang)
  text.parse_text

  text.parse_hash
end
parse_text(input,lang = nil) click to toggle source
# File lib/nlp_toolz.rb, line 90
def parse_text(input,lang = nil)
  parsed_text = []
  get_sentences(input,lang).each do |sentence|
    parsed_text << parse_sentence(sentence,lang)
  end

  parsed_text
end
tag_sentence(input,lang = nil) click to toggle source
# File lib/nlp_toolz.rb, line 69
def tag_sentence(input,lang = nil)
  sentence = NlpToolz::PosTags.new(input,lang)
  sentence.get_pos_tags if sentence.has_model?
end
tag_text(input,lang = nil) click to toggle source
# File lib/nlp_toolz.rb, line 74
def tag_text(input,lang = nil)
  tagged_text = []
  get_sentences(input,lang).each do |sentence|
    tagged_text << tag_sentence(sentence,lang)
  end

  tagged_text
end
tokenize_sentence(input,lang = nil) click to toggle source
# File lib/nlp_toolz.rb, line 55
def tokenize_sentence(input,lang = nil)
  sentence = NlpToolz::Tokens.new(input,lang)
  sentence.tokenize
end
tokenize_text(input,lang = nil) click to toggle source
# File lib/nlp_toolz.rb, line 60
def tokenize_text(input,lang = nil)
  tokenized_text = []
  get_sentences(input,lang).each do |sentence|
    tokenized_text << tokenize_sentence(sentence,lang)
  end

  tokenized_text
end