-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finally got Stanford wrapper to work nicely for word-by-word annotati…
…ons.
- Loading branch information
Mark Granroth-Wilding
committed
Mar 29, 2016
1 parent
ceb0a02
commit 59f5e80
Showing
15 changed files
with
346 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ lib/python/* | |
models/* | ||
!models/Makefile | ||
docs/_build/* | ||
log/ |
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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import os | ||
from pimlico import LOG_DIR | ||
|
||
|
||
def get_log_file(name): | ||
""" | ||
Returns the path to a log file that may be used to output helpful logging info. Typically used | ||
to output verbose error information if something goes wrong. The file can be found in the Pimlico | ||
log dir. | ||
:param name: identifier to distinguish from other logs | ||
:return: path | ||
""" | ||
if not os.path.exists(LOG_DIR): | ||
os.makedirs(LOG_DIR) | ||
return os.path.abspath(os.path.join(LOG_DIR, "%s.log" % name)) |
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 |
---|---|---|
@@ -1 +1,9 @@ | ||
__author__ = 'mark' | ||
|
||
|
||
class CoreNLPClientError(Exception): | ||
pass | ||
|
||
|
||
class CoreNLPProcessingError(Exception): | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from pimlico.core.external.java import check_java_dependency, DependencyCheckerError | ||
from pimlico.core.modules.base import DependencyError | ||
|
||
|
||
def check_corenlp_dependencies(module_name): | ||
""" | ||
Check dependencies in the style of module dependency checkers and return a list of the missing | ||
dependencies in the form they use. Designed to make it easy for all modules that use CoreNLP to | ||
check the basic deps. | ||
""" | ||
missing_dependencies = [] | ||
try: | ||
class_name = "edu.stanford.nlp.pipeline.StanfordCoreNLPServer" | ||
try: | ||
check_java_dependency(class_name) | ||
except DependencyError, e: | ||
if e.stderr is not None: | ||
extra_err = ". (Error: %s)" % e.stderr.splitlines()[0] | ||
else: | ||
extra_err = "" | ||
missing_dependencies.append(("CoreNLP", module_name, | ||
"Couldn't load %s. Install Stanford CoreNLP libraries in Java lib dir using " | ||
"'make corenlp'%s" % (class_name, extra_err))) | ||
except DependencyCheckerError, e: | ||
missing_dependencies.append(("Java dependency checker", module_name, str(e))) | ||
|
||
# We depend on the requests library | ||
try: | ||
import requests | ||
except ImportError: | ||
missing_dependencies.append(("Python requests library", module_name, | ||
"Install together with all CoreNLP python deps in Python lib dir using " | ||
"'make stanford'")) | ||
return missing_dependencies |
Oops, something went wrong.