- Timestamp:
- 04/28/09 21:20:47 (4 years ago)
- Location:
- lang/csharp/soyText/soyText
- Files:
-
- 3 added
- 11 modified
-
AndCondition.cs (added)
-
AnyCondition.cs (added)
-
DocumentSercher.cs (modified) (4 diffs)
-
DocumentSet.cs (modified) (1 diff)
-
Form1.cs (modified) (3 diffs)
-
KeywordCondition.cs (added)
-
SearchCondition.cs (modified) (1 diff)
-
TerminableThread.cs (modified) (1 diff)
-
bin/Debug/soyText.application (modified) (1 diff)
-
bin/Debug/soyText.exe (modified) (previous)
-
bin/Debug/soyText.exe.manifest (modified) (2 diffs)
-
bin/Debug/soyText.pdb (modified) (previous)
-
bin/Debug/soyText.vshost.application (modified) (1 diff)
-
soyText.csproj (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/csharp/soyText/soyText/DocumentSercher.cs
r32864 r32912 6 6 namespace SoyText 7 7 { 8 class DocumentSercher8 public class DocumentSercher 9 9 { 10 DocumentSet documentSet; 11 SearchCondition searchCondition; 12 FoundHandler foundHandler; 10 public DocumentSet documentSet; 11 public SearchCondition searchCondition; 12 public FoundHandler foundHandler; 13 bool terminated = false; 14 public void terminate() { terminated = true; } 13 15 public SortedList<long, Document> search() 14 16 { … … 20 22 } 21 23 var res = new SortedList<long, Document>(); 22 if (searchCondition == null || searchCondition .isAny)24 if (searchCondition == null || searchCondition is AnyCondition) 23 25 { 24 26 foreach (var d in rec) … … 27 29 if (a == FoundHandlerAction.End) break; 28 30 if (a == FoundHandlerAction.Accept) res.Add(d.Key, d.Value); 31 if (terminated) break; 29 32 } 30 33 return res; … … 45 48 } 46 49 } 50 if (terminated) break; 47 51 } 48 52 Debug.print("完了: 文書を検索: " + searchCondition); -
lang/csharp/soyText/soyText/DocumentSet.cs
r32760 r32912 97 97 return maxHandle; 98 98 } 99 public DocumentSercher createDocumentSearcher(String kw, FoundHandler f) 100 { 101 var s = new DocumentSercher(); 102 s.searchCondition = SearchCondition.fromExpression(kw); 103 s.foundHandler = f; 104 s.documentSet = this; 105 return s; 106 } 99 107 public SortedList<long,Document> search(String kw, FoundHandler f) 100 108 { 101 var rec0 = getRecents(); 102 var rec = new SortedList<long, Document>(); 103 lock (rec0) 104 { 105 foreach (var d in rec0) rec.Add(d.Key, d.Value); 106 } 107 var res = new SortedList<long, Document>(); 108 if (kw == null || kw.Equals("")) 109 { 110 foreach (var d in rec) 111 { 112 var a = f(d.Value); 113 if (a == FoundHandlerAction.End) break; 114 if (a == FoundHandlerAction.Accept) res.Add(d.Key,d.Value); 115 } 116 return res; 117 } 118 var t = workspace.indexer.createToken(kw); 119 /*Debug.print("文字検索: " + kw); 120 foreach (var st in t.existentSuperstrings) 121 { 122 var ress = exactSearch(st); 123 foreach (var d in ress) { 124 if (!res.ContainsKey(d.Key)) 125 { 126 res.Add(d.Key, d.Value); 127 } 128 } 129 }*/ 130 var c=rec.Count; 131 var cnt = 0; 132 foreach (var d in rec) 133 { 134 Debug.print("文書を検索: " + kw+"("+cnt+"/"+c+") - "+res.Count+"件見つかりました"); 135 cnt++; 136 if (d.Value.matches(kw)) 137 { 138 if (!res.ContainsKey(d.Key)) 139 { 140 var a=f(d.Value); 141 if (a == FoundHandlerAction.End) break; 142 if (a == FoundHandlerAction.Accept) res.Add(d.Key, d.Value); 143 } 144 } 145 } 146 Debug.print("完了: 文書を検索: " + kw); 147 148 //var resList = res.ToList(); 149 //Debug.print("検索結果の並べ替え: "+kw); 150 //resList.Sort(byRecency); 151 //Debug.print("End: 検索結果の並べ替え: " + kw); 152 return res; 153 109 var s = createDocumentSearcher(kw, f); 110 return s.search(); 154 111 } 112 155 113 private SortedList<long, Document> exactSearch(Token t) 156 114 { -
lang/csharp/soyText/soyText/Form1.cs
r32864 r32912 67 67 } 68 68 TerminableThread searchThread = new TerminableThread(); 69 DocumentSercher documentSearcher; 69 70 public void refreshList(String kw) 70 71 { 71 72 if (kw == "" || kw==null) Text = "soyText"; 72 73 else Text = kw + " - " + "soyText"; 73 74 if (documentSearcher != null) documentSearcher.terminate(); 74 75 searchThread.exec(delegate(TerminableThread t) 75 76 { … … 79 80 docListBox.Items.Clear(); 80 81 }); 81 SortedList<long, Document> res = documentSet.search(kw, delegate(Document d) 82 documentSearcher = documentSet.createDocumentSearcher(kw, 83 delegate(Document d) 82 84 { 83 85 cnt++; 84 if (cnt < 100 && !t.terminated)86 if (cnt < 100) 85 87 { 86 88 syncUI(delegate() { docListBox.Items.Add(d); }); … … 93 95 } 94 96 }); 97 documentSearcher.search(); 95 98 statusText = "完了"; 96 99 }); -
lang/csharp/soyText/soyText/SearchCondition.cs
r32864 r32912 6 6 namespace SoyText 7 7 { 8 public class SearchCondition8 public abstract class SearchCondition 9 9 { 10 String word; 11 public bool matches(Document d) 12 { 13 return d.content.IndexOf(word) >= 0; 14 } 15 public bool matches(DocumentLine line) 16 { 17 return line.content.IndexOf(word) >= 0; 18 } 10 public abstract bool matches(Document d); 11 public abstract bool matches(DocumentLine d); 19 12 public static SearchCondition fromExpression(String expr) 20 13 { 21 var r = new SearchCondition(); 22 r.word = expr; 23 return r; 24 } 25 public bool isAny { get { return word == ""; } } 26 public override string ToString() 27 { 28 return word; 14 if (expr == null || expr == "") return new AnyCondition(); 15 string[] s = expr.Split(' '); 16 if (s.Length == 1) 17 { 18 return new KeywordCondition(expr); 19 } 20 if (s.Length == 0) 21 { 22 return new AnyCondition(); 23 } 24 var res = new AndCondition(); 25 foreach (var e in s) 26 { 27 res.add(fromExpression(e)); 28 } 29 return res; 29 30 } 30 31 } -
lang/csharp/soyText/soyText/TerminableThread.cs
r32864 r32912 28 28 { 29 29 r = nextRun; 30 nextRun = null; 30 31 _running = true; 31 32 terminated = false; -
lang/csharp/soyText/soyText/bin/Debug/soyText.application
r32864 r32912 12 12 </dsig:Transforms> 13 13 <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> 14 <dsig:DigestValue> j6hhuQVWYtfWkwy8j3nFgirX6hk=</dsig:DigestValue>14 <dsig:DigestValue>b4VFJRybu2kjnO+ggm9SDfFqbuo=</dsig:DigestValue> 15 15 </hash> 16 16 </dependentAssembly> -
lang/csharp/soyText/soyText/bin/Debug/soyText.exe.manifest
r32864 r32912 53 53 </dependency> 54 54 <dependency> 55 <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="soyText.exe" size="4 5568">55 <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="soyText.exe" size="46080"> 56 56 <assemblyIdentity name="soyText" version="1.0.0.0" language="neutral" processorArchitecture="msil" /> 57 57 <hash> … … 60 60 </dsig:Transforms> 61 61 <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> 62 <dsig:DigestValue> EHWhcOuAInIwLvFSenDNLPBrS1s=</dsig:DigestValue>62 <dsig:DigestValue>yJYEl9jmz0Myd9vk+kUqmHKRDv4=</dsig:DigestValue> 63 63 </hash> 64 64 </dependentAssembly> -
lang/csharp/soyText/soyText/bin/Debug/soyText.vshost.application
r32864 r32912 12 12 </dsig:Transforms> 13 13 <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> 14 <dsig:DigestValue> j6hhuQVWYtfWkwy8j3nFgirX6hk=</dsig:DigestValue>14 <dsig:DigestValue>b4VFJRybu2kjnO+ggm9SDfFqbuo=</dsig:DigestValue> 15 15 </hash> 16 16 </dependentAssembly> -
lang/csharp/soyText/soyText/soyText.csproj
r32864 r32912 70 70 </ItemGroup> 71 71 <ItemGroup> 72 <Compile Include="AndCondition.cs" /> 72 73 <Compile Include="Debug.cs" /> 73 74 <Compile Include="Document.cs" /> 74 75 <Compile Include="DocumentImporter.cs" /> 75 76 <Compile Include="DocumentLine.cs" /> 77 <Compile Include="AnyCondition.cs" /> 76 78 <Compile Include="DocumentSercher.cs" /> 77 79 <Compile Include="DocumentSet.cs" /> … … 125 127 </Compile> 126 128 <Compile Include="Inclusion.cs" /> 129 <Compile Include="KeywordCondition.cs" /> 127 130 <Compile Include="SearchCondition.cs" /> 128 131 <Compile Include="Str.cs" /> … … 171 174 </BootstrapperPackage> 172 175 </ItemGroup> 176 <ItemGroup> 177 <Folder Include="Search\" /> 178 </ItemGroup> 173 179 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 174 180 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)