Class: AjaxCat::Request::Raw

Inherits:
Object
  • Object
show all
Defined in:
lib/ajax-cat/request/raw.rb

Direct Known Subclasses

Simple, Suggestion, Table

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sentence) ⇒ Raw

Returns a new instance of Raw.



11
12
13
14
15
16
# File 'lib/ajax-cat/request/raw.rb', line 11

def initialize(sentence)
	@sentence = sentence
	@lines = []
	@lock = Mutex.new
	@processed = false
end

Instance Attribute Details

#lockObject

Returns the value of attribute lock.



9
10
11
# File 'lib/ajax-cat/request/raw.rb', line 9

def lock
  @lock
end

#processedObject

Returns the value of attribute processed.



9
10
11
# File 'lib/ajax-cat/request/raw.rb', line 9

def processed
  @processed
end

#sentenceObject

Returns the value of attribute sentence.



9
10
11
# File 'lib/ajax-cat/request/raw.rb', line 9

def sentence
  @sentence
end

Class Method Details

.parse_position(line) ⇒ Object



30
31
32
# File 'lib/ajax-cat/request/raw.rb', line 30

def Raw.parse_position(line)
	Integer(line.split(" ||| ").first)
end

Instance Method Details

#prepare_moses_requestObject



18
19
20
# File 'lib/ajax-cat/request/raw.rb', line 18

def prepare_moses_request
	@sentence
end

#process_line(line) ⇒ Object



26
27
28
# File 'lib/ajax-cat/request/raw.rb', line 26

def process_line(line)
	@lines << line.chomp
end

#resultObject



22
23
24
# File 'lib/ajax-cat/request/raw.rb', line 22

def result
	@lines.join("\n")
end

#tokenize(str) ⇒ Object



34
35
36
# File 'lib/ajax-cat/request/raw.rb', line 34

def tokenize(str)
	str.strip.split(/[\t\n ]+/)
end