0

我正在尝试在 C# 中使用 Stanford CoreNLP(这是一个 Java 项目)。

我发现这个Nuget 包包含使用 IKVM 转换为 .NET 的 CoreNLP,它工作正常,但是我还需要对 java 项目进行一些修改。

我从Github下载了 CoreNLP ,我可以从 Ant 构建 CoreNLP JAR,它在 eclipse 中也运行良好,但是我在将 JAR 转换为 DLL 时遇到问题。根据我在 google 中找到的一些构建日志,我正在这样做:

ikvmc.exe  -version:2.1 ..\lib\joda-time.jar -out:joda-time.dll 
ikvmc.exe  -r:joda-time.dll -version:0.4.7 ..\lib\jollyday-0.4.7.jar -out:jollyday.dll 
ikvmc.exe  -version:0.23 ..\lib\ejml-0.23.jar -out:ejml-0.23.dll 
ikvmc.exe  -version:1.2.10 ..\lib\xom-1.2.10.jar -out:xom.dll 
ikvmc.exe  -version:1.0 ..\lib\javax.json.jar -out:javax.json.dll 
ikvmc.exe  -r:joda-time.dll -r:jollyday.dll -r:ejml-0.23.dll -r:xom.dll -r:javax.json.dll -version:3.5.0 ..\javanlp-core.jar -out:javanlp-core.dll 

我从以下转换中得到的只是一些关于无法找到的引用类的警告:

warning IKVMC0100: Class "org.apache.xerces.parsers.SAXParser" not found
warning IKVMC0100: Class "junit.framework.TestCase" not found
warning IKVMC0100: Class "org.apache.xerces.impl.Version" not found
...
warning IKVMC0100: Class "junit.framework.TestCase" not found
warning IKVMC0100: Class "javax.servlet.http.HttpServlet" not found
warning IKVMC0100: Class "javax.servlet.Filter" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors$FileDescriptor$InternalDescriptorAssigner" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$Builder" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage" not found
warning IKVMC0100: Class "com.google.protobuf.MessageOrBuilder" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$ExtendableBuilder" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$ExtendableMessage" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$ExtendableMessageOrBuilder" not found
warning IKVMC0100: Class "com.google.protobuf.Internal$EnumLiteMap" not found
warning IKVMC0100: Class "com.google.protobuf.ProtocolMessageEnum" not found
warning IKVMC0100: Class "junit.framework.TestSuite" not found
warning IKVMC0100: Class "junit.framework.Assert" not found
warning IKVMC0100: Class "com.apple.eawt.ApplicationAdapter" not found
warning IKVMC0100: Class "org.junit.Assert" not found
warning IKVMC0100: Class "org.apache.lucene.analysis.core.KeywordAnalyzer" not found
warning IKVMC0100: Class "org.apache.lucene.index.IndexWriterConfig" not found
warning IKVMC0100: Class "org.apache.lucene.util.Version" not found
warning IKVMC0100: Class "org.apache.lucene.store.FSDirectory" not found
warning IKVMC0100: Class "org.apache.lucene.index.DirectoryReader" not found
warning IKVMC0100: Class "org.apache.lucene.search.IndexSearcher" not found
warning IKVMC0100: Class "org.apache.lucene.search.BooleanQuery" not found
warning IKVMC0100: Class "org.apache.lucene.search.BooleanClause" not found
warning IKVMC0100: Class "org.apache.lucene.search.TermQuery" not found
warning IKVMC0100: Class "org.apache.lucene.index.Term" not found
warning IKVMC0100: Class "org.apache.lucene.search.BooleanClause$Occur" not found
warning IKVMC0100: Class "org.apache.lucene.search.TopDocs" not found
warning IKVMC0100: Class "org.apache.lucene.search.ScoreDoc" not found
warning IKVMC0100: Class "org.apache.lucene.document.Document" not found
warning IKVMC0100: Class "org.apache.lucene.index.IndexWriter" not found
warning IKVMC0100: Class "org.apache.lucene.queryparser.classic.ParseException" not found
warning IKVMC0100: Class "org.apache.lucene.document.StringField" not found
warning IKVMC0100: Class "org.apache.lucene.document.Field$Store" not found
warning IKVMC0100: Class "org.apache.lucene.document.Field" not found
warning IKVMC0100: Class "org.apache.lucene.search.Query" not found
warning IKVMC0100: Class "org.apache.lucene.store.Directory" not found
warning IKVMC0100: Class "org.apache.lucene.index.CheckIndex" not found
warning IKVMC0100: Class "org.apache.lucene.index.CheckIndex$Status" not found
warning IKVMC0100: Class "org.apache.lucene.store.NIOFSDirectory" not found
warning IKVMC0100: Class "org.apache.lucene.util.BytesRef" not found
warning IKVMC0100: Class "org.apache.lucene.index.IndexReader" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors$FileDescriptor" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors$Descriptor" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$FieldAccessorTable" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors" not found
warning IKVMC0100: Class "junit.framework.AssertionFailedError" not found
warning IKVMC0100: Class "org.apache.lucene.document.FieldType" not found

PS:我也尝试过转换 protobuf.jar,但对下面描述的问题没有帮助。

问题是:当我将 Nuget 引用替换为新编译的引用(6 个 dll)时,它编译得很好(找到所有引用),但抛出了这个MissingMethodException: Additional information: Method not found: 'Void edu.stanford.nlp.pipeline .StanfordCoreNLP..ctor(java.util.Properties)'。

任何人都可以解释一下吗?

4

1 回答 1

1

我想我想通了。这是固定的:

  1. 删除 Nuget 包 IKVM 8.0.5449.1
  2. 安装了 Nuget 包 IKVM 8.0.5449.0(这是我用来转换 JAR 文件的版本)
  3. 清洁和重建。

如果我理解正确的话,我用来转换 JAR 文件的 ikvmc.exe 必须与引用的运行时 DLL 的版本相同。

于 2015-04-16T03:16:12.073 回答