Skip to content

Commit

Permalink
Merge pull request #1 from axmand/nlp
Browse files Browse the repository at this point in the history
fx
  • Loading branch information
axmand authored Oct 15, 2019
2 parents cb7625a + e3b3204 commit 073d374
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 67 deletions.
7 changes: 0 additions & 7 deletions Engine.NLP/.editorconfig

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Engine.NLP.Annotation
/// 2. split words
/// 3.
/// </summary>
public class ScenarioAnnotation
public class ScenarioAnnotate
{

#region Annotation ClassName
Expand Down Expand Up @@ -102,8 +102,9 @@ public class ScenarioAnnotation
/// <summary>
/// Annotation with SUTime
/// </summary>
public ScenarioAnnotation()
public ScenarioAnnotate()
{
//annotate properites
_props = new java.util.Properties();
//refrenece https://stanfordnlp.github.io/CoreNLP/annotators.html
_props.setProperty("annotators",
Expand All @@ -121,6 +122,24 @@ public ScenarioAnnotation()
"parse");
}


/// <summary>
/// 执行regroup,
/// </summary>
/// <param name="rawText"></param>
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)
{
//
}
}

/// <summary>
/// reference:
/// https://stanfordnlp.github.io/CoreNLP/api.html
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -56,7 +54,7 @@ public class LexerItem
/// <summary>
/// 重组合原始预料,根据时间 (datetime.v2)规则重组预料
/// </summary>
public class RegimentTool : IRegimentTool
public class RegimentTool
{
/// <summary>
///
Expand Down
7 changes: 2 additions & 5 deletions Engine.NLP/Engine.NLP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Process\ITextTool.cs" />
<Compile Include="Process\IRegimentTool.cs" />
<Compile Include="Process\Tools\StanfordAnnotateTool.cs" />
<Compile Include="Annotate\ScenarioAnnotate.cs" />
<Compile Include="Entity\Pipline.cs" />
<Compile Include="Entity\Scenario.cs" />
<Compile Include="Forms\NLPConfigForm.cs">
Expand All @@ -269,7 +267,7 @@
<Compile Include="Lexicon\Lexicon.cs" />
<Compile Include="Lexicon\OnehotEncode.cs" />
<Compile Include="Lexicon\Vocabulary.cs" />
<Compile Include="Process\Tools\RegimentTool.cs" />
<Compile Include="Annotate\SemanticAnnotate.cs" />
<Compile Include="Utils\NLPConfiguration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
Expand All @@ -281,7 +279,6 @@
<Compile Include="Utils\NLPHelper.cs" />
</ItemGroup>
<ItemGroup>
<None Include=".editorconfig" />
<None Include="app.config" />
<None Include="NLPConfiguration.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
12 changes: 0 additions & 12 deletions Engine.NLP/Process/IRegimentTool.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Engine.NLP/Process/ITextTool.cs

This file was deleted.

9 changes: 5 additions & 4 deletions Examples/UnitTestText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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小时卸油作业中加入全部的脱硫剂。");
}
Expand Down
29 changes: 10 additions & 19 deletions Host.UI/Main.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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);
}

/// <summary>
Expand Down

0 comments on commit 073d374

Please sign in to comment.