Skip to content

Commit 073d374

Browse files
authored
Merge pull request #1 from axmand/nlp
fx
2 parents cb7625a + e3b3204 commit 073d374

File tree

8 files changed

+42
-67
lines changed

8 files changed

+42
-67
lines changed

Engine.NLP/.editorconfig

Lines changed: 0 additions & 7 deletions
This file was deleted.

Engine.NLP/Process/Tools/StanfordAnnotateTool.cs renamed to Engine.NLP/Annotate/ScenarioAnnotate.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Engine.NLP.Annotation
1212
/// 2. split words
1313
/// 3.
1414
/// </summary>
15-
public class ScenarioAnnotation
15+
public class ScenarioAnnotate
1616
{
1717

1818
#region Annotation ClassName
@@ -102,8 +102,9 @@ public class ScenarioAnnotation
102102
/// <summary>
103103
/// Annotation with SUTime
104104
/// </summary>
105-
public ScenarioAnnotation()
105+
public ScenarioAnnotate()
106106
{
107+
//annotate properites
107108
_props = new java.util.Properties();
108109
//refrenece https://stanfordnlp.github.io/CoreNLP/annotators.html
109110
_props.setProperty("annotators",
@@ -121,6 +122,24 @@ public ScenarioAnnotation()
121122
"parse");
122123
}
123124

125+
126+
/// <summary>
127+
/// 执行regroup,
128+
/// </summary>
129+
/// <param name="rawText"></param>
130+
public void ProcessTimeAbstract(string rawText)
131+
{
132+
if (rawText == null || rawText.Length == 0) return;
133+
edu.stanford.nlp.pipeline.StanfordCoreNLPClient pipeline = new edu.stanford.nlp.pipeline.StanfordCoreNLPClient(_props, NLPConfiguration.CoreNLPAddress, Convert.ToInt32(NLPConfiguration.CoreNLPPort));
134+
edu.stanford.nlp.pipeline.Annotation document = new edu.stanford.nlp.pipeline.Annotation(rawText);
135+
pipeline.annotate(document);
136+
java.util.AbstractList sentences = document.get(sentencesAnnotationClass) as java.util.AbstractList;
137+
foreach (edu.stanford.nlp.util.CoreMap sentence in sentences)
138+
{
139+
//
140+
}
141+
}
142+
124143
/// <summary>
125144
/// reference:
126145
/// https://stanfordnlp.github.io/CoreNLP/api.html

Engine.NLP/Process/Tools/RegimentTool.cs renamed to Engine.NLP/Annotate/SemanticAnnotate.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Reflection;
5-
using Baidu.Aip.Nlp;
1+
using Baidu.Aip.Nlp;
62
using Engine.NLP.Utils;
73
using Newtonsoft.Json;
84
using Newtonsoft.Json.Linq;
5+
using System.Collections.Generic;
6+
using System.Linq;
97

108
namespace Engine.NLP.Process.Tools
119
{
@@ -56,7 +54,7 @@ public class LexerItem
5654
/// <summary>
5755
/// 重组合原始预料,根据时间 (datetime.v2)规则重组预料
5856
/// </summary>
59-
public class RegimentTool : IRegimentTool
57+
public class RegimentTool
6058
{
6159
/// <summary>
6260
///

Engine.NLP/Engine.NLP.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,7 @@
241241
</Reference>
242242
</ItemGroup>
243243
<ItemGroup>
244-
<Compile Include="Process\ITextTool.cs" />
245-
<Compile Include="Process\IRegimentTool.cs" />
246-
<Compile Include="Process\Tools\StanfordAnnotateTool.cs" />
244+
<Compile Include="Annotate\ScenarioAnnotate.cs" />
247245
<Compile Include="Entity\Pipline.cs" />
248246
<Compile Include="Entity\Scenario.cs" />
249247
<Compile Include="Forms\NLPConfigForm.cs">
@@ -269,7 +267,7 @@
269267
<Compile Include="Lexicon\Lexicon.cs" />
270268
<Compile Include="Lexicon\OnehotEncode.cs" />
271269
<Compile Include="Lexicon\Vocabulary.cs" />
272-
<Compile Include="Process\Tools\RegimentTool.cs" />
270+
<Compile Include="Annotate\SemanticAnnotate.cs" />
273271
<Compile Include="Utils\NLPConfiguration.cs" />
274272
<Compile Include="Properties\AssemblyInfo.cs" />
275273
<Compile Include="Properties\Resources.Designer.cs">
@@ -281,7 +279,6 @@
281279
<Compile Include="Utils\NLPHelper.cs" />
282280
</ItemGroup>
283281
<ItemGroup>
284-
<None Include=".editorconfig" />
285282
<None Include="app.config" />
286283
<None Include="NLPConfiguration.config">
287284
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

Engine.NLP/Process/IRegimentTool.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

Engine.NLP/Process/ITextTool.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

Examples/UnitTestText.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ public void RecognizeTextTokenize()
4848
[TestMethod]
4949
public void RegimentTool()
5050
{
51-
IRegimentTool tool = new RegimentTool();
52-
tool.RegimentTextByTimeline(rawTextzhShort);
5351
}
5452

5553
[TestMethod]
5654
public void RecognizeScenarioNumericWithUnit()
5755
{
58-
ScenarioAnnotation annotation2 = new ScenarioAnnotation();
59-
_ = annotation2.Process("2010年7月15日Tanker Pacific Management (Singapore) Pte Ltd(新加坡太平洋油轮公司)所属利比里亚籍(最初误报道为巴拿马籍[1])“COSMIC JEWEL”(“宇宙宝石”)号30万吨级VLCC油轮在大连新港向国际储运公司原油灌区卸送中石油控股的中油燃料油股份有限公司委托中国联合石油有限责任公司进口的委内瑞拉祖阿塔原油15.3万吨,卸载入中国联合石油有限责任公司租赁的国际储运公司原油灌区304、401、403号罐。");
56+
string rawText = "2010年7月15日Tanker Pacific Management (Singapore) Pte Ltd(新加坡太平洋油轮公司)所属利比里亚籍(最初误报道为巴拿马籍[1])“COSMIC JEWEL”(“宇宙宝石”)号30万吨级VLCC油轮在大连新港向国际储运公司原油灌区卸送中石油控股的中油燃料油股份有限公司委托中国联合石油有限责任公司进口的委内瑞拉祖阿塔原油15.3万吨,卸载入中国联合石油有限责任公司租赁的国际储运公司原油灌区304、401、403号罐。";
57+
ScenarioAnnotate annotate1 = new ScenarioAnnotate();
58+
annotate1.ProcessTimeAbstract(rawText);
59+
60+
//_ = annotate1.Process();
6061
//Scenario s1 = annotation2.Process("7月15日20时,油轮开始用2号输油管线向国际储运公司的原油罐区卸送,祥诚公司作业人员开始通过原油罐区内一套内径90厘米输油管道上的排空阀向输油管道内注入脱硫剂。");
6162
//annotation2.Process("加剂过程中由于由于输油管内压力高,加注软管多处出现超压鼓泡,连接处脱落造成脱硫化剂泄漏等情况,致使加注作业多次中断共计约4个小时,以致未能按计划在17小时卸油作业中加入全部的脱硫剂。");
6263
}

Host.UI/Main.cs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Data;
4-
using System.Diagnostics;
5-
using System.Drawing;
6-
using System.IO;
7-
using System.Windows.Forms;
8-
using Engine.Brain.Method;
1+
using Engine.Brain.Method;
92
using Engine.GIS.Entity;
103
using Engine.GIS.GLayer.GRasterLayer;
114
using Engine.GIS.GOperation.Arithmetic;
125
using Engine.NLP.Entity;
136
using Engine.NLP.Forms;
14-
using Engine.NLP.Process;
15-
using Engine.NLP.Process.Tools;
167
using Engine.NLP.Utils;
178
using Host.UI.Forms;
189
using Host.UI.Jobs;
1910
using Host.UI.SettingForm;
2011
using Host.UI.Util;
12+
using System;
13+
using System.Collections.Generic;
14+
using System.Data;
15+
using System.Diagnostics;
16+
using System.Drawing;
17+
using System.IO;
18+
using System.Windows.Forms;
2119

2220
namespace Host.UI
2321
{
@@ -28,17 +26,10 @@ public partial class Main : Form
2826

2927
public Main()
3028
{
29+
//
3130
InitializeComponent();
31+
//Loading cached settings
3232
SettingInitialization();
33-
//}{debug
34-
DebugCode();
35-
}
36-
37-
private void DebugCode()
38-
{
39-
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分,靠近脱硫剂注入部位的输油管道突然发生爆炸,引发火灾,造成部分输油管道、附近储罐阀门、输油泵房和电力系统损坏和大量原油泄漏。事故导致储罐阀门无法及时关闭,火灾不断扩大。原油顺地下管沟流淌,形成地面流淌火,火势蔓延。";
40-
IRegimentTool tool = new RegimentTool();
41-
tool.RegimentTextByTimeline(text);
4233
}
4334

4435
/// <summary>

0 commit comments

Comments
 (0)