Exemple #1
0
        public static WordsDictionary FromString(string str)
        {
            WordsDictionary newWords = new WordsDictionary();

            newWords.SetWords(str);
            return(newWords);
        }
Exemple #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);
 }
Exemple #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));
        }
Exemple #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);
            }
        }