我正在dotnet框架中开展一个Q&A项目,我需要做一些NLP流程,比如词性标注和生成解析树
我知道斯坦福解析器,但我对在C#中找到它的接口感到有点困惑我搜索了一个很好的选择,我发现:
1- http://nlpdotnet.com/Services/Introduction.aspx (但它不提供解析树)
我想知道是否还有一些好的选择
最近几天,我一直在与Stanford-NLP进行一些基本的调整。我也读过有关链接语法的文章。如果有人使用过这些库中的任何一个,是否可以使用其中任何一个来检测疑问句?目前,我在斯坦福大学自然语言处理学院任教。我可能必须添加大量代码才能使其工作。看来我可能需要创建一个单独的PCFG。
在我的代码中,我从第一个分类器获得Person识别,对于我创建的第二个分类器,我添加了一些要被识别或注释为Organization的单词,但它没有注释Person.
我需要从他们两个中获益,我该怎么做?
我正在使用Netbeans,这是代码:
String serializedClassifier = "classifiers/english.all.3class.distsim.crf.ser.gz";
String serializedClassifier2 = "/Users/ha/stanford-ner-2014-10-26/classifiers/dept-model.ser.gz";
if (args.length > 0) {
serializedClassifier = args[0];
}
AbstractSequenceClassifier<CoreLabel> classifier = CRFClassifier.getClassifier(serializedClassifier);
AbstractSequenceClassifier<CoreLabel> classifier2 = CRFClassifier.getClassifier(serializedClassifier2);
String fileContents = IOUtils.slurpFile("/Users/ha/NetBeansProjects/NERtry/src/nertry/input.txt");
List<List<CoreLabel>> out = classifier.classify(fileContents);
List<List<CoreLabel>> out2 = classifier2.classify(fileContents);
for (List<CoreLabel> sentence : out) {
System.out.print("\nenglish.all.3class.distsim.crf.ser.gz: ");
for (CoreLabel word : sentence) {
System.out.print(word.word() + '/' + word.get(CoreAnnotations.AnswerAnnotation.class) + ' ');
}
for (List<CoreLabel> sentence2 : out2) {
System.out.print("\ndept-model.ser.gz");
for (CoreLabel word2 : …Run Code Online (Sandbox Code Playgroud) 我找到了与Stanford Core NLP兼容的德语解析和pos-tag模型.但是我无法让德语词典化工作.有办法吗?
How can I get lemmas for Arabic words? I tried the ISRI Arabic Stemmer from NLTK but it returns roots of words:
from nltk.stem.isri import ISRIStemmer
st = ISRIStemmer()
print st.stem(u'????????')
Run Code Online (Sandbox Code Playgroud)
It returns the root ??? and i want the lemma ??????
我试图通过将文档剪切成句子来进行分类,然后将句子中的每个单词进行逻辑回归以进行逻辑回归.但是,我发现stanford的注释类在我的火花工作中造成了严重的瓶颈(它需要20分钟才能处理500k文件)
这是我目前用于句子解析和分类的代码
句子解析:
def prepSentences(text: String): List[CoreMap] = {
val mod = text.replace("Sr.", "Sr") // deals with an edge case
val doc = new Annotation(mod)
pipeHolder.get.annotate(doc)
val sentences = doc.get(classOf[SentencesAnnotation]).toList
sentences
}
Run Code Online (Sandbox Code Playgroud)
然后,我将采用每个coremap并按如下方式处理引理
def coreMapToLemmas(map:CoreMap):Seq[String] = {
map.get(classOf[TokensAnnotation]).par.foldLeft(Seq[String]())(
(a, b) => {
val lemma = b.get(classOf[LemmaAnnotation])
if (!(stopWords.contains(b.lemma().toLowerCase) || puncWords.contains(b.originalText())))
a :+ lemma.toLowerCase
else a
}
)
}
Run Code Online (Sandbox Code Playgroud)
也许有一个类只涉及一些处理?
我需要使用Stanford CoreNLP进行浅层解析和深度解析.我google了很多但没有成功.最后,我发现有2个解析器,Constituency解析器和Dependency解析器.
我的问题是:
选区解析器浅层解析和依赖解析器是深度解析吗?
任何人都可以把上述解析器的代码和任何有用的链接?
我在corenlp服务器上使用pycorenlp。我可以以字符串格式获取解析树。但是我可以像NLTK库这样的树来获取它吗?
from pycorenlp import StanfordCoreNLP
import pprint
import nltk
nlp = StanfordCoreNLP('http://localhost:9000')
text = ('Purgrug Vobter and Juklog Qligjar vruled into the Battlefield. Vobter was about to Hellfire. Juklog Qligjar started kiblaring.')
output = nlp.annotate(text, properties={
'annotators': 'tokenize,ssplit,pos,depparse,parse',
'outputFormat': 'json'
})
print [s['parse'] for s in output['sentences']]
Run Code Online (Sandbox Code Playgroud)
输出:
[u'(ROOT\r\n (S\r\n (NP (NNP Purgrug) (NNP Vobter)\r\n (CC and)\r\n (NNP Juklog) (NNP Qligjar))\r\n (VP (VBD vruled)\r\n (PP (IN into)\r\n (NP (DT the) (NN Battlefield))))\r\n (. .)))', u'(ROOT\r\n (S\r\n (NP (NNP Vobter))\r\n (VP …Run Code Online (Sandbox Code Playgroud) 我遇到一个问题,CoreNLP只能识别名为Kobe Bryant的命名实体,它以一个大写字母开头,但不能识别kobe bryant作为一个人!那么如何通过CoreNLP识别以小写字符开头的命名实体???? 欣赏它!!!!
我正在寻找在nltk中使用stanford字标记器的方法,我想使用,因为当我比较stanford和nltk字标记器的结果时,它们都是不同的.我知道可能有办法使用stanford tokenizer,就像我们可以在NLTK中支持POS Tagger和NER一样.
是否可以在不运行服务器的情况下使用stanford tokenizer?
谢谢
stanford-nlp ×10
java ×2
nlp ×2
python ×2
.net ×1
apache-spark ×1
netbeans ×1
nltk ×1
parsing ×1
python-2.7 ×1
python-3.x ×1
scala ×1
sharpnlp ×1
tokenize ×1