1

我认为这个问题之前被问过,但由于未知原因被删除。我对 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 为它们分配一个分类。

任何帮助将不胜感激。

4

0 回答 0