Exemple #1
0
 public static void initTrieFromString( String s , Trie t )
 {
     string[] words = s.Replace("\r" , "").Split(' ' , '\n' , ',' , '.');
     foreach ( var w in words ) {
         bool valid = true;
         foreach ( char c in w )
             valid &= Char.IsLetter(c);
         if ( !valid ) continue;
         t.add(w);
     }
 }
Exemple #2
0
 public static Trie readTrie(string fileName , Filter<String> filter) {
     Trie trie=new Trie();
     StreamReader reader = null;
     try {
         reader = new StreamReader(fileName);
         string word;
         while ((word=reader.ReadLine())!=null) {
             string[] words = word.Replace("\r" , "").Split(' ' , '\n' , ',' , '.');
             foreach ( var w in words ) {
                 bool valid = true;
                 foreach ( char c in w )
                     valid &= Char.IsLetter(c);
                 if ( !valid ) continue;
                 if ( !filter(w) )
                     trie.add(w);
             }
         }
     } catch (Exception e) {
         Console.WriteLine(e.ToString());
     } finally {
         if (reader!=null) reader.Close();
     }
     return trie;
 }