Comments (10)
most probably you cannot use typeof
you need java.lang.Class
public static java.lang.Class GetAnnotationClass<T>()
=> ikvm.@internal.ClassLiteral<T>.Value; // or = new T().getClass()
var sentences = annotation.get(GetAnnotationClass<CoreAnnotations.SentencesAnnotation>());
foreach(CoreMap sentence in sentences as ArrayList){
var tree = sentence.get(GetAnnotationClass<TreeCoreAnnotations.TreeAnnotation>()) as Tree;
tree.constituents(); // most likely Tree is edu.stanford.nlp.trees.Tree
}
from stanford.nlp.net.
Thank you for the quick response!
from stanford.nlp.net.
I get the error " cannot convert from 'method group' to 'Class' " on these two lines:
GetAnnotationClass<CoreAnnotations.SentencesAnnotation>
GetAnnotationClass<TreeCoreAnnotations.TreeAnnotation>
from stanford.nlp.net.
Sorry, I forgot brackets, GetAnnotationClass
is a method that that we should call, so GetAnnotationClass<T>()
var sentences = annotation.get(GetAnnotationClass<CoreAnnotations.SentencesAnnotation>());
from stanford.nlp.net.
Thank you so much it worked! I am just still new with C# so I don't understand why I'm getting "Object reference not set to an instance of an object." when using "java.util.ArrayList":
var sentences = annotation.get(GetAnnotationClass<CoreAnnotations.SentencesAnnotation>());
foreach (CoreMap sentence in sentences as java.util.ArrayList)
{
Tree tree = sentence.get(GetAnnotationClass<TreeCoreAnnotations.TreeAnnotation>()) as Tree;
var treeConstituents = tree.constituents(new LabeledScoredConstituentFactory());
foreach (Constituent constituent in treeConstituents as java.util.ArrayList) // I get the error here
{
if (constituent.label().toString().Equals("NP"))
{
Console.WriteLine(constituent.toString());
Console.WriteLine(tree.getLeaves().subList(constituent.start(), constituent.end() + 1));
}
}
}
As compared with the example I showed previously by the CoreNLP website, I cannot use "Set<Constituent>" so I used "var" instead but still get the error.
from stanford.nlp.net.
Nevermind! I think I might have solved it by using "java.util.AbstractSet" instead of "java.util.ArrayList". Thanks again!
from stanford.nlp.net.
interior with Java/IKVM types is not very intuitive.
If you not sure what exact type is returned from annotation, you can take a look in debugger it Console.WriteLine(obj.GetType())
from stanford.nlp.net.
Oh I see now, thank you. Excuse me for bothering, and perhaps this is out of your area of expertise but, I have been using CoreNLP within Unity and since adding the lines:
public static java.lang.Class GetAnnotationClass<T>()
=> ikvm.@internal.ClassLiteral<T>.Value;
I have been getting an error about not being able to load the file "IKVM.OpenJDK.Core, Version 8.1". I was wondering if you could think of any DLL that I could be missing which could add the "GetAnnotationClass()" functionality within Unity? The full error within the console is this:
Error: Could not load signature of NLP:GetAnnotationClass due to: Could not load file or assembly 'IKVM.OpenJDK.Core, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58' or one of its dependencies. assembly:IKVM.OpenJDK.Core, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58 type: member:(null) signature:
I greatly appreciate any feedback.
from stanford.nlp.net.
- I would check that
IKVM.OpenJDK.Core
is actually present near you exe or - If you are on Windows you use Fuslogvw.exe to log all assembly resolution requests and result to find out what file was no resolved.
- you can try to replace
GetAnnotationClass<T>()
call bynew T().getClass()
and compare results
from stanford.nlp.net.
new T().getClass() worked perfectly. Thanks again.
from stanford.nlp.net.
Related Issues (20)
- c# issues HOT 6
- snk file not found HOT 3
- Calssifier Demo and how i can do it ? HOT 1
- Setup config HOT 3
- Assembly 'Assets/Plugins/stanford-corenlp-3.9.2.dll' will not be loaded due to errors HOT 1
- POS-Tagging in other languages HOT 4
- Add samples of loading configuration from config.properties file
- The new .NET Core merge works except very minor issues HOT 1
- Feedback Additional Standford.NLP Tools: PyTorch Dependency Parser HOT 1
- Help needed: Getting Dependency Visualization Brat to work in Blazor
- CoreNLP Server HOT 6
- Tests for other Langauges HOT 4
- Signed version for stanford.nlp.PosTagger HOT 2
- Upgrade 4.5.5? HOT 4
- System.TypeLoadException: Could not load type 'ikvm.internal.ClassLiteral` HOT 2
- Relationship between NLP, NER, Segmenter HOT 1
- SimpleTensor ClassNotFoundException - Wrong directory? HOT 4
- Is is possible to loop through the dependencies of the Semantic Graph Annotation? HOT 1
- Transform Words into Sentences and Paragraphs? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stanford.nlp.net.