Пример #1
0
        public SpeechRecognitionEngine InitiliseSRE()
        {
            sre = new SpeechRecognitionEngine(
                new System.Globalization.CultureInfo("en-EN"));
            //Use the microphone
            sre.SetInputToDefaultAudioDevice();
            Choices Words = new Choices();

            //use these words
            NetSpell.SpellChecker.Dictionary.WordDictionary oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary();
            oDict.DictionaryFolder = @"packages\NetSpell.2.1.7\dic";
            oDict.DictionaryFile   = "en-CA.dic";
            //oDict.DictionaryFile = "en-US.dic";
            oDict.Initialize();
            foreach (DictionaryEntry x in oDict.BaseWords)
            {
                Words.Add((string)x.Key);
            }
            //Words.Add(new string[] { "Test", "Coffee", "blue", "Stream", "Siege","game","do anything","Chicken Nuggets" });
            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(Words);
            gb.Culture = Thread.CurrentThread.CurrentCulture;
            Grammar g = new Grammar(gb);

            sre.LoadGrammar(g);

            sre.SpeechRecognized += Sre_SpeechRecognized;
            return(sre);
        }
Пример #2
0
        public static bool HasCorrectSpell(string word)
        {
            oDict.DictionaryFile = @"..\..\..\packages\NetSpell.2.1.7\dic\en-US.dic";
            oDict.Initialize();
            wordToCheck = word;
            string CamelChecker = wordToCheck.SplitCamel();

            string[] Words = CamelChecker.Split(' ');
            counter = CheckWords(Words);
            if (counter == Words.Length)
            {
                return(true);
            }
            else
            {
                if (word.Contains('_'))
                {
                    counter = 0;
                    Words   = word.Split('_');
                    counter = CheckWords(Words);
                    if (counter == Words.Length)
                    {
                        return(true);
                    }
                }

                return(false);
            }
        }
Пример #3
0
        private const Int32 NumCheckWords = 100;              //maximum number of words the program will check to make a decision on key
        public static void Main(string[] args)
        {
            try
            {
                #region Variables
                String filename;
                String encryptedText;
                #region initializing spellchecker

                var dict = new NetSpell.SpellChecker.Dictionary.WordDictionary
                {
                    DictionaryFolder = String.Concat(Environment.CurrentDirectory, Path.DirectorySeparatorChar, "data"),
                    DictionaryFile   = "en-US.dic"
                };
                dict.Initialize();
                _spell = new NetSpell.SpellChecker.Spelling {
                    Dictionary = dict
                };

                #endregion
                #endregion

                #region Get File and Location
                if (args.Length > 0)//tries to read filename from arguments
                {
                    filename = args[0];
                }
                else//if theres no argument (double clicked exe) program need to ask for the filename
                {
                    Console.WriteLine("Enter the file name without extension (must be a .txt file)");
                    filename = Console.ReadLine();
                }

                filename += ".txt";                                       //gives .txt extension to the name
                var filepath = String.Concat(DefaultInputPath, filename); //concats path and filename

                #endregion
                encryptedText = File.ReadAllText(filepath); //puts all text in a single string to work with

                // gets the most suitable key for the given text
                var key = FindKey(encryptedText);

                var text = TranslateText(encryptedText, key);

                Console.WriteLine(text);

                Console.ReadKey();
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("File not found!");
                Console.ReadKey();
            }
            catch (Exception)
            {
                Console.WriteLine("Something really unexpected happened! :( \n" +
                                  "Shutting down the application...");
                Console.ReadKey();
            }
        }
Пример #4
0
        protected void Page_Init(object sender, EventArgs e)
        {
            // if not in cache, create new
            WordDictionary = new NetSpell.SpellChecker.Dictionary.WordDictionary();
            WordDictionary.EnableUserFile = false;

            //getting folder for dictionaries
            string          dicFolder = Path.Combine(Utils.GetDataFolderPath(), @"dictionary");
            WebmailSettings settings  = (new WebMailSettingsCreator()).CreateWebMailSettings();
            string          defLang   = settings.DefaultLanguage;
            Account         acct      = (Account)Session[Constants.sessionAccount];

            if (acct != null)
            {
                defLang = acct.UserOfAccount.Settings.DefaultLanguage;
            }
            string dictionaryFile = "en-US.dic";

            switch (defLang)
            {
            case "French": dictionaryFile = "fr-FR.dic"; break;

            case "German": dictionaryFile = "de-DE.dic"; break;
            }
            WordDictionary.DictionaryFolder = dicFolder;
            WordDictionary.DictionaryFile   = dictionaryFile;

            //load and initialize the dictionary
            WordDictionary.Initialize();

            // create spell checker
            SpellChecker            = new Spelling();
            SpellChecker.ShowDialog = false;
            SpellChecker.Dictionary = WordDictionary;
        }
Пример #5
0
 public WordChecker()
 {
     oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary();
     oDict.DictionaryFile = "en-US.dic";
     oDict.Initialize();
     oSpell            = new NetSpell.SpellChecker.Spelling();
     oSpell.Dictionary = oDict;
 }
Пример #6
0
 public WordTransform(string ws, string wd)
 {
     wsrc   = ws;                        //set source word
     wtrans = ws;
     wdst   = wd;
     oDict  = new NetSpell.SpellChecker.Dictionary.WordDictionary();
     oSpell = new NetSpell.SpellChecker.Spelling();
     oDict.DictionaryFile = "packages\\NetSpell.2.1.7\\dic\\en-US.dic";
     oDict.Initialize();     //set final word
 }
Пример #7
0
 public CleanCodeAnalyzer(TokenGenerator tokenGenerator)
 {
     this.tokenGenerator = tokenGenerator;
     oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary();
     //If you're running this project separately you need to change this to relative path.
     oDict.DictionaryFile = "CocoProject/packages/NetSpell.2.1.7/dic/en-US.dic";
     oDict.Initialize();
     oSpell            = new NetSpell.SpellChecker.Spelling();
     oSpell.Dictionary = oDict;
 }
Пример #8
0
        public MainForm()
        {
            InitializeComponent();


            NetSpell.SpellChecker.Dictionary.WordDictionary w = new NetSpell.SpellChecker.Dictionary.WordDictionary();
            w.DictionaryFile   = "en-US.dic";
            w.DictionaryFolder = Application.StartupPath + @"\";
            w.Initialize();
            nS            = new NetSpell.SpellChecker.Spelling();
            nS.Dictionary = w;
            nS.ShowDialog = false;
        }
Пример #9
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            NetSpell.SpellChecker.Dictionary.WordDictionary oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary();
            string wordToCheck = activity.Text;

            try
            {
                oDict.DictionaryFile = "C:\\Program Files (x86)\\IIS Express\\en-US.dic";
                oDict.Initialize();
                NetSpell.SpellChecker.Spelling oSpell = new NetSpell.SpellChecker.Spelling();
                oSpell.Dictionary = oDict;



                // calculate something for us to return
                int length = (activity.Text ?? string.Empty).Length;

                // return our reply to the user
                if (oSpell.TestWord(wordToCheck))
                {
                    await context.PostAsync($"Word exists in the English dictionary");
                }
                else
                {
                    await context.PostAsync($"Word does not exist in the English dictionary");
                }
            }
            catch (FileNotFoundException fnfe)
            {
                await context.PostAsync($"File Was Not Found | Details: {fnfe.Message}");
            }
            finally
            {
                oDict.Dispose();
            }


            //await context.PostAsync($"You sent {activity.Text} which was {length} characters From {activity.From}");

            context.Wait(MessageReceivedAsync);
        }
Пример #10
0
        static void Main(string[] args)
        {
            validWordsDict = new Dictionary <string, bool>();
            callsDict      = new Dictionary <string, bool>();

            oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary();
            oDict.DictionaryFile = "en-US.dic";
            oDict.Initialize();
            oSpell            = new NetSpell.SpellChecker.Spelling();
            oSpell.Dictionary = oDict;

            var s             = "aqqz";
            var filledIndexes = "aaaa";
            var alphabet      = "abcdefghijklmnopqrstuvwxyz";

            var codes = CrackCode(s, filledIndexes, alphabet).ToList();

            var str = codes.Aggregate((a, b) => $"{a}{Environment.NewLine}{b}");

            System.Console.Out.WriteLine(str);
        }
Пример #11
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Iterations = new WordsArray(this);

            Bulls = new BullsArray(this);

            Cows = new CowsArray(this);

            Chances = new ChancesArray(this);

            NetSpell.SpellChecker.Dictionary.WordDictionary oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary();

            oDict.DictionaryFile = "en-US.dic";

            oDict.Initialize();

            spelCheck = new NetSpell.SpellChecker.Spelling();

            spelCheck.Dictionary = oDict;

            OriginalWord = GenerateWord();
        }
Пример #12
0
        //-////////////////////////////////////////////////////////
        //
        static void Main(string[] args)
        {
            //char[] arr = { 'a', 'b', 'c' };
            //GetPer2(arr, (char[] result) =>
            //{
            //    Console.WriteLine(result);
            //    if(new string(result) == "bca")
            //    {
            //        Console.WriteLine("Found it!");
            //        return true;
            //    }
            //    return false;
            //});
            //return;

            /// Initialization
            // Init Word Checker
            wordDict = new NetSpell.SpellChecker.Dictionary.WordDictionary();
            wordDict.DictionaryFile = "en-US.dic";
            wordDict.Initialize();
            wordChecker            = new NetSpell.SpellChecker.Spelling();
            wordChecker.Dictionary = wordDict;

            //string input = "fqjcb rwjwj vnjax bnkhj whxcq nawjv nfxdu mbvnu ujbbf nnc";
            //string input = "fqjcbrwjwjvnjaxbnkhjwhxcqnawjvnfxdumbvnuujbbfnnc";
            string input = inputStrings[2];

            Console.WriteLine("==============================");
            Console.WriteLine(input);

            bool success = Decrypt(input);

            /// Complete Decryption Process
            // Print Map Results
            PrintSubstitutionMap(substitutionMap);
            // Finished. Keep Console Open.
            Console.Read();
        }
Пример #13
0
        public static bool validTurn(List <BoardSpace> spacesPlayed)
        {
            if (spacesPlayed.Count < 1)
            {
                return(true);
            }
            NetSpell.SpellChecker.Dictionary.WordDictionary oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary();

            oDict.DictionaryFile = @"Assets\Packages\NetSpell.2.1.7\dic\en-US.dic";
            oDict.Initialize();

            List <String>     wordsPlayed = new List <String>();
            List <BoardSpace> spacesAdded = new List <BoardSpace>();

            foreach (BoardSpace space in spacesPlayed)
            {
                string word = "";
                word += space.getTile().getLetter();
                if (!checkListForMatch(space, spacesAdded))
                {
                    spacesAdded.Add(space);
                }

                //Check Left and Right
                if ((space.getX() != 0 && Board.boardSpaces[space.getX() - 1, space.getY()].checkEmpty() == false) || (space.getX() != 15 && Board.boardSpaces[space.getX() + 1, space.getY()].checkEmpty() == false))
                {
                    int xIndex = space.getX();
                    int yIndex = space.getY();
                    //Left
                    while (xIndex != 0 && Board.boardSpaces[xIndex - 1, yIndex].checkEmpty() == false && !checkListForMatch(Board.boardSpaces[xIndex - 1, yIndex], spacesAdded))
                    {
                        spacesAdded.Add(Board.boardSpaces[xIndex - 1, yIndex]);
                        word = Board.boardSpaces[xIndex - 1, yIndex].getTile().getLetter() + word;
                        Console.WriteLine(word);

                        xIndex--;
                    }
                    //Reset to original position
                    xIndex = space.getX();
                    yIndex = space.getY();

                    //Right
                    while (xIndex != 14 && Board.boardSpaces[xIndex + 1, yIndex].checkEmpty() == false && !checkListForMatch(Board.boardSpaces[xIndex + 1, yIndex], spacesAdded))
                    {
                        spacesAdded.Add(Board.boardSpaces[xIndex + 1, yIndex]);
                        word = word + Board.boardSpaces[xIndex + 1, yIndex].getTile().getLetter();
                        Console.WriteLine(word);

                        xIndex++;
                    }

                    if (word.Length > 1)
                    {
                        wordsPlayed.Add(word);
                    }
                }

                word  = "";
                word += space.getTile().getLetter();
                //Check Above and Below Space
                if ((space.getY() != 0 && Board.boardSpaces[space.getX(), space.getY() - 1].checkEmpty() == false) || (space.getY() != 15 && Board.boardSpaces[space.getX(), space.getY() + 1].checkEmpty() == false))
                {
                    int xIndex = space.getX();
                    int yIndex = space.getY();
                    //Below
                    while (yIndex != 0 && Board.boardSpaces[xIndex, yIndex - 1].checkEmpty() == false && !checkListForMatch(Board.boardSpaces[xIndex, yIndex - 1], spacesAdded))
                    {
                        spacesAdded.Add(Board.boardSpaces[xIndex, yIndex - 1]);
                        word = word + Board.boardSpaces[xIndex, yIndex - 1].getTile().getLetter();
                        Console.WriteLine(word);

                        yIndex--;
                    }
                    //Reset to original position
                    xIndex = space.getX();
                    yIndex = space.getY();

                    //Above
                    while (yIndex != 14 && Board.boardSpaces[xIndex, yIndex + 1].checkEmpty() == false && !checkListForMatch(Board.boardSpaces[xIndex, yIndex + 1], spacesAdded))
                    {
                        spacesAdded.Add(Board.boardSpaces[xIndex, yIndex + 1]);
                        word = Board.boardSpaces[xIndex, yIndex + 1].getTile().getLetter() + word;
                        Console.WriteLine(word);

                        yIndex++;
                    }

                    if (word.Length > 1)
                    {
                        wordsPlayed.Add(word);
                    }
                }
            }

            foreach (string word in wordsPlayed)
            {
                string wordToCheck = word;
                NetSpell.SpellChecker.Spelling oSpell = new NetSpell.SpellChecker.Spelling();

                oSpell.Dictionary = oDict;
                string reverse = reverseWord(wordToCheck);
                if (!oSpell.TestWord(reverse) && !oSpell.TestWord(wordToCheck))
                {
                    //Allows no tiles to be played and still be a valid turn
                    if (spacesPlayed.Count != 0)
                    {
                        //FAKE WORD DETECTED - RETURN FALSE AND NOTIFY PLAYER THEIR TURN IS NO GOOD
                        return(false);
                    }
                }
            }

            if (Board.boardSpaces[7, 7].checkEmpty() || wordsPlayed.Count == 0)
            {
                return(false);
            }
            return(true);//ALL WORDS ARE GOOD, Star space is used
        }
Пример #14
0
        static void Main(string[] args)
        {
            SeleccionaRegistros();
            Console.WriteLine("Termine de seleccionar registros");
            Console.WriteLine("Ojo Ojo Ojo");
            Console.ReadKey();
            Console.WriteLine("Empezamos con la lectura de BD");
            ExtracciónPalabras contratosTexto = new ExtracciónPalabras();
            Thread             t2012          = new Thread(new ThreadStart(contratosTexto.Extrae2012));
            Thread             t2013          = new Thread(new ThreadStart(contratosTexto.Extrae2013));
            Thread             t2014          = new Thread(new ThreadStart(contratosTexto.Extrae2014));
            Thread             t2015          = new Thread(new ThreadStart(contratosTexto.Extrae2015));
            Thread             t2016          = new Thread(new ThreadStart(contratosTexto.Extrae2016));
            Thread             t2017          = new Thread(new ThreadStart(contratosTexto.Extrae2017));
            Thread             t2018          = new Thread(new ThreadStart(contratosTexto.Extrae2018));

            t2012.Start();
            t2013.Start();
            t2014.Start();
            t2015.Start();
            t2016.Start();
            t2017.Start();
            t2018.Start();

            t2012.Join();
            t2013.Join();
            t2014.Join();
            t2015.Join();
            t2016.Join();
            t2017.Join();
            t2018.Join();

            Console.WriteLine("Inventario de Palabras de la base de datos");

            CreaInventarioPalabras(@"D:\AnalisisPalabrasAPF\Palabras2012.txt");
            CreaInventarioPalabras(@"D:\AnalisisPalabrasAPF\Palabras2013.txt");
            CreaInventarioPalabras(@"D:\AnalisisPalabrasAPF\Palabras2014.txt");
            CreaInventarioPalabras(@"D:\AnalisisPalabrasAPF\Palabras2015.txt");
            CreaInventarioPalabras(@"D:\AnalisisPalabrasAPF\Palabras2016.txt");
            CreaInventarioPalabras(@"D:\AnalisisPalabrasAPF\Palabras2017.txt");
            CreaInventarioPalabras(@"D:\AnalisisPalabrasAPF\Palabras2018.txt");

            Console.WriteLine("Terminamos inventario");
            Console.WriteLine("Escribimos el inventario de palabras");
            List <string> ListaInventarioPalabras = new List <string>();

            foreach (string palabra in InventarioPalabras)
            {
                ListaInventarioPalabras.Add(palabra);
            }
            ListaInventarioPalabras.Sort();

            componente = new System.ComponentModel.Container();
            NetSpell.SpellChecker.Spelling oSpell = new NetSpell.SpellChecker.Spelling(componente);
            NetSpell.SpellChecker.Dictionary.WordDictionary oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary(componente);
            oDict.DictionaryFolder = @"D:\VSProjects\NetSpell.2.1.7\dic\";
            oDict.DictionaryFile   = "es-MX.dic";
            oDict.Initialize();
            oSpell.Dictionary = oDict;

            if (oSpell.TestWord("acertijo"))
            {
                Console.WriteLine("acertijo OK");
            }
            else
            {
                Console.WriteLine("acertijo NOK");
            }
            if (oSpell.TestWord("acercátelos"))
            {
                Console.WriteLine(" acercátelos OK");
            }
            else
            {
                Console.WriteLine("acercátelos NOK");
            }

            using (System.IO.StreamWriter fileOK =
                       new System.IO.StreamWriter(@"D:\AnalisisPalabrasAPF\InventarioOK.txt")) {
                using (System.IO.StreamWriter fileNOK =
                           new System.IO.StreamWriter(@"D:\AnalisisPalabrasAPF\InventarioNOK.txt"))
                {
                    foreach (string palabra in ListaInventarioPalabras)
                    {
                        if (palabra.Length > 2)
                        {
                            if (oSpell.TestWord(palabra))
                            {
                                fileOK.WriteLine(palabra + " OK");
                            }
                            else
                            {
                                fileNOK.WriteLine(palabra + " NOK");
                            }
                        }
                    }
                }
            }

            Console.WriteLine("Acabamos inventarios");
            Console.ReadKey();
        }