ProjectSelector comboboxにカレントコーパスのproject id listが表示されるよう修正
@@ -1,4 +1,5 @@ | ||
1 | -using System; | |
1 | +using ChaKi.Entity.Corpora; | |
2 | +using System; | |
2 | 3 | using System.Collections.Generic; |
3 | 4 | using System.ComponentModel; |
4 | 5 | using System.Diagnostics; |
@@ -12,6 +13,16 @@ | ||
12 | 13 | { |
13 | 14 | public ProjectSelector() |
14 | 15 | { |
16 | + ChaKiModel.OnCurrentChanged += CurrentCorpusChangedHandler; | |
15 | 17 | } |
18 | + | |
19 | + private void CurrentCorpusChangedHandler(Corpus cps, int senid) | |
20 | + { | |
21 | + this.Items.Clear(); | |
22 | + if (cps != null && cps.DocumentSet != null) | |
23 | + { | |
24 | + this.Items.AddRange((from p in cps.DocumentSet.Projects select p.ID.ToString()).ToArray()); | |
25 | + } | |
26 | + } | |
16 | 27 | } |
17 | 28 | } |
@@ -130,6 +130,7 @@ | ||
130 | 130 | static private void DoLUWJobs(CreateCorpus cc) |
131 | 131 | { |
132 | 132 | // 1. 通常のCabochaインポートを実行(Proj 0) |
133 | + Console.WriteLine("========================= SUW -> Proj0"); | |
133 | 134 | cc.ReaderType = "Mecab|Cabocha|UniDic2"; |
134 | 135 | DoJobs(cc); |
135 | 136 | // 2. LUWアノテーションから長単位Cabocha fileを一時的に作成 |
@@ -139,12 +140,21 @@ | ||
139 | 140 | LuwCabochaUtil.Convert(cc.InputPath, path); |
140 | 141 | Console.WriteLine($"Written to: {path}"); |
141 | 142 | // 3. 長単位cabocha fileをProj 1にインポート |
142 | - Console.WriteLine("========================="); | |
143 | + Console.WriteLine("========================= LUW -> Proj1"); | |
143 | 144 | Console.WriteLine("Importing temporary cabocha file of LUWs..."); |
144 | 145 | cc.ResetInternals(); |
145 | 146 | cc.InputPath = path; |
146 | 147 | cc.ProjectId = 1; |
147 | 148 | DoJobs(cc); |
149 | + // 4. 一時ファイルを削除 | |
150 | + try | |
151 | + { | |
152 | + File.Delete(path); | |
153 | + } | |
154 | + catch (Exception ex) | |
155 | + { | |
156 | + Console.WriteLine($"Cannot delete temp file: {ex.Message}"); | |
157 | + } | |
148 | 158 | } |
149 | 159 | |
150 | 160 | static void PrintUsage() |
@@ -495,6 +495,14 @@ | ||
495 | 495 | } |
496 | 496 | } |
497 | 497 | } |
498 | + | |
499 | + // Project ID Listを取得 | |
500 | + var projects = session.CreateQuery("from Project").List<Project>(); | |
501 | + if (cps.DocumentSet == null) | |
502 | + { | |
503 | + cps.DocumentSet = new DocumentSet(); | |
504 | + } | |
505 | + cps.DocumentSet.Projects = projects; | |
498 | 506 | } |
499 | 507 | } |
500 | 508 |