nlp/resources/morphology/utils/lib/getroot.rb
# extract the root form from morphology files
extract the root form from morphology files
extract the root form from morphology files
def generate_root_file(input_file_path, dictionary_type = :root)
    output_file_path = "#{input_file_path}.#{dictionary_type}"
    File.open(input_file_path, 'r') do |input_file|
      File.open(output_file_path, 'w') do |output_file|
        input_file.each_line do |line|
          line = line.strip
          next if line.empty?
          root = process(line, dictionary_type)
          output_file.write("#{root}\n") unless root.nil?
        end
      end
    end
  rescue
    FileUtils.mv(output_file_path, "#{output_file_path}.crashed")
    raise
  end
def generate_root_file ( input_file_path , dictionary_type = :root ) output_file_path = "#{input_file_path}.#{dictionary_type}" File . open ( input_file_path , 'r' ) do | input_file | File . open ( output_file_path , 'w' ) do | output_file | input_file . each_line do | line | line = line . strip next if line . empty? root = process ( line , dictionary_type ) output_file . write ( "#{root}\n" ) unless root . nil? end end end rescue FileUtils . mv ( output_file_path , "#{output_file_path}.crashed" ) raise end
extract the root form from morphology files
extract the root form from morphology files
input_file_path
<not_specific>
dictionary_type
<not_specific>