private static void initNativeLayer() { //XMLVM_BEGIN_WRAPPER[java.lang.System: void initNativeLayer()] _fsystemProperties = new java.util.Properties(); _fsystemProperties.@this(); string[] nativeKeys = new string[] { "file.separator", "path.separator", "line.separator", //"user.name", //"user.dir" }; string[] nativeVals = new string[] { global::System.IO.Path.DirectorySeparatorChar.ToString(), global::System.IO.Path.PathSeparator.ToString(), global::System.Environment.NewLine, //global::System.Environment.UserName, //global::System.Environment.CurrentDirectory }; for (int i = 0; i < nativeKeys.Length; i++) { java.lang.String key = org.xmlvm._nUtil.toJavaString(nativeKeys[i]); java.lang.String val = org.xmlvm._nUtil.toJavaString(nativeVals[i]); _fsystemProperties.put(key, val); } org.xmlvm._nUtil.initOnce(); //XMLVM_END_WRAPPER[java.lang.System: void initNativeLayer()] }
/// <summary> /// Annotation with SUTime /// </summary> public ScenarioAnnotator(IEmbeddingNetwork net) { //词向量模型 _net = net; //annotate properites _props = new java.util.Properties(); //refrenece https://stanfordnlp.github.io/CoreNLP/annotators.html _props.setProperty("annotators", //tokenize https://stanfordnlp.github.io/CoreNLP/tokenize.html "tokenize, " + //https://stanfordnlp.github.io/CoreNLP/cleanxml.html //"cleanxml, " + //ssplit https://stanfordnlp.github.io/CoreNLP/ssplit.html "ssplit, " + //part of speech https://stanfordnlp.github.io/CoreNLP/pos.html "pos, " + //lemma https://stanfordnlp.github.io/CoreNLP/lemma.html "lemma, " + //named entity recongnition https://stanfordnlp.github.io/CoreNLP/ner.html "ner, " + //depparse https://stanfordnlp.github.io/CoreNLP/parse.html "depparse, " + //Open Information Extraction https://stanfordnlp.github.io/CoreNLP/openie.html "openie"); }
// Sample from https://stanfordnlp.github.io/CoreNLP/corenlp-server.html static void Main() { // creates a StanfordCoreNLP object with POS tagging, lemmatization, NER, parsing, and coreference resolution var props = new java.util.Properties(); props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref"); StanfordCoreNLPClient pipeline = new StanfordCoreNLPClient(props, "http://localhost", 9000, 2); // read some text in the text variable var text = "Kosgi Santosh sent an email to Stanford University."; // create an empty Annotation just with the given text Annotation document = new Annotation(text); // run all Annotators on this text pipeline.annotate(document); var sentences = document.get(sentencesAnnotationClass) as java.util.AbstractList; foreach (CoreMap sentence in sentences) { var tokens = sentence.get(tokensAnnotationClass) as java.util.AbstractList; Console.WriteLine("----"); foreach (CoreLabel token in tokens) { var word = token.get(textAnnotationClass); var pos = token.get(partOfSpeechAnnotationClass); var ner = token.get(namedEntityTagAnnotationClass); Console.WriteLine("{0}\t[pos={1};\tner={2};", word, pos, ner); } } }
static ChinesePOSExtractor() { var props = new java.util.Properties(); props.setProperty("annotators", "segment, ssplit, pos"); props.setProperty("customAnnotatorClass.segment", "edu.stanford.nlp.pipeline.ChineseSegmenterAnnotator"); props.setProperty("segment.model", "edu/stanford/nlp/models/segmenter/chinese/ctb.gz"); props.setProperty("segment.sighanCorporaDict", "edu/stanford/nlp/models/segmenter/chinese"); props.setProperty("segment.serDictionary", "edu/stanford/nlp/models/segmenter/chinese/dict-chris6.ser.gz"); props.setProperty("segment.sighanPostProcessing", "true"); //sentence split props.setProperty("ssplit.boundaryTokenRegex", "[.]|[!?]+|[。]|[!?]+"); //pos props.setProperty("pos.model", "edu/stanford/nlp/models/pos-tagger/chinese-distsim/chinese-distsim.tagger"); //ner props.setProperty("ner.model", "edu/stanford/nlp/models/ner/chinese.misc.distsim.crf.ser.gz"); props.setProperty("ner.applyNumericClassifiers", "false"); props.setProperty("ner.useSUTime", "false"); //# parse props.setProperty("parse.model", "edu/stanford/nlp/models/lexparser/chineseFactored.ser.gz"); pipeline = new StanfordCoreNLP(props); }
public virtual ArangoDB.Builder loadProperties(java.io.InputStream @in ) { if (@in != null) { java.util.Properties properties = new java.util.Properties(); try { properties.load(@in); host = getProperty(properties, PROPERTY_KEY_HOST, host, ArangoDBConstants .DEFAULT_HOST); port = System.Convert.ToInt32(getProperty(properties, PROPERTY_KEY_PORT, port, ArangoDBConstants .DEFAULT_PORT)); timeout = System.Convert.ToInt32(getProperty(properties, PROPERTY_KEY_TIMEOUT, timeout , ArangoDBConstants.DEFAULT_TIMEOUT)); user = getProperty(properties, PROPERTY_KEY_USER, user, null); password = getProperty(properties, PROPERTY_KEY_PASSWORD, password, null); useSsl = bool.parseBoolean(getProperty(properties, PROPERTY_KEY_USE_SSL, useSsl, ArangoDBConstants.DEFAULT_USE_SSL)); chunksize = System.Convert.ToInt32(getProperty(properties, PROPERTY_KEY_V_STREAM_CHUNK_CONTENT_SIZE , chunksize, ArangoDBConstants.CHUNK_DEFAULT_CONTENT_SIZE )); } catch (System.IO.IOException e) { throw new ArangoDBException(e); } } return(this); }
private static void initNativeLayer() { //XMLVM_BEGIN_WRAPPER[java.lang.System: void initNativeLayer()] _fsystemProperties = new java.util.Properties(); _fsystemProperties.@this(); string[] nativeKeys = new string[] { "file.separator", "path.separator", "line.separator", //"user.name", //"user.dir" }; string[] nativeVals = new string[] { global::System.IO.Path.DirectorySeparatorChar.ToString(), global::System.IO.Path.PathSeparator.ToString(), global::System.Environment.NewLine, //global::System.Environment.UserName, //global::System.Environment.CurrentDirectory }; for (int i=0; i<nativeKeys.Length; i++) { java.lang.String key = org.xmlvm._nUtil.toJavaString(nativeKeys[i]); java.lang.String val = org.xmlvm._nUtil.toJavaString(nativeVals[i]); _fsystemProperties.put(key, val); } org.xmlvm._nUtil.initOnce(); //XMLVM_END_WRAPPER[java.lang.System: void initNativeLayer()] }
static Client() { // Create a StanfordCoreNLPClient object with POS tagging, lemmatization, NER, parsing, and coreference resolution java.util.Properties props = new java.util.Properties(); props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref"); props.setProperty("coref.algorithm", "neural"); ServerPipeline = new StanfordCoreNLPClient(props, Properties.Settings.Default.CoreNLP_ServerHost, Properties.Settings.Default.CoreNLP_ServerPort, ClientThreads); }
private java.util.Properties ConvertToTable(NameValueCollection col) { java.util.Properties table = new java.util.Properties(); foreach (String key in col.Keys) { table.put(key, col [key]); } return(table); }
public void StanfordCore(string jarRoot = @"..\..\models") { var props = new java.util.Properties(); props.setProperty("annotators", "tokenize, ssplit, pos, lemma"); // props.setProperty("ner.useSUTime", "0"); var curDir = Environment.CurrentDirectory; Directory.SetCurrentDirectory(jarRoot); pipeline = new StanfordCoreNLP(props); Directory.SetCurrentDirectory(curDir); }
public StanfordCoreNLP() { var props = new java.util.Properties(); props.setProperty("annotators", "tokenize, ssplit, parse, sentiment"); var dictBackup = Environment.CurrentDirectory; System.IO.Directory.SetCurrentDirectory(_modelsFolder); _nlp = new edu.stanford.nlp.pipeline.StanfordCoreNLP(props); System.IO.Directory.SetCurrentDirectory(dictBackup); }
/// <summary inherit="yes"/> public override JProperties GetOutputProperties() { JProperties properties = (defaultOutputProperties == null ? new JProperties() : new JProperties(defaultOutputProperties)); java.util.Enumeration propsEnum = props.keys(); while (propsEnum.hasMoreElements()) { object obj = propsEnum.nextElement(); String value = (String)(props.get((String)obj)); properties.setProperty((String)obj, value); } return(properties); }
public void Pos() { var sent = new Sentence("Lucy is in the sky with diamonds."); var props = new java.util.Properties(); props.setProperty("ner.useSUTime", "0"); var nerTags = sent.nerTags(props); Assert.AreEqual("PERSON", nerTags.get(0)); var firstPOSTag = sent.posTag(0); Assert.AreEqual("NNP", firstPOSTag); }
static EnglishPOSExtractor() { var props = new java.util.Properties(); props.setProperty("annotators", "tokenize, ssplit, pos"); props.setProperty("ner.useSUTime", "0"); var curDir = Environment.CurrentDirectory; Directory.SetCurrentDirectory($"{curDir}/english"); pipeline = new StanfordCoreNLP(props); Directory.SetCurrentDirectory(curDir); }
/// <summary>Converts the JSONObject into a property file object.</summary> /// <param name="jo">JSONObject</param> /// <returns>java.util.Properties</returns> /// <exception cref="JSONException"/> /// <exception cref="org.json.JSONException"/> public static java.util.Properties ToProperties(org.json.JSONObject jo) { java.util.Properties properties = new java.util.Properties(); if (jo != null) { System.Collections.Generic.IEnumerator<string> keys = jo.Keys(); while (keys.HasNext()) { string name = keys.Next(); properties[name] = jo.GetString(name); } } return properties; }
/// <summary> /// Attempts to establish a connection to the given database URL. /// The <code>DriverManager</code> attempts to select an appropriate driver from /// the set of registered JDBC drivers. /// <para> /// <B>Note:</B> If the {@code user} or {@code password} property are /// also specified as part of the {@code url}, it is /// implementation-defined as to which value will take precedence. /// For maximum portability, an application should only specify a /// property once. /// /// </para> /// </summary> /// <param name="url"> a database url of the form /// <code>jdbc:<em>subprotocol</em>:<em>subname</em></code> </param> /// <param name="user"> the database user on whose behalf the connection is being /// made </param> /// <param name="password"> the user's password </param> /// <returns> a connection to the URL </returns> /// <exception cref="SQLException"> if a database access error occurs or the url is /// {@code null} </exception> /// <exception cref="SQLTimeoutException"> when the driver has determined that the /// timeout value specified by the {@code setLoginTimeout} method /// has been exceeded and has at least tried to cancel the /// current database connection attempt </exception> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @CallerSensitive public static Connection getConnection(String url, String user, String password) throws SQLException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public static Connection GetConnection(String url, String user, String password) { java.util.Properties info = new java.util.Properties(); if (user != null) { info["user"] = user; } if (password != null) { info["password"] = password; } return(GetConnection(url, info, Reflection.CallerClass)); }
/// <summary> /// Initialises CoreNLP pipeline to tokenise the input into sentences /// </summary> private void InitPipeline() { var jarRoot = @"C:\Users\Luca\Documents\University\General\UG3\SCC300\SCC300cs\SCC300cs\stanford-corenlp-3.7.0-models"; // Annotation pipeline configuration var props = new java.util.Properties(); props.setProperty("annotators", "tokenize, ssplit"); props.setProperty("ner.useSUTime", "0"); var CurDir = Environment.CurrentDirectory; Directory.SetCurrentDirectory(jarRoot); //change working dir to locate models Directory.SetCurrentDirectory(CurDir); }
internal JReceiver GetReceiver(Serializer serializer) { net.sf.saxon.expr.instruct.Executable executable = exp.getExecutable(); JConfiguration config = executable.getConfiguration(); JPipelineConfiguration pipe = config.makePipelineConfiguration(); pipe.setHostLanguage(executable.getHostLanguage()); JProperties baseProps = new JProperties(executable.getDefaultOutputProperties()); JCharacterMapIndex charMapIndex = executable.getCharacterMapIndex(); JCharacterMapIndex characterMap = serializer.GetCharacterMap(); if (charMapIndex.isEmpty()) { charMapIndex = characterMap; } else if (characterMap != null && !characterMap.isEmpty() && charMapIndex != characterMap) { // Merge the character maps java.util.Iterator mapIter = characterMap.iterator(); while (mapIter.hasNext()) { net.sf.saxon.serialize.CharacterMap map = (net.sf.saxon.serialize.CharacterMap)mapIter.next(); charMapIndex.putCharacterMap(map.getName(), map); } } JProperties properties = serializer.GetOutputProperties(); object [] propSet = properties.entrySet().toArray(); for (int i = 0; i < properties.size(); i++) { java.util.Map.Entry entry = (java.util.Map.Entry)propSet[i]; net.sf.saxon.om.StructuredQName name = net.sf.saxon.om.StructuredQName.fromClarkName((String)entry.getKey()); net.sf.saxon.expr.instruct.ResultDocument.setSerializationProperty( baseProps, name.getURI(), name.getLocalPart(), (String)entry.getValue(), null, true, config); } serializer.SetDefaultOutputProperties(baseProps); serializer.SetCharacterMap(charMapIndex); JReceiver target = serializer.GetReceiver(pipe); return(target); }
/// <summary> /// /// </summary> /// <returns></returns> public bool Initialize() { if (this.Initialized) { return(true); } var props = new java.util.Properties(); // we tokenize and sentece split props.setProperty("annotators", "tokenize, ssplit"); // don't separate words only when whitespace is encountered // e.g. ***THIS IS... = *** + THIS + IS... props.setProperty("tokenize.options", "whitespace=false"); // totally ignores parentheses and brackets - we don't care for them // NOTE (twolf): this doesn't really work - so we take care of it in // |QualifiedWords| props.setProperty("tokenize.options", "normalizeOtherBrackets=false"); props.setProperty("tokenize.options", "normalizeParentheses=false"); // version 3.7.0 of CoreNLP supports splitting hypentated words // yet has a whitelist of hyphenated words - so we let it do the work // for us and refrain from really long words like: // pg345.txt: two-pages-to-the-week-with-Sunday-squeezed-in-a-corner props.setProperty("tokenize.options", "splitHyphenated=true"); // two or more newlines should be treated as a sentece break // this is especially important for tables of contents props.setProperty( StanfordCoreNLP.NEWLINE_IS_SENTENCE_BREAK_PROPERTY, "two"); // ignore props.setProperty("ssplit.tokenPatternsToDiscard", "\\p{Punct}"); try { _pipeLine = new StanfordCoreNLP(props); } catch (Exception) { _pipeLine = null; } return(this.Initialized); }
internal DataSource GetDataSource(string dataSourceName, string namingProviderUrl, string namingFactoryInitial) { Hashtable cache = Cache; DataSource ds = cache[dataSourceName] as DataSource; if (ds != null) { return(ds); } Context ctx = null; java.util.Properties properties = new java.util.Properties(); if ((namingProviderUrl != null) && (namingProviderUrl.Length > 0)) { properties.put("java.naming.provider.url", namingProviderUrl); } if ((namingFactoryInitial != null) && (namingFactoryInitial.Length > 0)) { properties.put("java.naming.factory.initial", namingFactoryInitial); } ctx = new InitialContext(properties); try { ds = (DataSource)ctx.lookup(dataSourceName); } catch (javax.naming.NameNotFoundException e) { // possible that is a Tomcat bug, // so try to lookup for jndi datasource with "java:comp/env/" appended ds = (DataSource)ctx.lookup("java:comp/env/" + dataSourceName); } cache[dataSourceName] = ds; return(ds); }
private java.util.Properties InitProperties() { var properties = new java.util.Properties(); properties.setProperty("parse.model", localModelPath + "edu/stanford/nlp/models/srparser/englishSR.ser.gz"); properties.setProperty("sentiment.model", localModelPath + "edu/stanford/nlp/models/sentiment/sentiment.ser.gz"); properties.setProperty("pos.model", localModelPath + "edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger"); properties.setProperty("ner.model", localModelPath + "edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz"); properties.setProperty("dcoref.demonym", localModelPath + "edu/stanford/nlp/models/dcoref/demonyms.txt"); properties.setProperty("dcoref.states", localModelPath + "edu/stanford/nlp/models/dcoref/state-abbreviations.txt"); properties.setProperty("dcoref.animate", localModelPath + "edu/stanford/nlp/models/dcoref/animate.unigrams.txt"); properties.setProperty("dcoref.inanimate", localModelPath + "edu/stanford/nlp/models/dcoref/inanimate.unigrams.txt"); properties.setProperty("dcoref.big.gender.number", localModelPath + "edu/stanford/nlp/models/dcoref/gender.data.gz"); properties.setProperty("dcoref.countries", localModelPath + "edu/stanford/nlp/models/dcoref/countries"); properties.setProperty("dcoref.states.provinces", localModelPath + "edu/stanford/nlp/models/dcoref/statesandprovinces"); properties.setProperty("dcoref.singleton.model", localModelPath + "edu/stanford/nlp/models/dcoref/singleton.predictor.ser"); properties.setProperty("annotators", "tokenize, ssplit, pos, parse, lemma, ner, sentiment"); properties.setProperty("tokenize.language", "en"); properties.setProperty("ner.useSUTime", "0"); properties.setProperty("sutime.binders", "0"); properties.setProperty("sutime.rules", localModelPath + "edu/stanford/nlp/models/sutime/defs.sutime.txt, " + localModelPath + "edu/stanford/nlp/models/sutime/english.sutime.txt"); return(properties); }
private string getProperty <T>(java.util.Properties properties, string key, T currentValue , T defaultValue) { return(properties.getProperty(key, currentValue != null ? currentValue.ToString() : defaultValue != null ? defaultValue.ToString() : null)); }
public Properties() { underlyingModel = new java.util.Properties(); }
public java.sql.DriverPropertyInfo[] getPropertyInfo(string url, java.util.Properties info) { throw new NotImplementedException(); }
public Properties(java.util.Properties arg0) : base(global::MonoJavaBridge.JNIEnv.ThreadEnv) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; global::MonoJavaBridge.JniLocalHandle handle = @__env.NewObject(java.util.Properties.staticClass, global::java.util.Properties._Properties15619, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); Init(@__env, handle); }
public abstract string getTablePrefix(java.util.Properties paramProperties, int paramInt);
public java.sql.Connection connect(string url, java.util.Properties info) { throw new NotImplementedException(); }
/// <summary> /// Attempts to establish a connection to the given database URL. /// The <code>DriverManager</code> attempts to select an appropriate driver from /// the set of registered JDBC drivers. /// </summary> /// <param name="url"> a database url of the form /// <code> jdbc:<em>subprotocol</em>:<em>subname</em></code> </param> /// <returns> a connection to the URL </returns> /// <exception cref="SQLException"> if a database access error occurs or the url is /// {@code null} </exception> /// <exception cref="SQLTimeoutException"> when the driver has determined that the /// timeout value specified by the {@code setLoginTimeout} method /// has been exceeded and has at least tried to cancel the /// current database connection attempt </exception> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @CallerSensitive public static Connection getConnection(String url) throws SQLException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public static Connection GetConnection(String url) { java.util.Properties info = new java.util.Properties(); return(GetConnection(url, info, Reflection.CallerClass)); }
internal DataSource GetDataSource(string dataSourceName,string namingProviderUrl,string namingFactoryInitial) { Hashtable cache = Cache; DataSource ds = cache[dataSourceName] as DataSource; if (ds != null) { return ds; } Context ctx = null; java.util.Properties properties = new java.util.Properties(); if ((namingProviderUrl != null) && (namingProviderUrl.Length > 0)) { properties.put("java.naming.provider.url",namingProviderUrl); } if ((namingFactoryInitial != null) && (namingFactoryInitial.Length > 0)) { properties.put("java.naming.factory.initial",namingFactoryInitial); } ctx = new InitialContext(properties); try { ds = (DataSource)ctx.lookup(dataSourceName); } catch(javax.naming.NameNotFoundException e) { // possible that is a Tomcat bug, // so try to lookup for jndi datasource with "java:comp/env/" appended ds = (DataSource)ctx.lookup("java:comp/env/" + dataSourceName); } cache[dataSourceName] = ds; return ds; }
/// <summary> /// Output an XML representation of the compiled code of the stylesheet, for purposes of /// diagnostics and instrumentation /// </summary> /// <param name="destination">The destination for the diagnostic output</param> public void Explain(XmlDestination destination) { JConfiguration config = pss.getConfiguration(); JResult result = destination.GetResult(config.makePipelineConfiguration()); JProperties properties = new JProperties(); properties.setProperty("indent", "yes"); properties.setProperty("{http://saxon.sf.net/}indent-spaces", "2"); JReceiver receiver = config.getSerializerFactory().getReceiver( result, config.makePipelineConfiguration(), properties); JExpressionPresenter presenter = new JExpressionPresenter(config, receiver); pss.explain(presenter); }
/// <summary> /// Set default output properties, for use when no explicit properties are set using SetProperty(). /// The values supplied are typically those specified in the stylesheet or query. In the case of XSLT, /// they are the properties associated with unamed <c>xsl:output</c> declarations. /// </summary> /// <param name="props"></param> public void SetDefaultOutputProperties(JProperties props) { this.defaultOutputProperties = props; }
// Worker method called by the public getConnection() methods. //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private static Connection getConnection(String url, java.util.Properties info, Class caller) throws SQLException private static Connection GetConnection(String url, java.util.Properties info, Class caller) { /* * When callerCl is null, we should check the application's * (which is invoking this class indirectly) * classloader, so that the JDBC driver class outside rt.jar * can be loaded from here. */ ClassLoader callerCL = caller != null ? caller.ClassLoader : null; lock (typeof(DriverManager)) { // synchronize loading of the correct classloader. if (callerCL == null) { callerCL = Thread.CurrentThread.ContextClassLoader; } } if (url == null) { throw new SQLException("The url cannot be null", "08001"); } Println("DriverManager.getConnection(\"" + url + "\")"); // Walk through the loaded registeredDrivers attempting to make a connection. // Remember the first exception that gets raised so we can reraise it. SQLException reason = null; foreach (DriverInfo aDriver in RegisteredDrivers) { // If the caller does not have permission to load the driver then // skip it. if (IsDriverAllowed(aDriver.Driver, callerCL)) { try { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: Println(" trying " + aDriver.Driver.GetType().FullName); Connection con = aDriver.Driver.Connect(url, info); if (con != null) { // Success! //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: Println("getConnection returning " + aDriver.Driver.GetType().FullName); return(con); } } catch (SQLException ex) { if (reason == null) { reason = ex; } } } else { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: Println(" skipping: " + aDriver.GetType().FullName); } } // if we got here nobody could connect. if (reason != null) { Println("getConnection failed: " + reason); throw reason; } Println("getConnection: no suitable driver found for " + url); throw new SQLException("No suitable driver found for " + url, "08001"); }
private java.util.Properties ConvertToTable (NameValueCollection col) { java.util.Properties table = new java.util.Properties (); foreach (String key in col.Keys) table.put (key, col [key]); return table; }
//使用nlp將文章分析後回傳key private List<string> nlp(string sentence) { List<string> return_key = new List<string>(); string Relay_file = ".\\xml"; string Relay_name = "Relay" + ".xml"; string Relay_path = Relay_file + "\\" + Relay_name; // Path to the folder with models extracted from `stanford-corenlp-3.4-models.jar` var jarRoot = @"stanford-corenlp-3.5.2-models\\"; // Annotation pipeline configuration var props = new java.util.Properties(); props.setProperty("ner.useSUTime", "false"); props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref"); props.setProperty("sutime.binders", "0"); // We should change current directory, so StanfordCoreNLP could find all the model files automatically var curDir = Environment.CurrentDirectory; System.IO.Directory.SetCurrentDirectory(jarRoot); var pipeline = new StanfordCoreNLP(props); System.IO.Directory.SetCurrentDirectory(curDir); // Annotation var annotation = new Annotation(sentence); pipeline.annotate(annotation); //輸出nlp分析結果至Relay.xml FileOutputStream os = new FileOutputStream(new File(Relay_file, Relay_name)); pipeline.xmlPrint(annotation, os); os.close(); //呼叫ner將單字組合為有意義的key組裝 foreach (string k in ner(Relay_path)) { return_key.Add(k); } return return_key; }