lib/ajax-cat/request/suggestion.rb in ajax-cat-1.0.0 vs lib/ajax-cat/request/suggestion.rb in ajax-cat-2.0.1
- old
+ new
@@ -11,10 +11,11 @@
super(sentence)
@covered = covered
@translated = translated
@translated_length = tokenize(translated).length
@suggestions = []
+ @suggested_phrases = []
end
def prepare_moses_request
"#{@translated} ||| #{@covered} ||| #{@sentence}"
end
@@ -26,11 +27,20 @@
end
def process_line(line)
words = line.split(" ||| ")[1].strip.split(" ")
if @suggestions.length < @@rows
- suggestion = words[@translated_length, @@suggestion_length].join(" ")
- @suggestions.push(suggestion) unless @suggestions.member?(suggestion)
+ alignment = line.split(" ||| ")[4].strip.split(" ").first
+ phrase = Phrase.new(words, alignment)
+ suggestion = {
+ "text" => phrase.words,
+ "from" => phrase.from,
+ "to" => phrase.to
+ }
+ if not @suggested_phrases.member?(suggestion['text'])
+ @suggested_phrases.push(suggestion['text'])
+ @suggestions.push(suggestion)
+ end
end
end
end
\ No newline at end of file