- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Stanford POS Tagger 执行 POS 标记。标注器仅返回输入句子的一种可能的标注。例如,当提供输入句子“The clown weeps.”时,词性标注器会生成(错误的)“The_DT clown_NN weeps_NNS ._.”。
但是,我的应用程序将尝试解析结果,并且可能会拒绝 POS 标记,因为无法解析它。因此,在此示例中,它将拒绝“The_DT clown_NN weeps_NNS ._”。但会接受“The_DT clown_NN weeps_VBZ ._”。我认为这是解析器的置信度较低的标记。
因此,我希望词性标注器为每个单词的标注提供多种假设,并用某种置信值进行注释。通过这种方式,我的应用程序可以选择具有最高置信度的 POS 标记,从而实现其目的的有效解析。
我没有找到方法让斯坦福 POS Tagger 为每个单词(甚至整个句子)生成多个(n 个最佳)标记假设。有没有办法做到这一点? (或者,我也可以使用另一个性能相当、支持此功能的词性标注器。)
最佳答案
OpenNLP允许获得 POS 标记的最佳值:
Some applications need to retrieve the n-best pos tag sequences and not only the best sequence. The topKSequences method is capable of returning the top sequences. It can be called in a similar way as tag.
Sequence topSequences[] = tagger.topKSequences(sent);
Each Sequence object contains one sequence. The sequence can be retrieved via Sequence.getOutcomes() which returns a tags array and Sequence.getProbs() returns the probability array for this sequence.
此外,还有一种方法可以让 spaCy 做这样的事情:
Doc.set_extension('tag_scores', default=None)
Token.set_extension('tag_scores', getter=lambda token: token.doc._.tag_scores[token.i])
class ProbabilityTagger(Tagger):
def predict(self, docs):
tokvecs = self.model.tok2vec(docs)
scores = self.model.softmax(tokvecs)
guesses = []
for i, doc_scores in enumerate(scores):
docs[i]._.tag_scores = doc_scores
doc_guesses = doc_scores.argmax(axis=1)
if not isinstance(doc_guesses, numpy.ndarray):
doc_guesses = doc_guesses.get()
guesses.append(doc_guesses)
return guesses, tokvecs
Language.factories['tagger'] = lambda nlp, **cfg: ProbabilityTagger(nlp.vocab, **cfg)
然后,每个标记将具有 tag_scores,其中包含来自 spaCy 的 tag map 的每个词性的概率。 .
关于nlp - 使用斯坦福 POS Tagger 获取多个标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16791716/
我在检测以小写字母开头的命名实体时遇到问题。如果我只用小写单词训练模型,那么准确率是合理的;但是,当模型使用完全大写的标记或什至是小写和大写混合训练时,结果非常糟糕。我尝试了斯坦福 NLP 小组提供的
这可能是一个愚蠢的问题,但是如何迭代解析树作为 NLP 解析器(如斯坦福 NLP)的输出?它都是嵌套的括号,既不是 array 也不是 dictionary 或我使用过的任何其他集合类型。 (ROOT
如何使用斯坦福解析器在 java 类中标记字符串? 我只能找到 documentProcessor 和 PTBTokenizer 从外部文件获取文本的示例。 DocumentPreprocessor
我的代码开头有以下内容: import twitter4j.*; import java.util.List; import java.util.Properties; import ja
这是我第一次在这里发帖;因此,如果我表现出任何不好的做法,请告诉我。 所以目前我正在尝试使用斯坦福大学的 OpenIE 从网络挖掘的数据中提取信息。由于我对 Java 很陌生,我只是从他们的页面复制了
我正在尝试使用斯坦福 CoreNLP 关系提取器 ( http://nlp.stanford.edu/software/relationExtractor.shtml )。 我已经安装了 CoreNL
我最近在使用Stanford Lexparser。不幸的是,我遇到了一个问题,因为它需要很长时间,特别是当我传递一个大文件时。多线程有助于提高性能吗?我知道多线程可以在命令行中轻松完成。但是,我想在内
原始推文已保存到以下结构的文件中: tweet language || tweet 以下是我的预处理阶段,用于删除 URL、RT、用户名和任何非字母数字字符。 def cleanTweets() {
在哪里可以找到有关基因、蛋白质、激素、转录因子、神经递质、细胞因子、生物标志物、表观遗传标志物、 enzyme 、RNA、器官、细胞、药物和疾病的斯坦福 NLP 命名实体识别库? 最佳答案 简而言之:
我在使用斯坦福大学的句子注释器时遇到了问题。作为输入,我得到了文本,其中包含句子,但其中某些部分的点后没有空格。像这样: Dog loves cat.Cat loves mouse. Mouse ha
通常,当您使用 corenlp 注释管道进行 NER 时,您将编写以下代码 Properties props = new Properties(); props.put("annotators", "
我正在尝试对推文进行情感分析,但出现奇怪的异常。 我正在使用属性文件初始化管道,并将属性文件放置在 src->main 文件夹内的资源目录中。 但在 init 函数中仍然出现异常: Exception
我正在尝试使用斯坦福库设置我的 NLP 解析器。在我下载的网站上 stanford-corenlp-full-2015-12-09.zip standford-french-corenlp-2016-
我正在尝试使用文件输入运行此代码并将其输出到另一个文件: import java.util.*; import edu.stanford.nlp.pipeline.*; import edu.stan
我正在Windows中做一个NLP项目,问题是每当我从命令提示符运行Stanford CoreNLP时,大约需要14-15秒才能生成给定输入文本文件的XML输出。我认为这个问题是因为库需要相当多的时间
我在 python 中使用斯坦福 NER 标记器。它没有标记日期和时间。相反,每个单词都返回 O。我的句子是: “多少钱才能在 3 年内以年利率 12% 的利率赚取 162 美元的利息” 我标记后得到
Soo... 该程序完全按照应有的方式运行,但我不明白该程序输出的花哨缩写是什么。 如果我输入'I wish today was a school day',程序会输出 I/PRP : wish/VB
我在 http://nlp.stanford.edu/software/stanford-corenlp-full-2015-04-20.zip 下载了 Stanford NLP 3.5.2 然后我解
在斯坦福自然语言处理中,有命名实体识别器功能来识别对话中的实体。有没有一种方法可以配置可以训练以指向特定意图的话语?类似于 LUIS (Microsoft)。 最佳答案 我正在使用 SharpNLP
我正在使用 Stanford CoreNLP 在 Windows 机器上运行 Java 的 NLP 项目。我想从这个注释一篇大文本文章。我写的代码如下; Properties props = new
我是一名优秀的程序员,十分优秀!