Class: LanguageTool::Process
- Inherits:
-
Object
- Object
- LanguageTool::Process
- Defined in:
- lib/language_tool/process.rb
Constant Summary collapse
- FLAGS =
%w(api auto_detect_language apply break_as_paragraph_break bilingual encoding disable enable language mothertongue recursive taggeronly list_unknown profile verbose)
- DEFAULT_ARGS =
FLAGS.inject({}) do |h, flag| h[flag.to_sym] = true h end
Instance Attribute Summary collapse
-
#opts ⇒ Object
Returns the value of attribute opts.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #feed(text) ⇒ Object
-
#initialize(path = LanguageTool::Jars.location, opts = {}) ⇒ Process
constructor
A new instance of Process.
- #shutdown! ⇒ Object
- #start! ⇒ Object
Constructor Details
#initialize(path = LanguageTool::Jars.location, opts = {}) ⇒ Process
Returns a new instance of Process.
19 20 21 22 23 24 |
# File 'lib/language_tool/process.rb', line 19 def initialize(path = LanguageTool::Jars.location, opts = {}) self.path = path self.opts = opts @started = false @closing = false end |
Instance Attribute Details
#opts ⇒ Object
Returns the value of attribute opts.
16 17 18 |
# File 'lib/language_tool/process.rb', line 16 def opts @opts end |
#path ⇒ Object
Returns the value of attribute path.
16 17 18 |
# File 'lib/language_tool/process.rb', line 16 def path @path end |
Instance Method Details
#feed(text) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/language_tool/process.rb', line 43 def feed(text) text << "\n\n" if text[-2,2] != "\n\n" @process.write(text) buf = "" while line = @process.readline do buf << line break if line == "</matches>\n" end buf end |
#shutdown! ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/language_tool/process.rb', line 33 def shutdown! @closing = true @started = false @process.close_write @process.read @process.close @closing = false $? end |
#start! ⇒ Object
26 27 28 29 30 31 |
# File 'lib/language_tool/process.rb', line 26 def start! @started = true Dir.chdir(self.path) do @process = IO.popen("java -jar languagetool-commandline.jar --api -l en-GB -m de-DE -", "r+") end end |