• R/O
  • SSH
  • HTTPS

chaki: Commit


Commit MetaInfo

Revisión617 (tree)
Tiempo2018-07-24 00:04:35
Autortomorita

Log Message

DepEditで単語クリックにより表示されるLexemeSelectionGrid(単語アサイン変更ダイアログ)にMWE Annotationを統合.

Cambiar Resumen

Diferencia incremental

--- trunk/ChaKi.NET/src/ChaKi.NET/Panels/WordEditPanel.cs (revision 616)
+++ trunk/ChaKi.NET/src/ChaKi.NET/Panels/WordEditPanel.cs (revision 617)
@@ -52,8 +52,9 @@
5252 m_LexSelector.BeginSelection(orglex.Surface, orglex);
5353 if (m_LexSelector.ShowDialog() == DialogResult.OK)
5454 {
55- Lexeme lex = m_LexSelector.Selection;
56- if (lex != null)
55+ var lex = m_LexSelector.Selection?.Lexeme;
56+ var mwe_match = m_LexSelector.Selection?.Match;
57+ if (lex != null && mwe_match == null)
5758 {
5859 var props = lex.ToPropertyArray();
5960 var customprop = lex.CustomProperty;
--- trunk/ChaKi.NET/src/ChaKiCommon/SequenceMatcher/MatchingResult.cs (revision 616)
+++ trunk/ChaKi.NET/src/ChaKiCommon/SequenceMatcher/MatchingResult.cs (revision 617)
@@ -12,6 +12,7 @@
1212 public List<int> DepList { get; set; }
1313 public MWE MWE { get; set; }
1414 public List<CharRange> CharRangeList { get; set; }
15+ public Uri Url { get; set; } // 外部辞書でマッチした場合はそのサーバーのURL(Word IDは含まない)
1516
1617 public MatchingResult()
1718 {
@@ -27,5 +28,33 @@
2728 select new CharRange(words[r.Start].StartChar - startChar, words[r.End - 1].EndChar - startChar))
2829 .ToList();
2930 }
31+
32+ public static string MWEToString(MWE mwe, IList<Word> words, MatchingResult match)
33+ {
34+ if (words == null) return string.Empty;
35+
36+ var tokens = new List<string>();
37+ for (var i = 0; i < mwe.Items.Count; i++)
38+ {
39+ switch (mwe.Items[i].NodeType)
40+ {
41+ case MWENodeType.Word:
42+ tokens.Add(mwe.Items[i].Label);
43+ break;
44+ case MWENodeType.Placeholder:
45+ var w = new List<string>();
46+ for (var j = match.RangeList[i].Start; j < match.RangeList[i].End; j++)
47+ {
48+ w.Add(words[j].Lex.Surface);
49+ }
50+ tokens.Add($"({string.Join(" ", w)})");
51+ break;
52+ default:
53+ tokens.Add("*");
54+ break;
55+ }
56+ }
57+ return string.Join(" ", tokens);
58+ }
3059 }
3160 }
--- trunk/ChaKi.NET/src/DepEditSLA/SentenceStructure.cs (revision 616)
+++ trunk/ChaKi.NET/src/DepEditSLA/SentenceStructure.cs (revision 617)
@@ -580,7 +580,8 @@
580580
581581 // z-orderレベルの計算
582582 new TopologicalSort<SegmentBox>(m_SegmentBoxes,
583- (x, y) => {
583+ (x, y) =>
584+ {
584585 if (x.Range.IsSameStartEnd(y.Range))
585586 {
586587 return ((x.Model as Segment).ID > (y.Model as Segment).ID);
@@ -2276,11 +2277,13 @@
22762277
22772278 try
22782279 {
2279- m_LexSelector.BeginSelection(wb.Model.Lex.Surface, wb.Model.Lex);
2280+ var words = this.Model.GetWords(this.TargetProjectId);
2281+ m_LexSelector.BeginSelection(wb.Model.Lex.Surface, wb.Model.Lex, words);
22802282 if (m_LexSelector.ShowDialog() == DialogResult.OK)
22812283 {
2282- Lexeme lex = m_LexSelector.Selection;
2283- if (lex != null)
2284+ var lex = m_LexSelector.Selection?.Lexeme;
2285+ var mwe_match = m_LexSelector.Selection?.Match;
2286+ if (lex != null && mwe_match == null)
22842287 {
22852288 try
22862289 {
@@ -2294,6 +2297,28 @@
22942297 m_Service.ResetTransaction();
22952298 }
22962299 }
2300+ else if (mwe_match != null)
2301+ {
2302+ try
2303+ {
2304+ mwe_match.CalcCharRangeList(words, this.Model.StartChar);
2305+ var op = m_Service.CreateMWEAnnotation(mwe_match, true);
2306+ if (op == null)
2307+ {
2308+ MessageBox.Show("Duplicate segment is prohibited!");
2309+ }
2310+ else
2311+ {
2312+ UpdateContents();
2313+ }
2314+ }
2315+ catch (Exception ex)
2316+ {
2317+ ErrorReportDialog dlg = new ErrorReportDialog("Cannot Execute operation", ex);
2318+ dlg.ShowDialog();
2319+ m_Service.ResetTransaction();
2320+ }
2321+ }
22972322 }
22982323 }
22992324 catch (Exception ex)
--- trunk/ChaKi.NET/src/DepEditSLA/Widgets/LexemeSelectionGrid.cs (revision 616)
+++ trunk/ChaKi.NET/src/DepEditSLA/Widgets/LexemeSelectionGrid.cs (revision 617)
@@ -10,6 +10,8 @@
1010 using ChaKi.Service.DependencyEdit;
1111 using PopupControl;
1212 using ChaKi.Service.Lexicons;
13+using System.Linq;
14+using ChaKi.Common.SequenceMatcher;
1315
1416 namespace DependencyEditSLA.Widgets
1517 {
@@ -16,7 +18,7 @@
1618 public partial class LexemeSelectionGrid : Form
1719 {
1820 private Corpus m_Corpus;
19- private IList<Lexeme> m_LexList;
21+ private IList<LexemeCandidate> m_Candidates;
2022 private ILexiconService m_Service;
2123 private List<LP> m_PropertyColumns;
2224 private DataGridViewCell m_CurrentCell;
@@ -37,7 +39,7 @@
3739 /// <summary>
3840 /// 選択された結果のLexeme
3941 /// </summary>
40- public Lexeme Selection { get; set; }
42+ public LexemeCandidate Selection { get; set; }
4143
4244 public event EventHandler LexemeSelected;
4345
@@ -59,9 +61,14 @@
5961
6062 // カラム作成
6163 DataGridViewColumn col;
62- col = new DataGridViewTextBoxColumn()
63- { Name = "ID", ReadOnly = true,
64- DefaultCellStyle = new DataGridViewCellStyle() { Alignment = DataGridViewContentAlignment.MiddleRight } };
64+ col = new DataGridViewLinkColumn()
65+ {
66+ Name = "ID",
67+ ReadOnly = true,
68+ DefaultCellStyle = new DataGridViewCellStyle() { Alignment = DataGridViewContentAlignment.MiddleRight },
69+ LinkColor = Color.Blue,
70+ VisitedLinkColor = Color.DarkBlue
71+ };
6572 dg.Columns.Add(col);
6673 col = new DataGridViewTextBoxColumn() { Name = "Dictioanry", ReadOnly = true };
6774 dg.Columns.Add(col);
@@ -100,8 +107,11 @@
100107 c++;
101108 }
102109 col = new DataGridViewTextBoxColumn()
103- { Name = "Frequency", ReadOnly = true,
104- DefaultCellStyle = new DataGridViewCellStyle() { Alignment = DataGridViewContentAlignment.MiddleRight } };
110+ {
111+ Name = "Frequency",
112+ ReadOnly = true,
113+ DefaultCellStyle = new DataGridViewCellStyle() { Alignment = DataGridViewContentAlignment.MiddleRight }
114+ };
105115 dg.Columns.Add(col);
106116
107117 // 初期値設定を反映
@@ -116,7 +126,7 @@
116126 this.Location = new Point(
117127 Math.Min(maxRect.Width, Math.Max(Settings.InitialLocation.Location.X, 0)),
118128 Math.Min(maxRect.Height, Math.Max(Settings.InitialLocation.Location.Y, 0)));
119-
129+
120130 this.Size = new Size(
121131 Math.Min(maxRect.Width, Math.Max(Settings.InitialLocation.Size.Width, 100)),
122132 Math.Min(maxRect.Height, Math.Max(Settings.InitialLocation.Size.Height, 100)));
@@ -130,13 +140,13 @@
130140 m_CurrentCell = null;
131141 }
132142
133- public void BeginSelection(string surface, Lexeme currentLexeme)
143+ public void BeginSelection(string surface, Lexeme currentLexeme, IList<Word> words = null)
134144 {
135145 DataGridView dg = this.dataGridView1;
136146 dg.Rows.Clear();
137147 try
138148 {
139- m_LexList = m_Service.FindAllLexemeCandidates(surface);
149+ m_Candidates = m_Service.FindAllLexemeCandidates(surface);
140150 }
141151 catch (Exception ex)
142152 {
@@ -145,14 +155,16 @@
145155 return;
146156 }
147157
148- this.Selection = currentLexeme;
158+ this.Selection = (from c in this.m_Candidates where c.Lexeme == currentLexeme select c).FirstOrDefault();
149159
150- foreach (Lexeme lex in m_LexList)
160+ foreach (var cand in m_Candidates)
151161 {
152162 int r = dg.Rows.Add();
153163
154164 DataGridViewRow row = dg.Rows[r];
155165
166+ var lex = cand.Lexeme;
167+ var mwe_match = cand.Match;
156168 string idstr;
157169 if (lex.ID < 0)
158170 {
@@ -181,11 +193,20 @@
181193 row.Cells[col++].Value = lex.GetStringProperty(m_PropertyColumns[i]);
182194 }
183195 row.Cells[col++].Value = lex.Frequency;
196+ if (mwe_match != null)
197+ {
198+ row.Cells[2].Value = MatchingResult.MWEToString(mwe_match.MWE, words, mwe_match);
199+ }
200+
184201 if (!lex.CanEdit)
185202 {
186203 row.ReadOnly = true;
187- if (lex.Dictionary != null)
204+ if (mwe_match != null)
188205 {
206+ row.DefaultCellStyle.BackColor = Color.LightYellow;
207+ }
208+ else if (lex.Dictionary != null)
209+ {
189210 row.DefaultCellStyle.BackColor = Color.LightBlue;
190211 }
191212 else
@@ -198,7 +219,8 @@
198219 row.DefaultCellStyle.BackColor = Color.White;
199220 }
200221 }
201- this.dataGridView1.MouseClick +=new MouseEventHandler(dataGridView1_MouseClick);
222+ this.dataGridView1.MouseClick += new MouseEventHandler(dataGridView1_MouseClick);
223+ this.dataGridView1.CellContentClick += dataGridView1_CellContentClick;
202224
203225 // 参照用辞書を含め、全ての使用可能なPOS, CType, CFormタグのリストを得て、PropTreeにセットする.
204226 Dictionary<string, IList<PartOfSpeech>> pos; // stringはDictionary名(カレントコーパスは"Default")
@@ -223,7 +245,7 @@
223245 base.WndProc(ref m);
224246 }
225247
226- protected override bool ProcessCmdKey( ref Message msg, Keys keyData )
248+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
227249 {
228250 //if (keyData == Keys.Enter)
229251 //{
@@ -243,21 +265,21 @@
243265 if (OkCancel)
244266 {
245267 int index = (this.dataGridView1.SelectedCells.Count > 0) ? this.dataGridView1.SelectedCells[0].RowIndex : -1;
246- if (index >= 0 && index < m_LexList.Count)
268+ if (index >= 0 && index < m_Candidates.Count)
247269 {
248270 try
249271 {
250- string[] props = ToLexemePropertyArray(index, m_LexList[index]);
251- string customprop = m_LexList[index].CustomProperty;
252- Lexeme lex = m_LexList[index];
272+ var lex = m_Candidates[index].Lexeme;
273+ var props = ToLexemePropertyArray(index, lex);
274+ var customprop = lex.CustomProperty;
253275 if (lex.Dictionary != null)
254276 {
255277 lex = null;
256278 }
257279 m_Service.CreateOrUpdateLexeme(ref lex, props, customprop);
258- m_LexList[index] = lex;
280+ m_Candidates[index].Lexeme = lex;
259281
260- this.Selection = m_LexList[index];
282+ this.Selection = m_Candidates[index];
261283 if (LexemeSelected != null)
262284 {
263285 LexemeSelected(this, null);
@@ -300,7 +322,7 @@
300322
301323 private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
302324 {
303- if (e.RowIndex >= 0 && e.RowIndex < m_LexList.Count)
325+ if (e.RowIndex >= 0 && e.RowIndex < m_Candidates.Count)
304326 {
305327 foreach (DataGridViewCell cell in this.dataGridView1.SelectedCells)
306328 {
@@ -322,13 +344,13 @@
322344 {
323345 cell.Selected = false;
324346 }
325- if (m_LexList == null)
347+ if (m_Candidates == null)
326348 {
327349 return;
328350 }
329- for (int i = 0; i < m_LexList.Count; i++)
351+ for (int i = 0; i < m_Candidates.Count; i++)
330352 {
331- if (m_LexList[i] == this.Selection)
353+ if (m_Candidates[i] == this.Selection)
332354 {
333355 this.dataGridView1.Rows[i].Cells[0].Selected = true;
334356 this.dataGridView1.CurrentCell = this.dataGridView1[0, i];
@@ -337,6 +359,30 @@
337359 }
338360 }
339361
362+
363+ private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
364+ {
365+ var dgv = (DataGridView)sender;
366+ if (dgv.Columns[e.ColumnIndex].Name == "ID")
367+ {
368+ int index = (this.dataGridView1.SelectedCells.Count > 0) ? this.dataGridView1.SelectedCells[0].RowIndex : -1;
369+ if (index >= 0 && index < m_Candidates.Count)
370+ {
371+ var cand = m_Candidates[index];
372+ if (cand != null && cand.Url != null)
373+ {
374+ // Cradleの単語画面をブラウザで表示
375+ var url = $"{cand.Url}word?id={cand.Lexeme.SID}";
376+ System.Diagnostics.Process.Start(url);
377+
378+ // set "visited"
379+ var cell = (DataGridViewLinkCell)dgv[e.ColumnIndex, e.RowIndex];
380+ cell.LinkVisited = true;
381+ }
382+ }
383+ }
384+ }
385+
340386 // マウス右クリック→Tree Menu表示
341387 void dataGridView1_MouseClick(object sender, MouseEventArgs e)
342388 {
@@ -389,7 +435,7 @@
389435 // 初期値設定をセーブ
390436 int cols = this.dataGridView1.Columns.Count;
391437 Settings.ColumnWidths = new int[cols];
392- for (int i= 0; i < cols; i++)
438+ for (int i = 0; i < cols; i++)
393439 {
394440 Settings.ColumnWidths[i] = this.dataGridView1.Columns[i].Width;
395441 }
--- trunk/ChaKi.NET/src/DepEditSLA/Widgets/MWEDownloadGrid.cs (revision 616)
+++ trunk/ChaKi.NET/src/DepEditSLA/Widgets/MWEDownloadGrid.cs (revision 617)
@@ -127,36 +127,11 @@
127127 BeginInvoke(new Action(() => {
128128 this.Table.Rows.Add(
129129 false,
130- MWEToString(mwe, this.Words, match),
130+ MatchingResult.MWEToString(mwe, this.Words, match),
131131 string.Join(",", from r in match.RangeList where (r.Start >= 0 && r.End >= 0) select r.ToString()));
132132 this.Results.Add(new Tuple<MWE, MatchingResult>(mwe, match));
133133 }));
134134 }
135135
136- private static string MWEToString(MWE mwe, IList<Word> words, MatchingResult match)
137- {
138- var tokens = new List<string>();
139- for (var i = 0; i < mwe.Items.Count; i++)
140- {
141- switch (mwe.Items[i].NodeType)
142- {
143- case MWENodeType.Word:
144- tokens.Add(mwe.Items[i].Label);
145- break;
146- case MWENodeType.Placeholder:
147- var w = new List<string>();
148- for (var j = match.RangeList[i].Start; j < match.RangeList[i].End; j++)
149- {
150- w.Add(words[j].Lex.Surface);
151- }
152- tokens.Add($"({string.Join(" ", w)})");
153- break;
154- default:
155- tokens.Add("*");
156- break;
157- }
158- }
159- return string.Join(" ", tokens);
160- }
161136 }
162137 }
--- trunk/ChaKi.NET/src/Entity/Corpora/MWE.cs (revision 616)
+++ trunk/ChaKi.NET/src/Entity/Corpora/MWE.cs (revision 617)
@@ -14,6 +14,7 @@
1414
1515 public Lexeme Lex { get; set; }
1616 public List<MWENode> Items { get; set; }
17+ public string Dictionary { get; set; }
1718
1819 public override string ToString()
1920 {
--- trunk/ChaKi.NET/src/ImportWordRelation/Properties/AssemblyInfo.cs (revision 616)
+++ trunk/ChaKi.NET/src/ImportWordRelation/Properties/AssemblyInfo.cs (revision 617)
@@ -12,5 +12,5 @@
1212 [assembly: AssemblyCulture("")]
1313 [assembly: ComVisible(false)]
1414 [assembly: Guid("6a95808a-d1e3-47de-bb62-7ed7a281ac0b")]
15-[assembly: AssemblyVersion("3.11.613.0")]
16-[assembly: AssemblyFileVersion("3.11.613.0")]
15+[assembly: AssemblyVersion("3.11.616.0")]
16+[assembly: AssemblyFileVersion("3.11.616.0")]
--- trunk/ChaKi.NET/src/Service/DependencyEdit/DepEditService.cs (revision 616)
+++ trunk/ChaKi.NET/src/Service/DependencyEdit/DepEditService.cs (revision 617)
@@ -954,7 +954,7 @@
954954 /// (先に見つけられたものが優先される。コーパス内にあるものは最優先。)
955955 /// </summary>
956956 /// <param name="str"></param>
957- public IList<Lexeme> FindAllLexemeCandidates(string str)
957+ public IList<LexemeCandidate> FindAllLexemeCandidates(string str)
958958 {
959959 return FindAllLexemeCandidates(m_Context.Session, m_Dictionaries, str);
960960 }
@@ -965,20 +965,20 @@
965965 /// (先に見つけられたものが優先される。コーパス内にあるものは最優先。)
966966 /// </summary>
967967 /// <param name="str"></param>
968- public static IList<Lexeme> FindAllLexemeCandidates(ISession session, List<DictionaryAccessor> refdics, string str)
968+ public IList<LexemeCandidate> FindAllLexemeCandidates(ISession session, List<DictionaryAccessor> refdics, string str)
969969 {
970- SortedList<string, Lexeme> list = new SortedList<string, Lexeme>();
970+ var list = new SortedList<string, LexemeCandidate>();
971971
972972 // コーパス本体のLexicon
973- IQuery query = session.CreateQuery(string.Format("from Lexeme l where l.Surface='{0}'", str));
974- IList<Lexeme> result = query.List<Lexeme>();
973+ var query = session.CreateQuery(string.Format("from Lexeme l where l.Surface='{0}'", str));
974+ var result = query.List<Lexeme>();
975975 bool needsNewLexeme = true; // 新語登録に使えるLexeme (Freq=0) が見つからなければtrue.
976- foreach (Lexeme lex in result)
976+ foreach (var lex in result)
977977 {
978978 string key = lex.ToString3(); // POSを優先してSortさせる
979979 if (!list.ContainsKey(key))
980980 {
981- list.Add(key, lex);
981+ list.Add(key, new LexemeCandidate(lex));
982982 }
983983 if (lex.PartOfSpeech == PartOfSpeech.Default)
984984 {
@@ -999,7 +999,9 @@
999999 string key = lex.ToString3();
10001000 if (!list.ContainsKey(key))
10011001 {
1002- list.Add(key, lex);
1002+ var cand = new LexemeCandidate(lex);
1003+ cand.Url = refdic.Url;
1004+ list.Add(key, cand);
10031005 }
10041006 if (lex.Dictionary != null)
10051007 {
@@ -1012,13 +1014,45 @@
10121014 lex.CanEdit = false;
10131015 }
10141016 }
1015- IList<Lexeme> ret = new List<Lexeme>(list.Values);
1017+ // MWEも検索
1018+ var words = m_Context.Sen.GetWords(m_Context.Proj.ID);
1019+ var matches = this.FindMWECandidates2(str, words);
1020+ foreach (var match in matches)
1021+ {
1022+ var mwe = match.MWE;
1023+ var lex = mwe.Lex;
1024+ if (lex == null) continue;
1025+ var matchranges = string.Join(",", from r in match.RangeList where (r.Start >= 0 && r.End >= 0) select r.ToString());
1026+ var key = $"{lex.ToString3()}@{matchranges}";
1027+ if (!list.ContainsKey(key))
1028+ {
1029+ var cand = new LexemeCandidate(match);
1030+ cand.Url = match.Url;
1031+ list.Add(key, cand);
1032+ }
1033+ if (lex.Dictionary != null && lex.Dictionary.Contains("["))
1034+ {
1035+ // 同じLexに対して2回以上通る可能性があるので、簡易的にチェックする.
1036+ // do nothing
1037+ }
1038+ else if (lex.Dictionary != null)
1039+ {
1040+ lex.Dictionary = $"{mwe.Dictionary}[{lex.Dictionary}]";
1041+ }
1042+ else
1043+ {
1044+ lex.Dictionary = mwe.Dictionary;
1045+ }
1046+ lex.CanEdit = false;
1047+ }
1048+
1049+ var ret = new List<LexemeCandidate>(list.Values);
10161050 // 新語登録のための種となるLexemeをリストに追加する.
10171051 if (needsNewLexeme)
10181052 {
1019- Lexeme lex = Lexeme.CreateDefaultUnknownLexeme(str);
1053+ var lex = Lexeme.CreateDefaultUnknownLexeme(str);
10201054 lex.CanEdit = true;
1021- ret.Add(lex);
1055+ ret.Add(new LexemeCandidate(lex));
10221056 }
10231057
10241058 return ret;
@@ -1081,7 +1115,7 @@
10811115 }
10821116
10831117 /// <summary>
1084- /// strで開始されるMWEを複合語辞書(Cradle)から検索する.
1118+ /// word listのそれぞれの語で開始されるMWEを複合語辞書(Cradle)から検索する.
10851119 /// </summary>
10861120 /// <param name="str"></param>
10871121 public List<MWE> FindMWECandidates(IList<Word> words, Action<string> showMessageCallback = null, Action<MWE, MatchingResult> foundMWECallback = null)
@@ -1127,6 +1161,39 @@
11271161 }
11281162
11291163 /// <summary>
1164+ /// surfaceを含み、word list(本文)の一部になりうるMWEをすべて辞書から検索し、
1165+ /// word listとのマッチング結果を返す.
1166+ /// </summary>
1167+ /// <param name="surface"></param>
1168+ /// <returns></returns>
1169+ public List<MatchingResult> FindMWECandidates2(string surface, IList<Word> words)
1170+ {
1171+ var result = new List<MatchingResult>();
1172+
1173+ int wpos = 0;
1174+ foreach (var dict in m_Dictionaries)
1175+ {
1176+ if (!dict.CanSearchCompoundWord)
1177+ {
1178+ continue;
1179+ }
1180+ var list = dict.FindMWEBySurface2(surface);
1181+ foreach (var mwe in list)
1182+ {
1183+ mwe.Dictionary = dict.Name;
1184+ // 見つかったMWEがWord Listと合致するかチェックする.
1185+ var matches = MWEMatcher.Match(words, wpos, mwe);
1186+ foreach (var match in matches)
1187+ {
1188+ result.Add(match);
1189+ match.Url = dict.Url;
1190+ }
1191+ }
1192+ }
1193+ return result;
1194+ }
1195+
1196+ /// <summary>
11301197 /// 現在のSentenceの持つ "MWE"Group annotationおよびその範囲に付与された係り受けをすべて取得し、
11311198 /// MWEオブジェクトに変換して返す.
11321199 /// </summary>
--- trunk/ChaKi.NET/src/Service/DependencyEdit/DictionaryAccessor.cs (revision 616)
+++ trunk/ChaKi.NET/src/Service/DependencyEdit/DictionaryAccessor.cs (revision 617)
@@ -11,6 +11,8 @@
1111 {
1212 public abstract string Name { get; }
1313
14+ public Uri Url { get; private set; }
15+
1416 public bool CanSearchCompoundWord { get; private set; }
1517
1618 public bool CanUpdateCompoundWord { get; private set; }
@@ -32,11 +34,13 @@
3234
3335 if (dict is Dictionary_DB)
3436 {
35- ctx = new DictionaryAccessor_DB(((Dictionary_DB)dict));
37+ ctx = new DictionaryAccessor_DB((Dictionary_DB)dict);
3638 }
3739 else if (dict is Dictionary_Cradle)
3840 {
39- ctx = new DictionaryAccessor_Cradle(((Dictionary_Cradle)dict));
41+ var cradle = (Dictionary_Cradle)dict;
42+ ctx = new DictionaryAccessor_Cradle(cradle);
43+ ctx.Url = cradle.Url;
4044 }
4145 ctx.CanSearchCompoundWord = dict.CanSearchCompoundWord;
4246 ctx.CanUpdateCompoundWord = dict.CanUpdateCompoundWord;
@@ -48,6 +52,8 @@
4852
4953 public abstract IList<MWE> FindMWEBySurface(string surface);
5054
55+ public abstract IList<MWE> FindMWEBySurface2(string surface);
56+
5157 public abstract void RegisterMWE(MWE mwe);
5258 }
5359 }
--- trunk/ChaKi.NET/src/Service/DependencyEdit/DictionaryAccessor_Cradle.cs (revision 616)
+++ trunk/ChaKi.NET/src/Service/DependencyEdit/DictionaryAccessor_Cradle.cs (revision 617)
@@ -84,12 +84,22 @@
8484
8585 public override IList<MWE> FindMWEBySurface(string surface)
8686 {
87+ return FindMWEBySurface_Impl(surface, "find_mwe");
88+ }
89+
90+ public override IList<MWE> FindMWEBySurface2(string surface)
91+ {
92+ return FindMWEBySurface_Impl(surface, "find_mwe2");
93+ }
94+
95+ private IList<MWE> FindMWEBySurface_Impl(string surface, string apiname)
96+ {
8797 var result = new List<MWE>();
8898
8999 var client = new WebClient();
90100 client.Encoding = new UTF8Encoding();
91101 var json = client.DownloadString(
92- new Uri(string.Format("{0}find_mwe?surface={1}", m_Dict.Url, surface)));
102+ new Uri($"{m_Dict.Url}{apiname}?surface={surface}"));
93103 var jarray = JArray.Parse(json);
94104 foreach (var item in jarray)
95105 {
--- trunk/ChaKi.NET/src/Service/DependencyEdit/DictionaryAccessor_DB.cs (revision 616)
+++ trunk/ChaKi.NET/src/Service/DependencyEdit/DictionaryAccessor_DB.cs (revision 617)
@@ -63,6 +63,11 @@
6363 return new List<MWE>(); // This Dictionary does not support MWE(Compound Word)
6464 }
6565
66+ public override IList<MWE> FindMWEBySurface2(string surface)
67+ {
68+ return new List<MWE>(); // This Dictionary does not support MWE(Compound Word)
69+ }
70+
6671 public override void RegisterMWE(MWE mwe)
6772 {
6873 // This Dictionary does not support MWE(Compound Word)
--- trunk/ChaKi.NET/src/Service/Lexicons/LexiconService.cs (revision 616)
+++ trunk/ChaKi.NET/src/Service/Lexicons/LexiconService.cs (revision 617)
@@ -124,7 +124,7 @@
124124 //
125125 // 以下は今のところ使用していない。DepEditServiceで実装されている。
126126 //
127- public IList<Lexeme> FindAllLexemeCandidates(string str)
127+ public IList<LexemeCandidate> FindAllLexemeCandidates(string str)
128128 {
129129 throw new NotImplementedException();
130130 }
@@ -144,5 +144,9 @@
144144 throw new NotImplementedException();
145145 }
146146
147+ public List<MatchingResult> FindMWECandidates2(string surface, IList<Word> words)
148+ {
149+ throw new NotImplementedException();
150+ }
147151 }
148152 }
--- trunk/ChaKi.NET/src/Service/WordEdit/WordEditService.cs (revision 616)
+++ trunk/ChaKi.NET/src/Service/WordEdit/WordEditService.cs (revision 617)
@@ -91,9 +91,9 @@
9191 Operation.CreateOrUpdateLexeme(m_Context, ref lex, props, customprop);
9292 }
9393
94- public IList<Lexeme> FindAllLexemeCandidates(string str)
94+ public IList<LexemeCandidate> FindAllLexemeCandidates(string str)
9595 {
96- return DepEditService.FindAllLexemeCandidates(m_Context.Session, m_RefDics, str);
96+ throw new NotImplementedException();
9797 }
9898
9999 public void GetLexiconTags(out Dictionary<string, IList<PartOfSpeech>> pos, out Dictionary<string, IList<CType>> ctypes, out Dictionary<string, IList<CForm>> cforms)
@@ -103,7 +103,12 @@
103103
104104 public List<MWE> FindMWECandidates(IList<Word> words, Action<string> showMessageCallback, Action<MWE, MatchingResult> foundMWECallback)
105105 {
106- return DepEditService.FindMWECandidates(m_RefDics, words, showMessageCallback, foundMWECallback);
106+ throw new NotImplementedException();
107107 }
108+
109+ public List<MatchingResult> FindMWECandidates2(string surface, IList<Word> words)
110+ {
111+ throw new NotImplementedException();
112+ }
108113 }
109114 }
--- trunk/ChaKi.NET/src/ServiceInterface/Lexicons/ILexiconService.cs (revision 616)
+++ trunk/ChaKi.NET/src/ServiceInterface/Lexicons/ILexiconService.cs (revision 617)
@@ -11,7 +11,7 @@
1111 /// Surfaceがstrに一致するLexemeをすべて得る。
1212 /// </summary>
1313 /// <param name="str"></param>
14- IList<Lexeme> FindAllLexemeCandidates(string str);
14+ IList<LexemeCandidate> FindAllLexemeCandidates(string str);
1515
1616 /// <summary>
1717 /// propsで与えられた内容を元に既存のLexemeを更新または新たに生成してDBに登録する.
@@ -37,5 +37,13 @@
3737 /// </summary>
3838 /// <param name="str"></param>
3939 List<MWE> FindMWECandidates(IList<Word> words, Action<string> showMessageCallback = null, Action<MWE, MatchingResult> foundMWECallback = null);
40+
41+ /// <summary>
42+ /// surfaceを含み、word list(本文)の一部になりうるMWEをすべて辞書から検索し、
43+ /// word listとのマッチング結果を返す.
44+ /// </summary>
45+ /// <param name="surface"></param>
46+ /// <returns></returns>
47+ List<MatchingResult> FindMWECandidates2(string surface, IList<Word> words);
4048 }
4149 }
--- trunk/ChaKi.NET/src/Text2Corpus/Properties/AssemblyInfo.cs (revision 616)
+++ trunk/ChaKi.NET/src/Text2Corpus/Properties/AssemblyInfo.cs (revision 617)
@@ -12,5 +12,5 @@
1212 [assembly: AssemblyCulture("")]
1313 [assembly: ComVisible(false)]
1414 [assembly: Guid("a8cf8403-eb88-418f-bf54-56aeaef39268")]
15-[assembly: AssemblyVersion("3.11.613.0")]
16-[assembly: AssemblyFileVersion("3.11.613.0")]
15+[assembly: AssemblyVersion("3.11.616.0")]
16+[assembly: AssemblyFileVersion("3.11.616.0")]
--- trunk/ChaKi.NET/src/Timings/Properties/AssemblyInfo.cs (revision 616)
+++ trunk/ChaKi.NET/src/Timings/Properties/AssemblyInfo.cs (revision 617)
@@ -12,5 +12,5 @@
1212 [assembly: AssemblyCulture("")]
1313 [assembly: ComVisible(false)]
1414 [assembly: Guid("ff6652ed-b932-466b-944b-ce88d698979b")]
15-[assembly: AssemblyVersion("3.11.613.0")]
16-[assembly: AssemblyFileVersion("3.11.613.0")]
15+[assembly: AssemblyVersion("3.11.616.0")]
16+[assembly: AssemblyFileVersion("3.11.616.0")]
Show on old repository browser