• R/O
  • SSH
  • HTTPS

chaki: Commit


Commit MetaInfo

Revision615 (tree)
Time2018-07-22 21:20:43
Authortomorita

Log Message

不要ファイルを削除

Change Summary

  • delete: trunk/ChaKi.NET/src/Service/DependencyEdit/OperationDeleteMWEAnnotation.cs

Incremental Difference

--- trunk/ChaKi.NET/src/Service/DependencyEdit/OperationDeleteMWEAnnotation.cs (revision 614)
+++ trunk/ChaKi.NET/src/Service/DependencyEdit/OperationDeleteMWEAnnotation.cs (nonexistent)
@@ -1,132 +0,0 @@
1-using ChaKi.Entity.Corpora;
2-using ChaKi.Entity.Corpora.Annotations;
3-using System;
4-using System.Collections.Generic;
5-using System.Linq;
6-using System.Text;
7-
8-namespace ChaKi.Service.DependencyEdit
9-{
10- internal class OperationDeleteMWEAnnotation : Operation
11- {
12- private List<CharRange> m_CharRanges;
13- private List<int> m_Dependencies;
14- private List<Lexeme> m_SegLexList;
15- private List<Lexeme> m_LinkLexList;
16-
17- private const string MWETag = "MWE";
18-
19- public OperationDeleteMWEAnnotation(List<CharRange> charRanges, List<int> dependencies, List<Lexeme> segLexList, List<Lexeme> linkLexList)
20- {
21- m_CharRanges = charRanges;
22- m_Dependencies = dependencies;
23- m_SegLexList = segLexList;
24- m_LinkLexList = linkLexList;
25- }
26-
27- public override void Execute(DepEditContext ctx)
28- {
29- ExecuteCore(ctx, m_CharRanges, m_Dependencies, m_SegLexList, m_LinkLexList);
30- }
31-
32- public override void UnExecute(DepEditContext ctx)
33- {
34- OperationCreateMWEAnnotation.ExecuteCore(ctx, m_CharRanges, m_Dependencies, m_SegLexList, m_LinkLexList);
35- }
36-
37- public static void ExecuteCore(DepEditContext ctx, List<CharRange> charRanges, List<int> dependencies, List<Lexeme> segLexList, List<Lexeme> linkLexList)
38- {
39- var docid = ctx.Sen.ParentDoc.ID;
40- var segs = new HashSet<Segment>();
41-
42- // まずLinkを削除
43- for (var i = 0; i < charRanges.Count; i++)
44- {
45- var range = charRanges[i];
46- var dep =dependencies[i];
47- if (dep < 0 || dep > charRanges.Count - 1)
48- {
49- continue;
50- }
51- var start = range.Start.Value + ctx.Sen.StartChar;
52- var end = range.End.Value + ctx.Sen.StartChar;
53- var fromseg = FindSegmentBetween(ctx, docid, start, end, MWETag);
54- if (fromseg == null)
55- {
56- // 範囲が重なるOperationDeleteMWEAnnotationによって削除されている場合がある.
57- continue;
58- }
59- segs.Add(fromseg);
60- start = charRanges[dep].Start.Value + ctx.Sen.StartChar;
61- end = charRanges[dep].End.Value + ctx.Sen.StartChar;
62- var toseg = FindSegmentBetween(ctx, docid, start, end, MWETag);
63- if (toseg == null)
64- {
65- // 範囲が重なるOperationDeleteMWEAnnotationによって削除されている場合がある.
66- continue;
67- }
68- segs.Add(toseg);
69- var link = FindLink(ctx, fromseg, toseg, MWETag);
70- if (link == null)
71- {
72- throw new Exception($"Link not found. from=[{fromseg.ID}], to=[{toseg.ID}], tag=[{MWETag}]");
73- }
74- // First, Delete SegmentAttribute List from DB
75- foreach (LinkAttribute a in link.Attributes)
76- {
77- ctx.Delete(a);
78- ctx.Flush();
79- }
80- ctx.Delete(link);
81- ctx.Flush();
82- }
83-
84- // segsを全て子供として持つようなMWE Groupを探して削除する.
85- var group = FindGroupCovering(ctx, segs, MWETag);
86- if (group != null)
87- {
88- foreach (GroupAttribute a in group.Attributes)
89- {
90- ctx.Delete(a);
91- ctx.Flush();
92- }
93- ctx.Delete(group);
94- ctx.Flush();
95- }
96-
97- // 次にSegmentを削除
98- for (var i = 0; i < charRanges.Count; i++)
99- {
100- var range = charRanges[i];
101- var start = range.Start.Value + ctx.Sen.StartChar;
102- var end = range.End.Value + ctx.Sen.StartChar;
103- var seg = FindSegmentBetween(ctx, docid, start, end, MWETag);
104- if (seg == null)
105- {
106- // 別のOperationDeleteMWEAnnotationによって削除されている場合がある.
107- continue;
108- }
109- if (FindLinksFrom(ctx, seg).Count == 0 && FindLinksTo(ctx, seg).Count == 0)
110- {
111- foreach (SegmentAttribute a in seg.Attributes)
112- {
113- ctx.Delete(a);
114- ctx.Flush();
115- }
116- ctx.Delete(seg);
117- ctx.Flush();
118- }
119- }
120- }
121-
122- public override string ToIronRubyStatement(DepEditContext ctx)
123- {
124- return "#svc.DeleteMWEAnnotation() : not supported";
125- }
126-
127- public override string ToString()
128- {
129- return "{{DeleteMWEAnnotation}}";
130- }
131- }
132-}
Show on old repository browser