From e3b32049dfee4edf654fb0040086e0591d277afe Mon Sep 17 00:00:00 2001 From: axmand <815966508@qq.com> Date: Tue, 15 Oct 2019 21:06:50 +0800 Subject: [PATCH] fx --- Engine.NLP/.editorconfig | 7 ----- .../ScenarioAnnotate.cs} | 23 +++++++++++++-- .../SemanticAnnotate.cs} | 10 +++---- Engine.NLP/Engine.NLP.csproj | 7 ++--- Engine.NLP/Process/IRegimentTool.cs | 12 -------- Engine.NLP/Process/ITextTool.cs | 12 -------- Examples/UnitTestText.cs | 9 +++--- Host.UI/Main.cs | 29 +++++++------------ 8 files changed, 42 insertions(+), 67 deletions(-) delete mode 100644 Engine.NLP/.editorconfig rename Engine.NLP/{Process/Tools/StanfordAnnotateTool.cs => Annotate/ScenarioAnnotate.cs} (96%) rename Engine.NLP/{Process/Tools/RegimentTool.cs => Annotate/SemanticAnnotate.cs} (97%) delete mode 100644 Engine.NLP/Process/IRegimentTool.cs delete mode 100644 Engine.NLP/Process/ITextTool.cs diff --git a/Engine.NLP/.editorconfig b/Engine.NLP/.editorconfig deleted file mode 100644 index 84a2e04..0000000 --- a/Engine.NLP/.editorconfig +++ /dev/null @@ -1,7 +0,0 @@ -[*.cs] - -# IDE0052: 删除未读的私有成员 -dotnet_diagnostic.IDE0052.severity = silent - -# CA1031: 不捕获常规异常类型 -dotnet_diagnostic.CA1031.severity = none diff --git a/Engine.NLP/Process/Tools/StanfordAnnotateTool.cs b/Engine.NLP/Annotate/ScenarioAnnotate.cs similarity index 96% rename from Engine.NLP/Process/Tools/StanfordAnnotateTool.cs rename to Engine.NLP/Annotate/ScenarioAnnotate.cs index 5512003..94e565d 100644 --- a/Engine.NLP/Process/Tools/StanfordAnnotateTool.cs +++ b/Engine.NLP/Annotate/ScenarioAnnotate.cs @@ -12,7 +12,7 @@ namespace Engine.NLP.Annotation /// 2. split words /// 3. /// - public class ScenarioAnnotation + public class ScenarioAnnotate { #region Annotation ClassName @@ -102,8 +102,9 @@ public class ScenarioAnnotation /// /// Annotation with SUTime /// - public ScenarioAnnotation() + public ScenarioAnnotate() { + //annotate properites _props = new java.util.Properties(); //refrenece https://stanfordnlp.github.io/CoreNLP/annotators.html _props.setProperty("annotators", @@ -121,6 +122,24 @@ public ScenarioAnnotation() "parse"); } + + /// + /// 执行regroup, + /// + /// + public void ProcessTimeAbstract(string rawText) + { + if (rawText == null || rawText.Length == 0) return; + edu.stanford.nlp.pipeline.StanfordCoreNLPClient pipeline = new edu.stanford.nlp.pipeline.StanfordCoreNLPClient(_props, NLPConfiguration.CoreNLPAddress, Convert.ToInt32(NLPConfiguration.CoreNLPPort)); + edu.stanford.nlp.pipeline.Annotation document = new edu.stanford.nlp.pipeline.Annotation(rawText); + pipeline.annotate(document); + java.util.AbstractList sentences = document.get(sentencesAnnotationClass) as java.util.AbstractList; + foreach (edu.stanford.nlp.util.CoreMap sentence in sentences) + { + // + } + } + /// /// reference: /// https://stanfordnlp.github.io/CoreNLP/api.html diff --git a/Engine.NLP/Process/Tools/RegimentTool.cs b/Engine.NLP/Annotate/SemanticAnnotate.cs similarity index 97% rename from Engine.NLP/Process/Tools/RegimentTool.cs rename to Engine.NLP/Annotate/SemanticAnnotate.cs index 0d1299c..f3f66ec 100644 --- a/Engine.NLP/Process/Tools/RegimentTool.cs +++ b/Engine.NLP/Annotate/SemanticAnnotate.cs @@ -1,11 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Baidu.Aip.Nlp; +using Baidu.Aip.Nlp; using Engine.NLP.Utils; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Collections.Generic; +using System.Linq; namespace Engine.NLP.Process.Tools { @@ -56,7 +54,7 @@ public class LexerItem /// /// 重组合原始预料,根据时间 (datetime.v2)规则重组预料 /// - public class RegimentTool : IRegimentTool + public class RegimentTool { /// /// diff --git a/Engine.NLP/Engine.NLP.csproj b/Engine.NLP/Engine.NLP.csproj index cc16013..5fe0159 100644 --- a/Engine.NLP/Engine.NLP.csproj +++ b/Engine.NLP/Engine.NLP.csproj @@ -241,9 +241,7 @@ - - - + @@ -269,7 +267,7 @@ - + @@ -281,7 +279,6 @@ - PreserveNewest diff --git a/Engine.NLP/Process/IRegimentTool.cs b/Engine.NLP/Process/IRegimentTool.cs deleted file mode 100644 index ce790cd..0000000 --- a/Engine.NLP/Process/IRegimentTool.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Newtonsoft.Json.Linq; - -namespace Engine.NLP.Process -{ - /// - /// define regiment text (regroup) - /// - public interface IRegimentTool:ITextTool - { - void RegimentTextByTimeline(string rawText); - } -} diff --git a/Engine.NLP/Process/ITextTool.cs b/Engine.NLP/Process/ITextTool.cs deleted file mode 100644 index 7bda321..0000000 --- a/Engine.NLP/Process/ITextTool.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Engine.NLP.Process -{ - public interface ITextTool - { - } -} diff --git a/Examples/UnitTestText.cs b/Examples/UnitTestText.cs index 5d55316..b22c39e 100644 --- a/Examples/UnitTestText.cs +++ b/Examples/UnitTestText.cs @@ -48,15 +48,16 @@ public void RecognizeTextTokenize() [TestMethod] public void RegimentTool() { - IRegimentTool tool = new RegimentTool(); - tool.RegimentTextByTimeline(rawTextzhShort); } [TestMethod] public void RecognizeScenarioNumericWithUnit() { - ScenarioAnnotation annotation2 = new ScenarioAnnotation(); - _ = annotation2.Process("2010年7月15日Tanker Pacific Management (Singapore) Pte Ltd(新加坡太平洋油轮公司)所属利比里亚籍(最初误报道为巴拿马籍[1])“COSMIC JEWEL”(“宇宙宝石”)号30万吨级VLCC油轮在大连新港向国际储运公司原油灌区卸送中石油控股的中油燃料油股份有限公司委托中国联合石油有限责任公司进口的委内瑞拉祖阿塔原油15.3万吨,卸载入中国联合石油有限责任公司租赁的国际储运公司原油灌区304、401、403号罐。"); + string rawText = "2010年7月15日Tanker Pacific Management (Singapore) Pte Ltd(新加坡太平洋油轮公司)所属利比里亚籍(最初误报道为巴拿马籍[1])“COSMIC JEWEL”(“宇宙宝石”)号30万吨级VLCC油轮在大连新港向国际储运公司原油灌区卸送中石油控股的中油燃料油股份有限公司委托中国联合石油有限责任公司进口的委内瑞拉祖阿塔原油15.3万吨,卸载入中国联合石油有限责任公司租赁的国际储运公司原油灌区304、401、403号罐。"; + ScenarioAnnotate annotate1 = new ScenarioAnnotate(); + annotate1.ProcessTimeAbstract(rawText); + + //_ = annotate1.Process(); //Scenario s1 = annotation2.Process("7月15日20时,油轮开始用2号输油管线向国际储运公司的原油罐区卸送,祥诚公司作业人员开始通过原油罐区内一套内径90厘米输油管道上的排空阀向输油管道内注入脱硫剂。"); //annotation2.Process("加剂过程中由于由于输油管内压力高,加注软管多处出现超压鼓泡,连接处脱落造成脱硫化剂泄漏等情况,致使加注作业多次中断共计约4个小时,以致未能按计划在17小时卸油作业中加入全部的脱硫剂。"); } diff --git a/Host.UI/Main.cs b/Host.UI/Main.cs index 7a1e3aa..cf9bac0 100644 --- a/Host.UI/Main.cs +++ b/Host.UI/Main.cs @@ -1,23 +1,21 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Diagnostics; -using System.Drawing; -using System.IO; -using System.Windows.Forms; -using Engine.Brain.Method; +using Engine.Brain.Method; using Engine.GIS.Entity; using Engine.GIS.GLayer.GRasterLayer; using Engine.GIS.GOperation.Arithmetic; using Engine.NLP.Entity; using Engine.NLP.Forms; -using Engine.NLP.Process; -using Engine.NLP.Process.Tools; using Engine.NLP.Utils; using Host.UI.Forms; using Host.UI.Jobs; using Host.UI.SettingForm; using Host.UI.Util; +using System; +using System.Collections.Generic; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Windows.Forms; namespace Host.UI { @@ -28,17 +26,10 @@ public partial class Main : Form public Main() { + // InitializeComponent(); + //Loading cached settings SettingInitialization(); - //}{debug - DebugCode(); - } - - private void DebugCode() - { - string text = "2010年7月15日Tanker Pacific Management (Singapore) Pte Ltd(新加坡太平洋油轮公司)所属利比里亚籍(最初误报道为巴拿马籍)“COSMIC JEWEL”(“宇宙宝石”)号30万吨级VLCC油轮在大连新港向国际储运公司原油灌区卸送中石油控股的中油燃料油股份有限公司委托中国联合石油有限责任公司进口的委内瑞拉祖阿塔原油15.3万吨,卸载入中国联合石油有限责任公司租赁的国际储运公司原油灌区304、401、403号罐。由于该原油H2S含量较高,中油燃料油股份有限公司委托天津辉盛达石化技术有限公司负责加入原油脱硫剂作业。辉盛达公司委托上海祥诚商品检验技术服务有限公司大连分公司在国际储运公司原油罐区输油管道上进行现场作业。所添加的“HD-硫化氢脱除剂”原油脱硫剂由辉盛达公司生产。卸油作业于7月15日15时30分开始,在两条输油管道同时进行。7月15日20时,油轮开始用2号输油管线向国际储运公司的原油罐区卸送,祥诚公司作业人员开始通过原油罐区内一套内径90厘米输油管道上的排空阀向输油管道内注入脱硫剂。加剂过程中由于由于输油管内压力高,加注软管多处出现超压鼓泡,连接处脱落造成脱硫化剂泄漏等情况,致使加注作业多次中断共计约4个小时,以致未能按计划在17小时卸油作业中加入全部的脱硫剂。7月16日13时,油轮进行原油洗舱集油作业,停止向岸上卸油并关闭船岸间控制阀。此时,中石油大连石化公司石油储运公司生产调度通知上海祥诚大连分公司经理“船上停止卸油了”,但注入脱硫剂的作业没有停止,又继续加入了22.6t脱硫剂。18时,在注入了全部的88立方米脱硫剂后,现场作业人员用消防泵房(位于103号油罐东侧)内的消防水对脱硫剂管路和泵进行冲洗,冲洗液0.1t直接经加剂口入该输油管线。18时02分,靠近脱硫剂注入部位的输油管道突然发生爆炸,引发火灾,造成部分输油管道、附近储罐阀门、输油泵房和电力系统损坏和大量原油泄漏。事故导致储罐阀门无法及时关闭,火灾不断扩大。原油顺地下管沟流淌,形成地面流淌火,火势蔓延。"; - IRegimentTool tool = new RegimentTool(); - tool.RegimentTextByTimeline(text); } ///