-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClassifyLoanWords.rb
36 lines (28 loc) · 1.03 KB
/
ClassifyLoanWords.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# This script iterates the words in the text files in the given directories
# and asks the user if the words have been loaned from English.
# Only words that have been classified as (possibly) interesting are taken
# into account. The files containing interesting words are read from the
# current directory.
require 'io/console'
LibDir = File.dirname(__FILE__) + '/lib/'
require File.expand_path(LibDir + 'WordClassifierDirectTranslatedOriginal')
require File.expand_path(LibDir + 'WordClassifierYesNoMaybe')
require File.expand_path(LibDir + 'Helpers')
include Helpers
def get_cmd_line_args()
if ARGV.length != 1
puts "\nArguments: <directory>"
exit
end
get_dirs_from_cmd_line_args(ARGV).first
end
# Main
directory = get_cmd_line_args
classifier = WordClassifierDirectTranslatedOriginal.new
quit = false
puts "Analyzing words in directory " + directory
WordClassifierYesNoMaybe::get_interesting_word_files(directory).each do |file_name|
quit = classifier.classify_words_in_file(file_name)
break if quit
end
classifier.save