-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
038d62b
commit 727a307
Showing
11 changed files
with
89 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,9 @@ | |
stanford: { | ||
jar_path: nil, | ||
model_path: nil | ||
}, | ||
open_nlp: { | ||
jar_path: nil, | ||
model_path: nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
class Treat::Loaders::BindIt | ||
|
||
# Keep track of whether its loaded or not. | ||
@@loaded = {} | ||
|
||
# Load CoreNLP package for a given language. | ||
def self.load(klass, name, language = nil) | ||
|
||
return if @@loaded[klass] | ||
|
||
language ||= Treat.core.language.default | ||
|
||
jar_path = Treat.libraries[name].jar_path || | ||
Treat.paths.bin + "#{name}/" | ||
model_path = Treat.libraries[name].model_path || | ||
Treat.paths.models + "#{name}/" | ||
|
||
if !File.directory?(jar_path) | ||
raise Treat::Exception, "Looking for #{klass} " + | ||
"library JAR files in #{jar_path}, but it is " + | ||
"not a directory. Please set the config option " + | ||
"Treat.libraries.#{name}.jar_path to a folder " + | ||
"containing the appropriate JAR files." | ||
end | ||
|
||
if !File.directory?(model_path) | ||
raise Treat::Exception, "Looking for #{klass} " + | ||
"library model files in #{model_path}, but it " + | ||
"is not a directory. Please set the config option " + | ||
"Treat.libraries.#{name}.model_path to a folder " + | ||
"containing the appropriate JAR files." | ||
end | ||
|
||
klass.jar_path = jar_path | ||
klass.model_path = model_path | ||
klass.use language | ||
|
||
if Treat.core.verbosity.silence | ||
klass.log_file = '/dev/null' | ||
end | ||
|
||
klass.bind | ||
|
||
@@loaded[klass] = true | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'treat/loaders/bind_it' | ||
|
||
# A helper class to load the OpenNLP package. | ||
class Treat::Loaders::OpenNLP < Treat::Loaders::BindIt | ||
|
||
require 'open-nlp' | ||
|
||
def self.load(language = nil) | ||
super(OpenNLP, :open_nlp, language) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters