DBPedia聚焦较小的文本(单词)而不是段落

时间:2017-05-08 08:37:47

标签: java dbpedia spotlight-dbpedia

我认为这个问题早先被问过,但原因不明。我是DBPedia的新手,对编写问题知之甚少。我试图解决的问题是自然语言问题。我能够从给定的句子中提取实体。我可以将其中一些分类为名称,组织和人员,但无法正确分类其余部分。所以我想添加一个查找选项,我在DPpedia这样的数据库中查找它们进行分类。就在昨天,一位善良的灵魂建议我看看DBPedia Spotlight。我完成了继承文件。将它集成到我的java代码中的最佳方法是:

import org.dbpedia.spotlight.annotate.DefaultParagraphAnnotator
import org.dbpedia.spotlight.disambiguate.{TwoStepDisambiguator, ParagraphDisambiguatorJ}
import org.dbpedia.spotlight.model.SpotlightConfiguration
import org.dbpedia.spotlight.model.SpotlightFactory
  val text = new String("Brazilian oil giant Petrobras and U.S. oilfield service company Halliburton have signed a technological cooperation agreement, Petrobras announced Monday. The two companies agreed on three projects: studies on contamination of fluids in oil wells, laboratory simulation of well production, and research on solidification of salt and carbon dioxide formations, said Petrobras. Twelve other projects are still under negotiation.")
  val configuration = new SpotlightConfiguration("conf/server.properties")
  val factory = new SpotlightFactory(configuration)
  val disambiguator = new ParagraphDisambiguatorJ(new TwoStepDisambiguator(factory.candidateSearcher, factory.contextSearcher))
  val spotter = factory.spotter()
  val annotator = new DefaultParagraphAnnotator(spotter, disambiguator);
  println(annotator.annotate(text))

但是,我不想注释段落。只需对我从一个可能是实体的句子中提取的单词运行注释,例如雅虎首席执行官玛丽莎梅耶斯昨天在新闻发布会上表示......"我能够提取雅虎和玛丽莎梅耶斯。现在我想使用DBPedia为它们分配分类。

非常感谢任何帮助。

0 个答案:

没有答案