-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtranslate.rb
33 lines (32 loc) · 899 Bytes
/
translate.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
require 'rubygems'
require 'v8'
require './doge.rb'
def translate(input)
input = input.gsub("\n", " ")
cxt = V8::Context.new
cxt.load("parser_js/lexer.js")
cxt.load("parser_js/POSTagger.js")
cxt.load("parser_js/lexicon.js_")
cxt.load("parser_js/shibe.js")
cxt['input'] = input
# cxt['lex'] = cxt.eval('lexWords(in)')
# cxt['sortLex'] = ctx.eval('sortWords(lex)')
# cxt['phrases'] = ctx.eval('getPhrases()')
# text = cxt.eval('createShibe(shortLex, phrases)')
text = cxt.eval('createShibe(sortWords(lexWords(input)), getPhrases())')
puts text
lines = text.split("\n")
File.foreach('counter') do |i|
Doge.new do
lines.each { |x |
wuff(x.chomp)
}
end.image.write("/var/www/dogepics/doge#{i.chomp}.jpg")
end
File.open 'counter', 'r+' do |file|
num = file.gets.to_i
file.rewind
file.puts num.next
end
return text
end