Exemplo n.º 1
0
        public static WordsDictionary FromString(string str)
        {
            WordsDictionary newWords = new WordsDictionary();

            newWords.SetWords(str);
            return(newWords);
        }
Exemplo n.º 2
0
 public OneAlphabetDecoder(Alphabet alphabet, string fileName)
 {
     this.alphabet     = alphabet;
     overallStatistics = new AlphabetCounter(alphabet);
     encodedStatistics = new AlphabetCounter(alphabet);
     foundMatch        = new Match <char>(alphabet);
     overallStatistics.CountInFile(fileName);
     dictionary = new WordsDictionary(fileName);
 }
Exemplo n.º 3
0
        public Checker(string word,
                       Alphabet alphabet,
                       WordsDictionary knownWords,
                       Match <char> alreadyFound,
                       Dictionary <char, IEnumerable <char> > hypothesises)
        {
            encodedWord       = word;
            this.hypothesises = hypothesises;
            this.knownWords   = knownWords;
            this.alphabet     = alphabet;
            this.alreadyKnown = alreadyFound;

            symbols = hypothesises.Keys.Where(symbol => alphabet.IsInAlphabet(symbol));
        }
Exemplo n.º 4
0
        public void TryDecode(string text)
        {
            encodedStatistics.Add(text);
            Log.Statistics(overallStatistics);
            Log.Statistics(encodedStatistics);
            WordsDictionary dictionary = WordsDictionary.FromString(text);

            List <char> stat        = GetStat(overallStatistics);
            List <char> encodedStat = GetStat(encodedStatistics);

            foreach (string word in dictionary.Words)
            {
                Log.StartProcessing(word);
                if (foundMatch.AllFound)
                {
                    return;
                }

                TryWord(word, stat, encodedStat);
                Log.KnownWords(foundMatch);
            }
        }