- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 OpenIE来自斯坦福 NLP 库的工具,用于从句子中获取最少的从句。以下是我到目前为止的想法(主要是从他们的演示代码中获得灵感):
public static void main(String[] args) {
Properties props = new Properties();
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,depparse,natlog,openie");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation doc = new Annotation("Obama was born in Hawaii. He is our president.");
pipeline.annotate(doc);
for (CoreMap sentence : doc.get(CoreAnnotations.SentencesAnnotation.class)) {
OpenIE split = new OpenIE(props);
List<SentenceFragment> clauses = split.clausesInSentence(sentence);
for (SentenceFragment clause : clauses) {
List<SentenceFragment> short_clauses = split.entailmentsFromClause(clause);
for (SentenceFragment short_clause : short_clauses){
System.out.println(short_clause.parseTree);
}
}
}
}
我现在想使用 PTB 组成树作为输入而不是纯文本,然后只使用 depparse、natlog 和 openie 注释器来获取子句。
我知道我可以使用 PTB 树作为 Stanford 解析器的输入(如 here 所述),但还没有想出如何将其集成到管道中。
最佳答案
这是我认为其实不平凡的。如果有人在管道中有一个干净的方法来做到这一点,请插话!但是,如果我要这样做,我可能只是手动调用代码的组件位。这意味着:
从选区树的 GrammaticalStructure
创建一个 SemanticGraph
对象。
为语义图中的每个IndexedWord
添加词条注释。这可以通过对每个标记调用 Morphology#lemma(word, posTag)
并将 LemmaAnnotation
设置为此来完成。
运行自然逻辑注释器会很棘手。一种选择是模拟一个 Annotation 对象并通过通常的 annotate()
方法推送它。但是,如果您不太关心 OpenIE 系统识别否定,您可以通过将值 Polarity#DEFAULT
添加到 SemanticGraph
上的每个标记来跳过此注释器PolarityAnnotation
键。
现在您的依赖树应该准备好通过 OpenIE 注释器。你想在这里打三个电话:
OpenIE#clausesInSentence(SemanticGraph)
将从给定的图形中生成一组子句。OpenIE#entailmentsFromClause(SentenceFragment)
将从每个子句生成简短的蕴涵。您希望将上述函数的每个输出传递给此函数,并收集所有生成的片段。OpenIE#relationsInFragment(SentenceFragment)
会将一个短蕴涵分割成一个关系三元组。它返回一个 Optional
——大多数片段不会分割成任何三元组。您想要将从上述调用中收集的每个短蕴涵传递给此函数,并收集在此函数的输出中定义的关系三元组。这些是您的 OpenIE 三元组。出于好奇,你到底想做什么?也许有更简单的方法来实现相同的目标。
关于java - 在 Stanford CoreNLP 流水线中输入 Penn Treebank 组成树,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34167592/
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 8年前关闭。 Improve thi
我正在寻找处理 Penn Treebank 结构的 Python 数据结构。这是 Treebank 的样例: ( (S (NP-SBJ (PRP He) ) (VP (VBD shou
说我有一句话: After he had eaten the cheese, Bill went to the grocery. 在我的程序中,我得到以下输出: ---PARSE TREE--- (R
我已经下载了 UPDT波斯语树库( Uppsala Persian Dependency Treebank ),我正在尝试使用斯坦福 NLP 从中构建依赖解析器模型。我尝试使用命令行和 Java 代码
我最初使用的是来自 NLTK 的以下 Penn Treebank 标记器: POS_Tagger = UnigramTagger(treebank.tagged_sents(), backoff=De
我正在专门寻找一些数据结构、枚举或生成过程,通过它们在内部表示不同的词性。我花了很长时间扫描了一段时间的Javadoc和源代码,找不到我要找的东西。如果可能的话,我想直接访问标签的集合,如果它们存储在
我正在寻找一个端口为 this 的 Perl 模块我基本上可以在其中创建一个对象,调用一个 tokenize() 子例程,传入一堆文本并取回一个标记列表。达到那种效果的东西。如果它不存在我会做,但重新
我知道 Treebank 语料库已经被标记了,但与 Brown 语料库不同,我不知道如何获得标签字典。例如, >>> from nltk.corpus import brown >>> wordcou
Penn Treebank tagset有一个单独的标签 TO对于单词“to”,无论它是用于介词意义(例如 I went to school )还是不定式意义(例如 I want to eat )。从
我有来自 OpenNLP 的 POS 标记输入...我需要将这些与 WordNet 一起使用...但 wordnet 仅使用 4 个标签 - 名词、动词、形容词、副词...其中 OpenNLP 根据
我正在使用 OpenIE来自斯坦福 NLP 库的工具,用于从句子中获取最少的从句。以下是我到目前为止的想法(主要是从他们的演示代码中获得灵感): public static void main(Str
我正在努力学习使用 NLTK在 python 中打包。特别是,我需要在 NLTK 中使用 penn tree bank 数据集。据我所知,如果我调用 nltk.download('treebank')
我对 NLTK 和 Python 还很陌生。我一直在使用示例中给出的玩具语法创建句子解析,但我想知道是否有可能使用从 Penn Treebank 的一部分学习的语法,而不是仅仅编写我自己的或使用玩具语
我是一名优秀的程序员,十分优秀!