簡體   English   中英

加載NER .bin文件作為openNLP :: Maxent_Entity_Annotator()的模型參數時出錯

[英]error loading NER .bin file as model argument for openNLP::Maxent_Entity_Annotator()

我使用Apache OpenNLP的命令行工具創建了一個模型來識別命名實體。 以下代碼使用文件sentences4OpenNLP.txt作為訓練集創建了模型。

opennlp TokenNameFinderTrainer -type maxent -model C:\Users\Documents\en-ner-org.bin -lang en -data C:\Users\Documents\apache-opennlp-1.6.0\sentences4OpenNLP.txt -encoding UTF-8

我從命令行通過將句子傳遞給tag來測試該模型,該模型似乎運行良好。 但是,我無法成功使用R中的模型。我在嘗試創建組織注釋功能時使用以下幾行。 使用相同的代碼加載從OpenNLP下載的模型可以正常工作。

modelNER <- "C:/Users/Documents/en-ner-org.bin"
oa <- openNLP::Maxent_Entity_Annotator(language = "en",
                                  kind = "organization",
                                  probs = TRUE,
                                  model = modelNER)

當上面的代碼運行時,我收到一條錯誤消息:

Could not instantiate the opennlp.tools.namefind.TokenNameFinderFactory. The initialization throw an exception.
opennlp.tools.util.ext.ExtensionNotLoadedException: Unable to find implementation for opennlp.tools.util.BaseToolFactory, the class or service opennlp.tools.namefind.TokenNameFinderFactory could not be located!
     at opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(ExtensionLoader.java:97)
     at opennlp.tools.util.BaseToolFactory.create(BaseToolFactory.java:106)
     at opennlp.tools.util.model.BaseModel.initializeFactory(BaseModel.java:254)
Error in .jnew("opennlp.tools.namefind.TokenNameFinderModel", .jcast(.jnew("java.io.FileInputStream",  : 
java.lang.IllegalArgumentException: opennlp.tools.util.InvalidFormatException: Could not instantiate the opennlp.tools.namefind.TokenNameFinderFactory. The initialization throw an exception.
     at opennlp.tools.util.model.BaseModel.loadModel(BaseModel.java:237)
     at opennlp.tools.util.model.BaseModel.<init>(BaseModel.java:181)
     at opennlp.tools.namefind.TokenNameFinderModel.<init>(TokenNameFinderModel.java:110)

關於如何解決該錯誤的任何建議將對您大有幫助。 提前致謝。

解決了錯誤。 R函數openNLP::Maxent_Entity_Annotator與OpenNLP 1.6.0生成的命名實體識別(NER)模型不兼容。 使用OpenNLP 1.5.3構建NER模型導致openNLP::Maxent_Entity_Annotator運行無錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM