kotodama 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/wordgen +12 -8
- data/lib/kotodama.rb +1 -1
- metadata +2 -2
data/bin/wordgen
CHANGED
@@ -36,6 +36,9 @@ optparse = OptionParser.new do |opt|
|
|
36
36
|
opt.on '-o', '--out FILE', 'Write results to FILE' do |file|
|
37
37
|
options[:output] = file
|
38
38
|
end
|
39
|
+
opt.in '-z', '--zipf', 'Output Zipf frequencies' do
|
40
|
+
options[:zipf] = true
|
41
|
+
end
|
39
42
|
end
|
40
43
|
|
41
44
|
optparse.parse!
|
@@ -52,19 +55,20 @@ if File.exist? ARGV[0]
|
|
52
55
|
end
|
53
56
|
if result.parsed?
|
54
57
|
output = []
|
58
|
+
output_file = options[:output] ? File.open(options[:output], 'w') : STDOUT
|
59
|
+
if options[:zipf]
|
60
|
+
result.result.zipf.each do |key, value|
|
61
|
+
output_file.puts "#{key} => #{value}"
|
62
|
+
end
|
63
|
+
end
|
55
64
|
times.times do
|
56
65
|
output << result.result.generate(options)
|
57
66
|
end
|
58
|
-
|
59
|
-
|
60
|
-
file.puts output
|
61
|
-
end
|
62
|
-
else
|
63
|
-
puts output
|
64
|
-
end
|
67
|
+
output_file.puts output
|
68
|
+
output_file.close if output_file != STDOUT
|
65
69
|
else
|
66
70
|
STDERR.puts result.error
|
67
71
|
end
|
68
72
|
else
|
69
73
|
STDERR.puts "File `#{ARGV[0]}' does not exist"
|
70
|
-
end
|
74
|
+
end
|
data/lib/kotodama.rb
CHANGED