示例#1
0
        public DictionaryGenerator(Dictionary dictionary, string directory, string outputDirectory)
        {
            this.dictionary = dictionary;
            this.outputDirectory = outputDirectory;
            this.directory = directory;
            this.errorModel = new MPSpell.Correction.ErrorModel(dictionary);
            this.languageModel = new LanguageModel(dictionary);

            int initValue = 1;

            char[] alphabetWithSpace = dictionary.GetAlphabetForErrorModel(true).ToCharArray();
            char[] alphabet = dictionary.GetAlphabetForErrorModel().ToCharArray();
            insGen = new InsertionsMatrixGenerator(alphabetWithSpace, initValue);
            delGen = new DeletionsMatrixGenerator(alphabetWithSpace, initValue);
            subGen = new SubstitutionsMatrixGenerator(alphabet, initValue);
            trnGen = new TranspositionsMatrixGenerator(alphabet, initValue);

            charCounter = new CharFrequencyCounter(alphabetWithSpace.ToStringArray());
            twoCharCounter = new TwoCharFrequencyCounter(alphabetWithSpace.ToStringArray());
        }
示例#2
0
        public void TranspositionsMatrixTest()
        {
            TranspositionsMatrixGenerator generator = new TranspositionsMatrixGenerator(alphabet);
            var matrix = generator.GenerateMatrix(this.testData);

            Assert.AreEqual(1, matrix['c']['a']);
            Assert.IsFalse(matrix.ContainsKey(' '));
        }