我正在尝试使用斯坦福NER标记命名实体.我的代码非常简单:
from nltk.tag import StanfordNERTagger st = StanfordNERTagger('stanford-ner/classifiers/english.all.3class.distsim.crf.ser.gz', 'stanford-ner/stanford-ner.jar', encoding='utf-8') st.tag('Rami Eid is studying at Stony Brook University in NY'.split())
但是,我无法让它发挥作用.我得到的是一个Java异常说:
Exception in thread "main" java.lang.UnsupportedClassVersionError: edu/stanford/nlp/ie/crf/CRFClassifier : Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) raise OSError('Java command failed : ' + str(cmd)) OSError: Java command failed : [u'/usr/bin/java', '-mx1000m', '-cp', 'stanford-ner/stanford-ner.jar', 'edu.stanford.nlp.ie.crf.CRFClassifier', '-loadClassifier', 'stanford-ner/classifiers/english.all.3class.distsim.crf.ser.gz', '-textFile', '/tmp/tmpq3u0oi', '-outputFormat', 'slashTags', '-tokenizerFactory', 'edu.stanford.nlp.process.WhitespaceTokenizer', '-tokenizerOptions', '"tokenizeNLs=false"']
什么可能导致这次崩溃?先感谢您.
您正在使用旧版本的Java.什么是输出/usr/bin/java -version
?它至少应该是Java 8.