frable / python-sutime Goto Github PK
View Code? Open in Web Editor NEWPython wrapper for Stanford CoreNLP's SUTime
License: GNU General Public License v3.0
Python wrapper for Stanford CoreNLP's SUTime
License: GNU General Public License v3.0
I am using Google Colab and trying to use Stanford sutime library inside a function that is being called by pyspark.
This function takes a row of a given RDD and then uses the sutime library to return a (sentence, frequency) pair.
def convert1(row):
s=str(row.dosefrequency)
s=s.lower()
try:
i=sutime.parse(s) #This parses the input string and output the frequency like P1D(Per Day).
if len(i)>0:
if 'timex-value' in i[0]:
return [s,i[0]['timex-value']]
else:
return []
else:
return []
except Exception as e:
return []
My input RDD looks like:-
rdd.take(3)
'''
[Row(practiceid=701, dosequantity='200', dosefrequency='take 2 tablet by oral route every day', count_dosequantity=716, count_dosefrequency=1, count_patientuid=306, DM Current -hychqudose='200mg', DM Expected Value='400mg'),
Row(practiceid=595, dosequantity='200', dosefrequency='take 1 tablet by oral route 2 times every day', count_dosequantity=327, count_dosefrequency=1, count_patientuid=230, DM Current -hychqudose='200mg', DM Expected Value='400mg'),
Row(practiceid=623, dosequantity='200', dosefrequency='take 1 (200MG) by oral route 2 times every day', count_dosequantity=339, count_dosefrequency=1, count_patientuid=180, DM Current -hychqudose='200mg', DM Expected Value='400mg')]
'''
This is how i am calling the function using flatmap :
details = rdd.flatMap(lambda row: convert1(row)).collect()
But it gives me the following error:
Traceback (most recent call last):
File "/usr/lib/python3.6/pickle.py", line 916, in save_global
__import__(module_name, level=0)
ModuleNotFoundError: No module named 'edu'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 841, in save_global
return Pickler.save_global(self, obj, name=name)
File "/usr/lib/python3.6/pickle.py", line 922, in save_global
(obj, module_name, name))
_pickle.PicklingError: Can't pickle <java class 'edu.stanford.nlp.python.SUTimeWrapper'>: it's not found as edu.stanford.nlp.python.edu.stanford.nlp.python.SUTimeWrapper
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/pickle.py", line 916, in save_global
__import__(module_name, level=0)
ModuleNotFoundError: No module named 'java'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 841, in save_global
return Pickler.save_global(self, obj, name=name)
File "/usr/lib/python3.6/pickle.py", line 922, in save_global
(obj, module_name, name))
_pickle.PicklingError: Can't pickle <java class 'java.lang.Object'>: it's not found as java.lang.java.lang.Object
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/serializers.py", line 468, in dumps
return cloudpickle.dumps(obj, pickle_protocol)
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 1097, in dumps
cp.dump(obj)
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 357, in dump
return Pickler.dump(self, obj)
File "/usr/lib/python3.6/pickle.py", line 409, in dump
self.save(obj)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python3.6/pickle.py", line 751, in save_tuple
save(element)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 501, in save_function
self.save_function_tuple(obj)
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 730, in save_function_tuple
save(state)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python3.6/pickle.py", line 821, in save_dict
self._batch_setitems(obj.items())
File "/usr/lib/python3.6/pickle.py", line 847, in _batch_setitems
save(v)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python3.6/pickle.py", line 781, in save_list
self._batch_appends(obj)
File "/usr/lib/python3.6/pickle.py", line 808, in _batch_appends
save(tmp[0])
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 496, in save_function
self.save_function_tuple(obj)
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 730, in save_function_tuple
save(state)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python3.6/pickle.py", line 821, in save_dict
self._batch_setitems(obj.items())
File "/usr/lib/python3.6/pickle.py", line 847, in _batch_setitems
save(v)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python3.6/pickle.py", line 821, in save_dict
self._batch_setitems(obj.items())
File "/usr/lib/python3.6/pickle.py", line 852, in _batch_setitems
save(v)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 496, in save_function
self.save_function_tuple(obj)
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 730, in save_function_tuple
save(state)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python3.6/pickle.py", line 821, in save_dict
self._batch_setitems(obj.items())
File "/usr/lib/python3.6/pickle.py", line 847, in _batch_setitems
save(v)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python3.6/pickle.py", line 821, in save_dict
self._batch_setitems(obj.items())
File "/usr/lib/python3.6/pickle.py", line 852, in _batch_setitems
save(v)
File "/usr/lib/python3.6/pickle.py", line 521, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python3.6/pickle.py", line 634, in save_reduce
save(state)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python3.6/pickle.py", line 821, in save_dict
self._batch_setitems(obj.items())
File "/usr/lib/python3.6/pickle.py", line 847, in _batch_setitems
save(v)
File "/usr/lib/python3.6/pickle.py", line 521, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python3.6/pickle.py", line 605, in save_reduce
save(cls)
File "/usr/lib/python3.6/pickle.py", line 490, in save
self.save_global(obj)
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 850, in save_global
return self.save_dynamic_class(obj)
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 662, in save_dynamic_class
obj=obj)
File "/usr/lib/python3.6/pickle.py", line 610, in save_reduce
save(args)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python3.6/pickle.py", line 751, in save_tuple
save(element)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python3.6/pickle.py", line 736, in save_tuple
save(element)
File "/usr/lib/python3.6/pickle.py", line 490, in save
self.save_global(obj)
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 850, in save_global
return self.save_dynamic_class(obj)
File "/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/cloudpickle.py", line 666, in save_dynamic_class
save(clsdict)
File "/usr/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python3.6/pickle.py", line 821, in save_dict
self._batch_setitems(obj.items())
File "/usr/lib/python3.6/pickle.py", line 847, in _batch_setitems
save(v)
File "/usr/lib/python3.6/pickle.py", line 496, in save
rv = reduce(self.proto)
TypeError: can't pickle _jpype._JMethod objects
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
/usr/lib/python3.6/pickle.py in save_global(self, obj, name)
915 try:
--> 916 __import__(module_name, level=0)
917 module = sys.modules[module_name]
ModuleNotFoundError: No module named 'edu'
During handling of the above exception, another exception occurred:
PicklingError Traceback (most recent call last)
65 frames
PicklingError: Can't pickle <java class 'edu.stanford.nlp.python.SUTimeWrapper'>: it's not found as edu.stanford.nlp.python.edu.stanford.nlp.python.SUTimeWrapper
During handling of the above exception, another exception occurred:
ModuleNotFoundError Traceback (most recent call last)
ModuleNotFoundError: No module named 'java'
During handling of the above exception, another exception occurred:
PicklingError Traceback (most recent call last)
PicklingError: Can't pickle <java class 'java.lang.Object'>: it's not found as java.lang.java.lang.Object
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
TypeError: can't pickle _jpype._JMethod objects
During handling of the above exception, another exception occurred:
PicklingError Traceback (most recent call last)
/content/spark-3.0.1-bin-hadoop3.2/python/pyspark/serializers.py in dumps(self, obj)
476 msg = "Could not serialize object: %s: %s" % (e.__class__.__name__, emsg)
477 print_exec(sys.stderr)
--> 478 raise pickle.PicklingError(msg)
479
480
PicklingError: Could not serialize object: TypeError: can't pickle _jpype._JMethod objects
Although I tried to call the convert1 function explicitly using the code :
rr=rdd.take(10)
for i in range(10):
x=convert1(rr[i])
print(x)
The above code perfectly fine for me. It is not working with flatMap.
Kindly ask for necessary details if required.
Currently, sutime sutime==0.2.0
doesn't seem to work with the latest version of CoreNLP(3.7.0).
Confirmed by _required_jars
being set to jars for version 3.6.0.
Can I use the existing wrapper to work with the latest version of CoreNLP? If so, what changes I need to make.
If not, are there any plans for this integration.
it echo this error, when i ran "python test_sutime.py" in the /soft/python-sutime-master/sutime/test.
ImportError: /soft/anaconda3/lib/python3.6/site-packages/_jpype.cpython-36m-x86_64-linux-gnu.so: undefined symbol: PySlice_Unpack
python: Python 3.6.0 |Anaconda 4.3.0 (64-bit)| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
sutime: sutime (1.0.1)
thx
I try to set up todays date as a reference_date e.g '2022-02-17' but when I'm parsing text 'now' I get PRESENT_REF instead of todays date. Can someone help me with this?
I have a bug:
site-packages/jpype/_jclass.py", line 212, in _JClassNew
javaClass = _jpype.PyJPClass(arg)
jpype._jclass.NoClassDefFoundError: edu/stanford/nlp/python/SUTimeWrapper
require is wrong (in package install)
# _required_jars = {
# 'stanford-corenlp-3.6.0-models.jar',
# 'stanford-corenlp-3.6.0.jar',
# 'gson-2.7.jar',
# 'slf4j-simple-1.7.21.jar'
# }
_required_jars = {
"stanford-corenlp-3.9.2-models.jar",
"stanford-corenlp-3.9.2.jar",
"gson-2.8.5.jar",
"slf4j-simple-1.7.25.jar",
}
I wanted to suppress the log statements on the console, as it adds disturbance in the output stdout. Can someone please let me know how can I suppress the [main] INFO logs.
Why it is not working by just replacing ThreadPoolExecutor with ProcessPoolExecutor?
@FraBle Can you please look at this and reply as soon as possible? Thank you.
Here is a code snippet using your code:
import os
import json
from sutime import SUTime
from concurrent.futures import ProcessPoolExecutor
from multiprocessing import cpu_count
def get_sutime():
jar_files = os.path.join(os.path.dirname(__file__), os.pardir, "jars")
sutime = SUTime(jars=jar_files, mark_time_ranges=True)
return sutime
def struct_filing(sentence, sutime):
return sentence, sutime.parse(sentence)
def get_time(text_list):
sutime = get_sutime()
with ProcessPoolExecutor(max_workers=cpu_count()) as executor:
return dict(
future.result()
for future in [
executor.submit(struct_filing, sentence, sutime)
for sentence in text_list
]
)
if __name__ == "__main__":
data_set_1 = {
"The Formula One race came to Singapore in 2008.",
"It was a tremendous success and gained wide international coverage.",
"In a first for the F1, the event was held at night.",
"State-of-the-art technology was used to ensure that the race operated"
" in near daylight conditions.",
"Holding the race at night had a great advantage as European audiences"
" could watch it at a convenient time.",
"Over the years, Singapore’s tourism industry has gained significant"
" benefits from the media attention that the race has generated",
}
print(json.dumps(get_time(data_set_1), sort_keys=True, indent=4))
Originally posted by @FraBle in #9 (comment)
I previous think that the model can be pre-load. But after test (create an sutime api in django), the model can't pre-load in memory, is there any other solution?
I installed maven2 with
sudo apt-get install maven2
Then I ran
mvn dependency:copy-dependencies -DoutputDirectory=./jars
I got the following error
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [dependency:copy-dependencies]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot execute mojo: copy-dependencies. It requires a project with an existing pom.xml, but the build is not using one.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Mon May 07 20:06:56 IST 2018
[INFO] Final Memory: 4M/118M
[INFO] ------------------------------------------------------------------------
I am trying to install python sutime in Windows 10 with Python 3.5.
Installation fails with the following error.
building '_jpype' extension
error: [WinError 2] The system cannot find the file specified
Complete installation log as follows:
Collecting sutime
Using cached https://files.pythonhosted.org/packages/b3/2e/88920eb5bd900990160f76a9fe0b40d163ecfe89122434519a0271d2932b/sutime-0.2.0-py2.py3-none-any.whl
Collecting JPype1 (from sutime)
Using cached https://files.pythonhosted.org/packages/c4/4b/60a3e63d51714d4d7ef1b1efdf84315d118a0a80a5b085bb52a7e2428cdc/JPype1-0.6.3.tar.gz
Installing collected packages: JPype1, sutime
Running setup.py install for JPype1: started
Running setup.py install for JPype1: finished with status 'error'
Complete output from command "c:\program files\python 3.5\python.exe" -u -c "import setuptools, tokenize;file='C:\Users\Public\Documents\Wondershare\CreatorTemp\pip-install-iu3pcoji\JPype1\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\Public\Documents\Wondershare\CreatorTemp\pip-record-6nyol0s6\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\jpype
copying jpype\imports.py -> build\lib.win-amd64-3.5\jpype
copying jpype\JClassUtil.py -> build\lib.win-amd64-3.5\jpype
copying jpype\nio.py -> build\lib.win-amd64-3.5\jpype
copying jpype\reflect.py -> build\lib.win-amd64-3.5\jpype
copying jpype_classpath.py -> build\lib.win-amd64-3.5\jpype
copying jpype_core.py -> build\lib.win-amd64-3.5\jpype
copying jpype_cygwin.py -> build\lib.win-amd64-3.5\jpype
copying jpype_darwin.py -> build\lib.win-amd64-3.5\jpype
copying jpype_gui.py -> build\lib.win-amd64-3.5\jpype
copying jpype_jarray.py -> build\lib.win-amd64-3.5\jpype
copying jpype_jboxed.py -> build\lib.win-amd64-3.5\jpype
copying jpype_jclass.py -> build\lib.win-amd64-3.5\jpype
copying jpype_jcollection.py -> build\lib.win-amd64-3.5\jpype
copying jpype_jexception.py -> build\lib.win-amd64-3.5\jpype
copying jpype_jio.py -> build\lib.win-amd64-3.5\jpype
copying jpype_jobject.py -> build\lib.win-amd64-3.5\jpype
copying jpype_jpackage.py -> build\lib.win-amd64-3.5\jpype
copying jpype_jproxy.py -> build\lib.win-amd64-3.5\jpype
copying jpype_jvmfinder.py -> build\lib.win-amd64-3.5\jpype
copying jpype_jwrapper.py -> build\lib.win-amd64-3.5\jpype
copying jpype_linux.py -> build\lib.win-amd64-3.5\jpype
copying jpype_properties.py -> build\lib.win-amd64-3.5\jpype
copying jpype_pykeywords.py -> build\lib.win-amd64-3.5\jpype
copying jpype_refdaemon.py -> build\lib.win-amd64-3.5\jpype
copying jpype_windows.py -> build\lib.win-amd64-3.5\jpype
copying jpype_init_.py -> build\lib.win-amd64-3.5\jpype
creating build\lib.win-amd64-3.5\jpype\awt
copying jpype\awt_init_.py -> build\lib.win-amd64-3.5\jpype\awt
creating build\lib.win-amd64-3.5\jpype\awt\event
copying jpype\awt\event\WindowAdapter.py -> build\lib.win-amd64-3.5\jpype\awt\event
copying jpype\awt\event_init_.py -> build\lib.win-amd64-3.5\jpype\awt\event
creating build\lib.win-amd64-3.5\jpypex
copying jpypex_init_.py -> build\lib.win-amd64-3.5\jpypex
creating build\lib.win-amd64-3.5\jpypex\swing
copying jpypex\swing\AbstractAction.py -> build\lib.win-amd64-3.5\jpypex\swing
copying jpypex\swing\pyutils.py -> build\lib.win-amd64-3.5\jpypex\swing
copying jpypex\swing_init_.py -> build\lib.win-amd64-3.5\jpypex\swing
running build_ext
C:\Users\Public\Documents\Wondershare\CreatorTemp\pip-install-iu3pcoji\JPype1\setup.py:173: FeatureNotice: Turned ON Numpy support for fast Java array access
FeatureNotice)
building '_jpype' extension
error: [WinError 2] The system cannot find the file specified
----------------------------------------
mvn dependency:copy-dependencies -DoutputDirectory=./jars => this is failing with below error.
Goal requires a project to execute but there is no POM in this directory.
Any idea how to resolve this. It would be of great help.
I created a german ruleset and try to use it.
The problem is if I change the sutime.py language to german it still loads the English rules.
Has anybody a solution for that?
My workaround for now was to add the changed rules to the spanish model as 'spanish.sutime'.
It would be great if the wrapper would support setting a reference date for SUTime to use.
From http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/time/TimeAnnotator.html:
If a reference time is set (via CoreAnnotations.DocDateAnnotation), then temporal expressions are resolved with respect to the document date. You set it on an Annotation as follows:
annotation.set(CoreAnnotations.DocDateAnnotation.class, "2013-07-14");
In sutime.py, there are certain jar files which are marked as required, and in jars those files have been updated and therefore now sutime.py is showing error, so to resolve this, i manually changed the names of those 'required jar files' in sutime.py.
can you please fix this issue, so that I do not need to manually change the names of jar files.
For this error, I found that the python command import importlib; has an issue and throws a util not found error. Instead the command should be from importlib import util and then removing the util keyword.
The new command should be:
mvn dependency:copy-dependencies -DoutputDirectory=./jars -f $(python3 -c ' from importlib import util; import pathlib; print(pathlib.Path(util.find_spec("sutime").origin).parent / "pom.xml")')
Its possible to change the language of sutime to support spanish ?
Installed all of the jars in the pom and kept getting an error says the dependencies didn't line up. Looks like the required jars in sutime.py are not aligned with the versions listed in the pom.
I have been trying to run the example given on readme but everytime this error shows up
Traceback (most recent call last): File "time_check.py", line 9, in <module> sutime = SUTime(jars=jar_files, mark_time_ranges=True) File "/home/prabhu/.local/lib/python3.5/site-packages/sutime/sutime.py", line 46, in __init__ self._classpath = self._create_classpath() File "/home/prabhu/.local/lib/python3.5/site-packages/sutime/sutime.py", line 87, in _create_classpath 'Not all necessary Java dependencies have been downloaded!') RuntimeError: Not all necessary Java dependencies have been downloaded!
When I use the following command on Jupyter notebook (Windows):
!pip install sutime
!mvn dependency:copy-dependencies -DoutputDirectory=./jars -f $(python3 -c 'import importlib; import pathlib; print(pathlib.Path(importlib.util.find_spec("sutime").origin).parent / "pom.xml")')
I get the following error:
POM file "$(python3" specified the -f/--file command-line argument does not exist
I'm trying to follow your install instructions, but am meeting errors. I have downloaded pod.xlm
, updated maven
, and am running mvn dependency:copy-dependencies -DoutputDirectory=./jars
from inside the sutime
directory, which is in an anaconda
environment, i.e. /anacona3/envs/my_env/lib/site-packages/sutime/
.
Any pointers?
Also, you should consider updating your readme. The install instructions would be simple enough to detail, but they are currently very unclear, and it shouldn't be necessary to trawl through issues to understand you have to download pom.xlm
and cd
into the sutime
dir to install.
Here's my maven
and java
system info (generated by mvn -v
):
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/cole/apache-maven-3.6.3
Java version: 10.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
And here's a debug trace of the install:
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-parseable POM /anaconda3/envs/phd/lib/python3.6/site-packages/sutime/pom.xml: Expected root element 'project' but found 'html' (position: START_TAG seen ...<!DOCTYPE html>\n<html lang="en">... @7:17) @ line 7, column 17
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project (/anaconda3/envs/phd/lib/python3.6/site-packages/sutime/pom.xml) has 1 error
[ERROR] Non-parseable POM /anaconda3/envs/phd/lib/python3.6/site-packages/sutime/pom.xml: Expected root element 'project' but found 'html' (position: START_TAG seen ...<!DOCTYPE html>\n<html lang="en">... @7:17) @ line 7, column 17 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
(phd) Coles-MacBook-Air-2:sutime cole$ mvn dependency:copy-dependencies -DoutputDirectory=./jars -X
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/cole/apache-maven-3.6.3
Java version: 10.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
[DEBUG] Created new class realm maven.api
[DEBUG] Importing foreign packages into class realm maven.api
[DEBUG] Imported: javax.annotation.* < plexus.core
[DEBUG] Imported: javax.annotation.security.* < plexus.core
[DEBUG] Imported: javax.enterprise.inject.* < plexus.core
[DEBUG] Imported: javax.enterprise.util.* < plexus.core
[DEBUG] Imported: javax.inject.* < plexus.core
[DEBUG] Imported: org.apache.maven.* < plexus.core
[DEBUG] Imported: org.apache.maven.artifact < plexus.core
[DEBUG] Imported: org.apache.maven.classrealm < plexus.core
[DEBUG] Imported: org.apache.maven.cli < plexus.core
[DEBUG] Imported: org.apache.maven.configuration < plexus.core
[DEBUG] Imported: org.apache.maven.exception < plexus.core
[DEBUG] Imported: org.apache.maven.execution < plexus.core
[DEBUG] Imported: org.apache.maven.execution.scope < plexus.core
[DEBUG] Imported: org.apache.maven.lifecycle < plexus.core
[DEBUG] Imported: org.apache.maven.model < plexus.core
[DEBUG] Imported: org.apache.maven.monitor < plexus.core
[DEBUG] Imported: org.apache.maven.plugin < plexus.core
[DEBUG] Imported: org.apache.maven.profiles < plexus.core
[DEBUG] Imported: org.apache.maven.project < plexus.core
[DEBUG] Imported: org.apache.maven.reporting < plexus.core
[DEBUG] Imported: org.apache.maven.repository < plexus.core
[DEBUG] Imported: org.apache.maven.rtinfo < plexus.core
[DEBUG] Imported: org.apache.maven.settings < plexus.core
[DEBUG] Imported: org.apache.maven.toolchain < plexus.core
[DEBUG] Imported: org.apache.maven.usability < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.* < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.authentication < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.authorization < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.events < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.observers < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.proxy < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.repository < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.resource < plexus.core
[DEBUG] Imported: org.codehaus.classworlds < plexus.core
[DEBUG] Imported: org.codehaus.plexus.* < plexus.core
[DEBUG] Imported: org.codehaus.plexus.classworlds < plexus.core
[DEBUG] Imported: org.codehaus.plexus.component < plexus.core
[DEBUG] Imported: org.codehaus.plexus.configuration < plexus.core
[DEBUG] Imported: org.codehaus.plexus.container < plexus.core
[DEBUG] Imported: org.codehaus.plexus.context < plexus.core
[DEBUG] Imported: org.codehaus.plexus.lifecycle < plexus.core
[DEBUG] Imported: org.codehaus.plexus.logging < plexus.core
[DEBUG] Imported: org.codehaus.plexus.personality < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.Xpp3Dom < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlPullParser < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlPullParserException < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlSerializer < plexus.core
[DEBUG] Imported: org.eclipse.aether.* < plexus.core
[DEBUG] Imported: org.eclipse.aether.artifact < plexus.core
[DEBUG] Imported: org.eclipse.aether.collection < plexus.core
[DEBUG] Imported: org.eclipse.aether.deployment < plexus.core
[DEBUG] Imported: org.eclipse.aether.graph < plexus.core
[DEBUG] Imported: org.eclipse.aether.impl < plexus.core
[DEBUG] Imported: org.eclipse.aether.installation < plexus.core
[DEBUG] Imported: org.eclipse.aether.internal.impl < plexus.core
[DEBUG] Imported: org.eclipse.aether.metadata < plexus.core
[DEBUG] Imported: org.eclipse.aether.repository < plexus.core
[DEBUG] Imported: org.eclipse.aether.resolution < plexus.core
[DEBUG] Imported: org.eclipse.aether.spi < plexus.core
[DEBUG] Imported: org.eclipse.aether.transfer < plexus.core
[DEBUG] Imported: org.eclipse.aether.version < plexus.core
[DEBUG] Imported: org.fusesource.jansi.* < plexus.core
[DEBUG] Imported: org.slf4j.* < plexus.core
[DEBUG] Imported: org.slf4j.event.* < plexus.core
[DEBUG] Imported: org.slf4j.helpers.* < plexus.core
[DEBUG] Imported: org.slf4j.spi.* < plexus.core
[DEBUG] Populating class realm maven.api
[INFO] Error stacktraces are turned on.
[DEBUG] Message scheme: color
[DEBUG] Message styles: debug info warning error success failure strong mojo project
[DEBUG] Reading global settings from /Users/cole/apache-maven-3.6.3/conf/settings.xml
[DEBUG] Reading user settings from /Users/cole/.m2/settings.xml
[DEBUG] Reading global toolchains from /Users/cole/apache-maven-3.6.3/conf/toolchains.xml
[DEBUG] Reading user toolchains from /Users/cole/.m2/toolchains.xml
[DEBUG] Using local repository at /Users/cole/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /Users/cole/.m2/repository
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-parseable POM /anaconda3/envs/phd/lib/python3.6/site-packages/sutime/pom.xml: Expected root element 'project' but found 'html' (position: START_TAG seen ...<!DOCTYPE html>\n<html lang="en">... @7:17) @ line 7, column 17
@
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-parseable POM /anaconda3/envs/phd/lib/python3.6/site-packages/sutime/pom.xml: Expected root element 'project' but found 'html' (position: START_TAG seen ...<!DOCTYPE html>\n<html lang="en">... @7:17) @ line 7, column 17
at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:397)
at org.apache.maven.graph.DefaultGraphBuilder.collectProjects (DefaultGraphBuilder.java:414)
at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor (DefaultGraphBuilder.java:405)
at org.apache.maven.graph.DefaultGraphBuilder.build (DefaultGraphBuilder.java:82)
at org.apache.maven.DefaultMaven.buildGraph (DefaultMaven.java:507)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:219)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR] The project (/anaconda3/envs/phd/lib/python3.6/site-packages/sutime/pom.xml) has 1 error
[ERROR] Non-parseable POM /anaconda3/envs/phd/lib/python3.6/site-packages/sutime/pom.xml: Expected root element 'project' but found 'html' (position: START_TAG seen ...<!DOCTYPE html>\n<html lang="en">... @7:17) @ line 7, column 17 -> [Help 2]
org.apache.maven.model.io.ModelParseException: Expected root element 'project' but found 'html' (position: START_TAG seen ...<!DOCTYPE html>\n<html lang="en">... @7:17)
at org.apache.maven.model.io.DefaultModelReader.read (DefaultModelReader.java:117)
at org.apache.maven.model.io.DefaultModelReader.read (DefaultModelReader.java:85)
at org.apache.maven.model.building.DefaultModelProcessor.read (DefaultModelProcessor.java:111)
at org.apache.maven.model.building.DefaultModelBuilder.readModel (DefaultModelBuilder.java:552)
at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:281)
at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:448)
at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:414)
at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:377)
at org.apache.maven.graph.DefaultGraphBuilder.collectProjects (DefaultGraphBuilder.java:414)
at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor (DefaultGraphBuilder.java:405)
at org.apache.maven.graph.DefaultGraphBuilder.build (DefaultGraphBuilder.java:82)
at org.apache.maven.DefaultMaven.buildGraph (DefaultMaven.java:507)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:219)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: Expected root element 'project' but found 'html' (position: START_TAG seen ...<!DOCTYPE html>\n<html lang="en">... @7:17)
at org.apache.maven.model.io.xpp3.MavenXpp3ReaderEx.read (MavenXpp3ReaderEx.java:4418)
at org.apache.maven.model.io.xpp3.MavenXpp3ReaderEx.read (MavenXpp3ReaderEx.java:598)
at org.apache.maven.model.io.DefaultModelReader.read (DefaultModelReader.java:108)
at org.apache.maven.model.io.DefaultModelReader.read (DefaultModelReader.java:85)
at org.apache.maven.model.building.DefaultModelProcessor.read (DefaultModelProcessor.java:111)
at org.apache.maven.model.building.DefaultModelBuilder.readModel (DefaultModelBuilder.java:552)
at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:281)
at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:448)
at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:414)
at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:377)
at org.apache.maven.graph.DefaultGraphBuilder.collectProjects (DefaultGraphBuilder.java:414)
at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor (DefaultGraphBuilder.java:405)
at org.apache.maven.graph.DefaultGraphBuilder.build (DefaultGraphBuilder.java:82)
at org.apache.maven.DefaultMaven.buildGraph (DefaultMaven.java:507)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:219)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
I am able to use this in python in Colab. But I want to run this in my PySpark-Scala Colab.
Hello!
So, i'm trying to run python-sutime but i keep getting this error:
"RuntimeError: Not all necessary Java dependencies have been downloaded!"
The picture below are from my files after i had installed with maven:
Im using:
I want to identify name , address from given Japanese text using python libraries
import spacy
nlp = spacy.load('xx_ent_wiki_sm')
sentence = "私の名前はサイキランです"
doc = nlp(sentence)
print(doc.ents
During a recent deploy the jpype1 lib was automatically updated and our systems integrated with SUTime started to crash with the following exception:
TypeError json in loads
error
the JSON object must be str, bytes or bytearray, not 'java.lang.String'.
The issue occurs in line 159 of the sutime.py file return json.loads(self._sutime.annotate(input_str, reference_date))
call.
"""
if not jpype.isThreadAttachedToJVM():
jpype.attachThreadToJVM()
if reference_date:
return json.loads(self._sutime.annotate(input_str, reference_date))
return json.loads(self._sutime.annotate(input_str))
Hello,
I'm using your (awesome) wrapper for a big project to get the dates in a sentences. It worked fine until I tried to parallelized it with several threads
Now it crashes my Jupyter Notebook
Here a simplified version of my code
My data
data_set_1 = {
"The Formula One race came to Singapore in 2008.",
"It was a tremendous success and gained wide international coverage.",
"In a first for the F1, the event was held at night.",
" State-of-the-art technology was used to ensure that the race operated in near daylight conditions.",
"Holding the race at night had a great advantage as European audiences could watch it at a convenient time.",
"Over the years, Singapore’s tourism industry has gained significant benefits \
from the media attention that the race has generated"
}
from sutime import SUTime
import concurrent.futures
def get_sutime():
jar_files = "path to jars"
sutime = SUTime(jars=jar_files, mark_time_ranges=True)
return sutime
def struct_filing(sentence, sutime):
su_list = sutime.parse(sentence)
def get_time(text_list, initial_date):
struct = {}
date = initial_date
sutime = get_sutime()
executor = concurrent.futures.ThreadPoolExecutor(5)
futures = [executor.submit(struct_filing, sentence, sutime) for sentence in text_list]
concurrent.futures.wait(futures)
return struct
struct = get_time(data_set_1, [2017, 9, 22])
And if I replace the parallel for by a normal one, it works fine.
executor = concurrent.futures.ThreadPoolExecutor(5)
futures = [executor.submit(struct_filing, sentence, sutime) for sentence in text_list]
concurrent.futures.wait(futures)
replaced by
for sentence in text_list:
struct_filing(sentence, sutime)
Does that mean that we can't use the same sutime in different thread? So parse different sentence at the same time is forbidden?
python3.6
Windows 10 64bits
It used to work before, now I get this error:
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Registering annotator sutime with class edu.stanford.nlp.time.TimeAnnotator
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator tokenize
[main] INFO edu.stanford.nlp.pipeline.TokenizerAnnotator - TokenizerAnnotator: No tokenizer type provided. Defaulting to PTBTokenizer.
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ssplit
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator pos
Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [1.1 sec].
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator lemma
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ner
sutime.includeRange=false
Unknown property: |sutime.includeRange|
sutime.markTimeRanges=false
Unknown property: |sutime.markTimeRanges|
Loading classifier from edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... Unknown property: |sutime.includeRange|
Unknown property: |sutime.markTimeRanges|
done [1.6 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz ... Unknown property: |sutime.includeRange|
Unknown property: |sutime.markTimeRanges|
done [0.8 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz ... Unknown property: |sutime.includeRange|
Unknown property: |sutime.markTimeRanges|
done [0.9 sec].
[main] INFO edu.stanford.nlp.time.JollyDayHolidays - Initializing JollyDayHoliday for SUTime from classpath edu/stanford/nlp/models/sutime/jollyday/Holidays_sutime.xml as sutime.binder.1.
Jan 26, 2018 11:22:17 AM de.jollyday.util.XMLUtil unmarshallConfiguration
WARNING: Could not create JAXB context using the current threads context classloader. Defaulting to ObjectFactory classloader.
Traceback (most recent call last):
File "charlie.py", line 43, in <module>
sutime = SUTime(jars=jar_files)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sutime/sutime.py", line 59, in __init__
self.mark_time_ranges, self.include_range)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jpype/_jclass.py", line 86, in _javaInit
*args)
jpype._jexception.ReflectionLoading$ReflectionLoadingExceptionPyRaisable: edu.stanford.nlp.util.ReflectionLoading$ReflectionLoadingException: Error creating edu.stanford.nlp.time.TimeExpressionExtractorImpl
I'm using version 0.20.0 to build a custom temporal parser. I have got the parser working on my local machine, but when i try to run it on a server I'm getting an error as mentioned in the title. Could you point out why this error is happening or point to me how i could solve this? This is the traceback that I'm getting:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "date_normalizer.py", line 29, in __init__
self.sutime = SUTime(jars=self.jar_files, mark_time_ranges=mark_time_ranges)
File "/home/bridgei2i/converser/normalizer_test/local/lib/python2.7/dist-packa ges/sutime/sutime.py", line 47, in __init__
self._start_jvm()
File "/home/bridgei2i/converser/normalizer_test/local/lib/python2.7/dist-packa ges/sutime/sutime.py", line 69, in _start_jvm
classpath=self._classpath)
File "/home/bridgei2i/converser/normalizer_test/local/lib/python2.7/dist ges/JPype1-0.7.0-py2.7-linux-x86_64.egg/jpype/_core.py", line 219, in star
_jpype.startup(jvmpath, tuple(args), ignoreUnrecognized, convertString
jpype._jclass.UnsupportedClassVersionError: org/jpype/classloader/JPypeCla er : Unsupported major.minor version 52.0
$ python -c 'import importlib; import pathlib; print(pathlib.Path(importlib.util.find_spec("sutime").origin).parent / "pom.xml")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: module 'importlib' has no attribute 'util'
Python Version is 3.8.5 on Ubuntu 20.04.2
I have installed maven
and downloaded all dependencies from pom.xml
.
Executing SUTime(jars="path/to/jars")
following error occured. Please reply what to do as soon as possible.
-------------------------------------------------------------------------------
Deprecated: convertStrings was not specified when starting the JVM. The default
behavior in JPype will be False starting in JPype 0.8. The recommended setting
for new code is convertStrings=False. The legacy value of True was assumed for
this session. If you are a user of an application that reported this warning,
please file a ticket with the developer.
-------------------------------------------------------------------------------
""")
Traceback (most recent call last):
File "/home/user/PycharmProjects/parser/src/main.py", line 1, in <module>
from src.date_parser.date_parser import parse_dates
File "/home/user/PycharmProjects/parser/src/date_parser/date_parser.py", line 19, in <module>
sutimes = SUTime(jars=jar_files)
File "/home/user/Apps/anaconda3/envs/parser/lib/python3.7/site-packages/sutime/sutime.py", line 71, in __init__
"edu.stanford.nlp.python.SUTimeWrapper"
File "/home/user/Apps/anaconda3/envs/parser/lib/python3.7/site-packages/jpype/_jclass.py", line 130, in __new__
return _JClassNew(args[0], **kwargs)
File "/home/user/Apps/anaconda3/envs/parser/lib/python3.7/site-packages/jpype/_jclass.py", line 213, in _JClassNew
javaClass = _jpype.PyJPClass(arg)
jpype._jclass.UnsupportedClassVersionError: edu/stanford/nlp/python/SUTimeWrapper has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 54.0
After following the install instructions, and copying the example code into a file called core.py,
running python core.py
results in the following error:
python2.7/site-packages/jpype/_jclass.py", line 55, in JClass
raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
jpype._jexception.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class edu.stanford.nlp.python.SUTimeWrapper not found
From what I can tell from the code, all the files are in the correct locations.
Any idea what might be wrong?
This is all running inside a virtualenv
on OSX El Cap 10.11.6
with Python version 2.7.9 (64 bit)
Java version:
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
STACK TRACE :
edu.stanford.nlp.util.ReflectionLoading$ReflectionLoadingExceptionPyRaisableTraceback (most recent call last)
in ()
6
7 jar_files = "C:/Users/Rohit/AppData/Local/conda/conda/envs/rohitfroot/Lib/site-packages/sutime/jars"
----> 8 sutime = SUTime(jars=jar_files, mark_time_ranges=True)
9
10 print(json.dumps(sutime.parse(test_case), sort_keys=True, indent=4))
~\AppData\Local\conda\conda\envs\rohitfroot\lib\site-packages\sutime\sutime.py in init(self, jars, jvm_started, mark_time_ranges, include_range)
57 'edu.stanford.nlp.python.SUTimeWrapper')
58 self._sutime = SUTimeWrapper(
---> 59 self.mark_time_ranges, self.include_range)
60 self._is_loaded = True
61 finally:
~\AppData\Local\conda\conda\envs\rohitfroot\lib\site-packages\jpype_jclass.py in _javaInit(self, *args)
109 else:
110 self.javaobject = self.class.javaclass.newClassInstance(
--> 111 *args)
112
113
edu.stanford.nlp.util.ReflectionLoading$ReflectionLoadingExceptionPyRaisable: edu.stanford.nlp.util.ReflectionLoading$ReflectionLoadingException: Error creating edu.stanford.nlp.time.TimeExpressionExtractorImpl
DETAILS :
Python == 3.7
OS == Windows 8.1
JPype == 0.6.3
Could anyone tell me what is going wrong?
[ERROR] Failed to execute goal on project stanford-corenlp-sutime-python: Could not resolve dependencies for project edu.stanford.nlp:stanford-corenlp-sutime-python:
jar:1.4.0: Could not transfer artifact edu.stanford.nlp:stanford-corenlp:jar:models:3.9.2 from/to central (https://repo.maven.apache.org/maven2): GET request of: edu
/stanford/nlp/stanford-corenlp/3.9.2/stanford-corenlp-3.9.2-models.jar from central failed: Read timed out -> [Help 1]
(base) C:\Users\SAIKIRAN\Desktop\GithubSUTime\python-sutime-master>python SUTime.py
Traceback (most recent call last):
File "SUTime.py", line 16, in
sutime = SUTime(jars=jar_files, mark_time_ranges=True)
File "C:\Users\SAIKIRAN\Desktop\GithubSUTime\python-sutime-master\sutime\sutime.py", line 81, in init
self._start_jvm(jvm_flags)
File "C:\Users\SAIKIRAN\Desktop\GithubSUTime\python-sutime-master\sutime\sutime.py", line 121, in _start_jvm
flags = ["-Djava.class.path=" + self._create_classpath()]
File "C:\Users\SAIKIRAN\Desktop\GithubSUTime\python-sutime-master\sutime\sutime.py", line 139, in _create_classpath
"Not all necessary Java dependencies have been downloaded!"
RuntimeError: Not all necessary Java dependencies have been downloaded!
I am wondering what is the issue with this error. The installation went fine according to the instructions, and I checked that the jar files seem to be all in order. I use another stanfordcorenlp wrapper, and its java dependencies are working fine with the current installation. I am using python 3.6
Thanks for create this package. I am using it with corenlp 3.9.2 just change the following version of jars:
_required_jars = {
'stanford-corenlp-3.9.2-models.jar',
'stanford-corenlp-3.9.2.jar',
'gson-2.8.5.jar',
'slf4j-simple-1.7.25.jar'
}
But how to load the custom SUTime rules (such as edu/stanford/nlp/models/sutime/defs.sutime.txt) ?
In the online application, how to make these rules effect in realtime (for the new added rules) ?
Is there any suggestion? Thanks very much.
I try to download the pom.xml file and put it inside the sutime package, and run the next command.
but when i try to run the python script, same issue happens: Not all necessary Java dependencies have been downloaded!
So I'm using the same code as given in the read me with few tweaks. I can see in the source code that SUTime expects a list of jars
def __init__(self, jars=[], jvm_started=False, mark_time_ranges=False, include_range=False):
and required jars in the source code are
_required_jars = { 'stanford-corenlp-3.6.0-models.jar', 'stanford-corenlp-3.6.0.jar', 'gson-2.7.jar', 'slf4j-simple-1.7.21.jar' }
Following is my code:
if __name__ == '__main__':
test_case = u'I need a desk for tomorrow from 2pm to 3pm'
jar_files = ['C:/Users/mohit.motwani/AppData/Local/Temp/pip-install-hk39ku98/sutime/sutime/jars/stanford-corenlp-sutime-python-1.0.0.jar',
'C:/Users/mohit.motwani/Downloads/stanford-ner-2018-02-27/stanford-ner.jar',
'C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2018.1.5/lib/gson-2.8.2.jar',
'C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2018.1.5/plugins/maven/lib/maven3/lib/slf4j-simple-1.7.5.jar']
sutime = SUTime(jars=jar_files, mark_time_ranges=True)
print(json.dumps(sutime.parse(test_case), sort_keys=True, indent=4))
I get the error
TypeError Traceback (most recent call last)
<ipython-input-131-a66e62edb0a9> in <module>()
3
4 # jar_files = os.path.join(os.path.dirname(__file__), 'jars')
----> 5 sutime = SUTime( mark_time_ranges=True)
6
7 print(json.dumps(sutime.parse(test_case), sort_keys=True, indent=4))
~\AppData\Local\Continuum\anaconda3\lib\site-packages\sutime\sutime.py in __init__(self, jars, jvm_started, mark_time_ranges, include_range)
44
45 if not jvm_started:
---> 46 self._classpath = self._create_classpath()
47 self._start_jvm()
48
~\AppData\Local\Continuum\anaconda3\lib\site-packages\sutime\sutime.py in _create_classpath(self)
78 jars = [sutime_jar]
79 jar_file_names = []
---> 80 for top, dirs, files in os.walk(self.jars):
81 for file_name in files:
82 if file_name.endswith('.jar'):
~\AppData\Local\Continuum\anaconda3\Lib\os.py in walk(top, topdown, onerror, followlinks)
333
334 """
--> 335 top = fspath(top)
336 dirs = []
337 nondirs = []
TypeError: expected str, bytes or os.PathLike object, not list
Am I missing something or making a mistake? What's the best fix to this problem?
Hi, this lib is crashing on the input below, with:
File "step_1_gen_input.py", line 34, in <lambda>
return lambda text: sutime.parse(text)
File "/usr/local/lib/python3.5/site-packages/sutime/sutime.py", line 107, in parse
return json.loads(self._sutime.annotate(input_str))
jpype._jexception.IllegalArgumentExceptionPyRaisable: java.lang.IllegalArgumentException: Fields invalid for add
Code (that worked on another 145 samples):
from sutime import SUTime
jars = os.path.join(os.path.dirname(__file__), 'jars')
sutime = SUTime(jars, mark_time_ranges=True)
[...]
sutime.parse(text)
Input:
Hi Sally,
I need to be working on my newest project, for which we went to Hallettsville
this week, and tomorrow is Garden club, and I am almost through as president.
I will not preside in April, as I have a conflict-new secretary in Colonial
Dames and then all we have left in Garden Club will be our May luncheon.
Being presdent has not been too bad, as all of the ladies are very helpful.
My project is the completion of our papers for the recognition of our
cemetery by the State Historic Commissson . That is why we were in
Hallettville. Hope to get that done by Tuesday-there are many attachments
necessary. We stayed in a Bed and Breakfast, which was fair but not
oustanding breakfast. I ran by to see Dot for a few minutes before we headed
home. Mary had spent Sunday night with us to go with us and we met our
cousin from Missouri City also.
Enough of that, this will be a great quick way to communicate. I am glad
Cindy gave me your address. Hope you have had a great week-end. I will
write more another time.
Love,
Mom (almost signed it Sue)
why the library is running so much slow?,
CPU times: user 2.55 s, sys: 614 ms, total: 3.17 s
Wall time: 3min 11s
the output as following,
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Registering annotator sutime with class edu.stanford.nlp.time.TimeAnnotator
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator tokenize
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ssplit
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator pos
[main] INFO edu.stanford.nlp.tagger.maxent.MaxentTagger - Loading POS tagger from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [0.9 sec].
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator lemma
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ner
[main] INFO edu.stanford.nlp.sequences.SeqClassifierFlags - sutime.includeRange=false
[main] INFO edu.stanford.nlp.sequences.SeqClassifierFlags - Unknown property: |sutime.includeRange|
[main] INFO edu.stanford.nlp.sequences.SeqClassifierFlags - sutime.language=english
[main] INFO edu.stanford.nlp.sequences.SeqClassifierFlags - sutime.markTimeRanges=true
[main] INFO edu.stanford.nlp.sequences.SeqClassifierFlags - Unknown property: |sutime.markTimeRanges|
[main] INFO edu.stanford.nlp.sequences.SeqClassifierFlags - Unknown property: |sutime.includeRange|
[main] INFO edu.stanford.nlp.sequences.SeqClassifierFlags - Unknown property: |sutime.markTimeRanges|
[main] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... done [1.4 sec].
[main] INFO edu.stanford.nlp.sequences.SeqClassifierFlags - Unknown property: |sutime.includeRange|
[main] INFO edu.stanford.nlp.sequences.SeqClassifierFlags - Unknown property: |sutime.markTimeRanges|
[main] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz ... done [1.4 sec].
[main] INFO edu.stanford.nlp.sequences.SeqClassifierFlags - Unknown property: |sutime.includeRange|
[main] INFO edu.stanford.nlp.sequences.SeqClassifierFlags - Unknown property: |sutime.markTimeRanges|
[main] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz ... done [0.7 sec].
[main] INFO edu.stanford.nlp.time.JollyDayHolidays - Initializing JollyDayHoliday for SUTime from classpath edu/stanford/nlp/models/sutime/jollyday/Holidays_sutime.xml as sutime.binder.1.
[main] INFO edu.stanford.nlp.time.TimeExpressionExtractorImpl - Using following SUTime rules: edu/stanford/nlp/models/sutime/defs.sutime.txt,edu/stanford/nlp/models/sutime/english.sutime.txt,edu/stanford/nlp/models/sutime/english.holidays.sutime.txt
[main] INFO edu.stanford.nlp.pipeline.TokensRegexNERAnnotator - ner.fine.regexner: Read 580704 unique entries out of 581863 from edu/stanford/nlp/models/kbp/english/gazetteers/regexner_caseless.tab, 0 TokensRegex patterns.
[main] INFO edu.stanford.nlp.pipeline.TokensRegexNERAnnotator - ner.fine.regexner: Read 4869 unique entries out of 4869 from edu/stanford/nlp/models/kbp/english/gazetteers/regexner_cased.tab, 0 TokensRegex patterns.
[main] INFO edu.stanford.nlp.pipeline.TokensRegexNERAnnotator - ner.fine.regexner: Read 585573 unique entries from 2 files
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator sutime
[main] INFO edu.stanford.nlp.time.JollyDayHolidays - Initializing JollyDayHoliday for SUTime from classpath edu/stanford/nlp/models/sutime/jollyday/Holidays_sutime.xml as sutime.binder.1.
[main] INFO edu.stanford.nlp.time.TimeExpressionExtractorImpl - Using following SUTime rules: edu/stanford/nlp/models/sutime/defs.sutime.txt,edu/stanford/nlp/models/sutime/english.sutime.txt,edu/stanford/nlp/models/sutime/english.holidays.sutime.txt
Hi,
thanks fro the efforts. it's a really wonderful library. I am very new to NLP and have a simple question. I read from the CoreNLP page, there are several language supported, including German and Chinese. I am wondering if they are also supported by this package, since it is dependent on the CoreNLP.
Chuan
I've started the jvm before calling sutime with jvm_started=True but the process just gets killed (interrupted by signal 11: SIGSEGV). Any idea how to resolve this?
When I try to pip install sutime I get the following error and I am nnot sure how to resolve the issue:
Collecting sutime
Using cached https://files.pythonhosted.org/packages/b3/2e/88920eb5bd900990160f76a9fe0b40d163ecfe89122434519a0271d2932b/sutime-0.2.0-py2.py3-none-any.whl
Collecting JPype1
Using cached https://files.pythonhosted.org/packages/d7/62/0f312d578e0165e9b5e8fcae0291f7ee83783b3805f59071006b21229d55/JPype1-0.7.1.tar.gz
Installing collected packages: JPype1, sutime
Running setup.py install for JPype1 ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\ggcar\appdata\local\programs\python\python36\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\ggcar\AppData\Local\Temp\pip-install-r_4ei3ic\JPype1\setup.py'"'"'; file='"'"'C:\Users\ggcar\AppData\Local\Temp\pip-install-r_4ei3ic\JPype1\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\ggcar\AppData\Local\Temp\pip-record-nv0nmrni\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\ggcar\AppData\Local\Temp\pip-install-r_4ei3ic\JPype1
Complete output (61 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\jpype
copying jpype\beans.py -> build\lib.win-amd64-3.6\jpype
copying jpype\imports.py -> build\lib.win-amd64-3.6\jpype
copying jpype\nio.py -> build\lib.win-amd64-3.6\jpype
copying jpype\pickle.py -> build\lib.win-amd64-3.6\jpype
copying jpype\reflect.py -> build\lib.win-amd64-3.6\jpype
copying jpype\types.py -> build\lib.win-amd64-3.6\jpype
copying jpype_classpath.py -> build\lib.win-amd64-3.6\jpype
copying jpype_core.py -> build\lib.win-amd64-3.6\jpype
copying jpype_cygwin.py -> build\lib.win-amd64-3.6\jpype
copying jpype_darwin.py -> build\lib.win-amd64-3.6\jpype
copying jpype_gui.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jarray.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jboxed.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jclass.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jcollection.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jcomparable.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jcustomizer.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jexception.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jinit.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jio.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jobject.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jpackage.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jproxy.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jstring.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jtypes.py -> build\lib.win-amd64-3.6\jpype
copying jpype_jvmfinder.py -> build\lib.win-amd64-3.6\jpype
copying jpype_linux.py -> build\lib.win-amd64-3.6\jpype
copying jpype_pykeywords.py -> build\lib.win-amd64-3.6\jpype
copying jpype_windows.py -> build\lib.win-amd64-3.6\jpype
copying jpype_init_.py -> build\lib.win-amd64-3.6\jpype
running build_ext
running build_java
Using Jar cache
creating build\lib
creating build\lib\org
creating build\lib\org\jpype
creating build\lib\org\jpype\classloader
copying native\jars\org\jpype\classloader\JPypeClassLoader.class -> build\lib\org\jpype\classloader
copying native\jars\org.jpype.jar -> build\lib
running build_thunk
Building thunks
including thunk build\lib\org\jpype\classloader\JPypeClassLoader.class
including thunk build\lib\org.jpype.jar
C:\Users\ggcar\AppData\Local\Temp\pip-install-r_4ei3ic\JPype1\setupext\build_ext.py:87: FeatureNotice: Turned ON Numpy support for fast Java array access
FeatureNotice)
building '_jpype' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\build
creating build\temp.win-amd64-3.6\Release\build\src
creating build\temp.win-amd64-3.6\Release\native
creating build\temp.win-amd64-3.6\Release\native\common
creating build\temp.win-amd64-3.6\Release\native\python
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DWIN32=1 -DHAVE_NUMPY=1 -Inative\common\include -Inative\python\include -Ibuild\src -Inative\jni_include -Ic:\users\ggcar\appdata\local\programs\python\python36\lib\site-packages\numpy\core\include -Ic:\users\ggcar\appdata\local\programs\python\python36\include -Ic:\users\ggcar\appdata\local\programs\python\python36\include "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" /EHsc /Tpbuild\src\jp_thunk.cpp /Fobuild\temp.win-amd64-3.6\Release\build\src\jp_thunk.obj /Zi /EHsc /std:c++14
error: command 'cl.exe' failed: No such file or directory
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\ggcar\appdata\local\programs\python\python36\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\ggcar\AppData\Local\Temp\pip-install-r_4ei3ic\JPype1\setup.py'"'"'; file='"'"'C:\Users\ggcar\AppData\Local\Temp\pip-install-r_4ei3ic\JPype1\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\ggcar\AppData\Local\Temp\pip-record-nv0nmrni\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.