Comments (4)
Sorry, I cannot open link https://prntscr.com/n5rfid
Can you please post code here ?
It may depends on what model you are trying to deserialize. Please specify Nuget package that you use (with version) and what model do you use (ideally, URL where you download it from)
from stanford.nlp.net.
Code below, error at: pipeline = new StanfordCoreNLP(props);
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using java.util.prefs;
using edu.stanford.nlp.ling;
using edu.stanford.nlp.pipeline;
using edu.stanford.nlp.util;
using edu.stanford.nlp.trees;
using edu.stanford.nlp.sentiment;
using edu.stanford.nlp.neural.rnn;
using edu.stanford.nlp.neural;
using org.ejml.simple;
using System.IO;
namespace Ascanio_Bajada_Thesis
{
public class SentimentAnalyzer
{
StanfordCoreNLP pipeline;
public void Initialize()
{
var jarRoot = @"..\..\..\..\Thesis\packages\stanford-corenlp-full-2018-02-27\models";
java.util.Properties props = new java.util.Properties();
props.setProperty("pos.model", "pos-tagger\\english-left3words-distsim.tagger");
props.setProperty("ner.model", "ner\\classifiers\\english.all.3class.distsim.crf.ser.gz");
props.setProperty("ner.useSUTime", "false");
props.setProperty("ner.applyFineGrained", "0");
props.setProperty("parse.model", "lexparser\\englishPCFG.ser.gz");
props.setProperty("sentiment.model", "sentiment\\sentiment.ser.gz");
props.setProperty("dcoref.demonym", "dcoref\\demonyms.txt");
props.setProperty("dcoref.states", "dcoref\\state-abbreviations.txt");
props.setProperty("dcoref.animate", "dcoref\\animate.unigrams.txt");
props.setProperty("dcoref.inanimate", "dcoref\\inanimate.unigrams.txt");
props.setProperty("dcoref.big.gender.number", "dcoref\\gender.map.ser.gz");
props.setProperty("dcoref.countries", "dcoref\\countries");
props.setProperty("dcoref.states.provinces", "dcoref\\statesandprovinces");
props.setProperty("dcoref.singleton.model", "dcoref\\singleton.predictor.ser");
props.setProperty("dcoref.language", "en");
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, sentiment");
props.setProperty("dcoref.algorithm", "statistical");
// build pipeline
var curDir = Environment.CurrentDirectory;
Directory.SetCurrentDirectory(jarRoot);
pipeline = new StanfordCoreNLP(props);
Directory.SetCurrentDirectory(curDir);
}
public SentimentResult GetSentimentResult(string text)
{
Initialize();
SentimentClassification classification = new SentimentClassification();
SentimentResult sentimentResult = new SentimentResult();
if (text != null && text.Length > 0)
{
Annotation annotation = pipeline.process(text);
var sentences = annotation.get(new CoreAnnotations.SentencesAnnotation().getClass()) as ArrayList;
foreach (CoreMap sentence in sentences)
{
Tree tree = (Tree)sentence.get(typeof(SentimentCoreAnnotations.SentimentAnnotatedTree));
int sentiment = RNNCoreAnnotations.getPredictedClass(tree);
SimpleMatrix simpleMatrix = RNNCoreAnnotations.getPredictions(tree);
classification.setVeryNegative((int)Math.Round(simpleMatrix.get(0) * 100d));
classification.setNegative((int)Math.Round(simpleMatrix.get(1) * 100d));
classification.setNeutral((int)Math.Round(simpleMatrix.get(2) * 100d));
classification.setPositive((int)Math.Round(simpleMatrix.get(3) * 100d));
classification.setVeryPositive((int)Math.Round(simpleMatrix.get(4) * 100d));
string setimentType = (string)sentence.get(typeof(SentimentCoreAnnotations.SentimentClass));
sentimentResult.setSentimentType(setimentType);
sentimentResult.setSentimentClass(classification);
sentimentResult.setSentimentScore(RNNCoreAnnotations.getPredictedClass(tree));
}
}
return sentimentResult;
}
}
}
Nuget package: Stanford.NLP.CoreNLP 3.9.1
Model: stanford-english-corenlp-2018-02-27-models (I've also tried with the 2018-10-05, v3.9.2) downloaded from https://stanfordnlp.github.io/CoreNLP/history.html
Re-hosted images to imgur
Furthermore I've also tried extracting the stanford-corenlp-3.9.1.jar file, moving the SimpleTensor.class to the correct directory (under edu.stanford.nlp.neural.rnn), archiving into .jar and replacing the old one but the Object Browser still found it under the neural directory.
from stanford.nlp.net.
Used Nuget package: Stanford.NLP.CoreNLP 3.9.1
Hi ,
I have the same issue . It throws error at :
var pipeline = new StanfordCoreNLP(props)
I saw that workaround exist in java : https://github.com/stanfordnlp/CoreNLP/issues/715
But how do we tackle "dependencies" in .Net as Maven / POM.xml tool doesn't exist ?
Any idea, insight ?
Thanks for your feedback
from stanford.nlp.net.
Close as an old issue
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
- How do I get constituents from a tree annotation? HOT 10
- 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.