Example #1
0
        public IEnumerable <Tag> CreateTagsCloud(IEnumerable <string> words)
        {
            var interestingWords = WordHandler.NormalizeAndExcludeBoringWords(words);
            var readyTags        = WordConverter.ConvertToTags(interestingWords)
                                   .Select(InsertTagInFrame)
                                   .OrderByDescending(t => t.Frequency);

            Layouter.Recreate();
            return(readyTags);
        }
Example #2
0
        public void Main(string file)
        {
            var wordHandler  = new WordHandler();
            var pdfHandler   = new PdfHandler();
            var excelHandler = new ExcelHandler();

            wordHandler.SetSuccessor(pdfHandler);
            pdfHandler.SetSuccessor(excelHandler);

            wordHandler.Process(file);
        }
        public void ReturnFalse_GivenOneString()
        {
            var stringList = new List <string>()
            {
                "On"
            };
            var wordHandler = new WordHandler();
            var expected    = false;
            var actual      = wordHandler.CompareWords(stringList[0],
                                                       stringList);

            Assert.AreEqual(expected, actual);
        }
        public void RangeSetTest()
        {
            IWordModel    model        = new WordModel(target);
            WordHandler   @WordHandler = new WordHandler(model, null, null);
            List <string> ranges       = new List <string>()
            {
                "apple", "chocolate", "salt"
            };

            model.SetRange(ranges);
            Assert.True(model.AvailableWordList.SequenceEqual(new string[] { "almond", "banana", "sugar", "sweet potato" }));
            Assert.True(model.AddedWords.OrderBy(str => str).SequenceEqual(ranges));
        }
        public void ReturnTrue_GivenMatchingStrings()
        {
            var stringList = new List <string>()
            {
                "On",
                "No"
            };
            var wordHandler = new WordHandler();
            var expected    = true;
            var actual      = wordHandler.CompareWords(stringList[0],
                                                       stringList);

            Assert.AreEqual(expected, actual);
        }
Example #6
0
        public void NormilizeAndExcludeBoringWords_BoringWordsIsNounAndConjunctions_ReturnsOnlyAdjective()
        {
            var settings = new WordHandlerSettings
            {
                SpeechPartsStatuses = new Dictionary <string, bool>
                {
                    ["Прилагательное"] = true, ["Существительное"] = false, ["Союз"] = false
                }
            };
            var words            = "Красивое и сочное яблоко".Split(" ");
            var interestingWords = new WordHandler(settings).NormalizeAndExcludeBoringWords(words).ToArray();

            interestingWords.Should().Contain("красивый", "сочный");
            interestingWords.Should().NotContain("и", "яблоко");
        }
Example #7
0
    private void Awake()
    {
        if (WordHandler.instance == null)
        {
            WordHandler.instance = this;
        }
        else if (WordHandler.instance != this)
        {
            Destroy(this.gameObject);
        }
        words_3 = new List <string>();
        words_4 = new List <string>();
        words_5 = new List <string>();
        words_6 = new List <string>();
        words_7 = new List <string>();

        string[] text = text2.ToString().Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
        for (int i = 0; i < text.Length; i++)
        {
            switch (text[i].Length)
            {
            case 3:
                words_3.Add(text[i].ToUpper());
                break;

            case 4:
                words_4.Add(text[i].ToUpper());
                break;

            case 5:
                words_5.Add(text[i].ToUpper());
                break;

            case 6:
                words_6.Add(text[i].ToUpper());
                break;

            case 7:
                words_7.Add(text[i].ToUpper());
                break;

            default:
                Debug.Log("\"" + text[i] + "\" is not allowed");
                break;
            }
        }
    }
Example #8
0
    // Use this for initialization
    void Start()
    {
        CurrentPastaList = new List<GameObject>();
        cam = GetComponent<Camera>();


        if (!WHandler) WHandler = GetComponent<WordHandler>();
        WStart = 0;
        WEnd = 0;
        TotalWeight = 0;
        for (int i = 0; i < AlphaghettiDatabase.Length; i++)
        {
            TotalWeight += AlphaghettiDatabase[i].weight;
        }


        AddPastas(InitialSpawnLetters);
    }
Example #9
0
        public FileHandler Create(string fileName)
        {
            FileHandler handler = null;

            if (fileName.EndsWith(".doc") || fileName.EndsWith(".docx"))
            {
                handler = new WordHandler();
            }
            else if (fileName.EndsWith(".xls") || fileName.EndsWith(".xlsx"))
            {
                handler = new ExcelHandler();
            }
            else if (fileName.EndsWith(".pptx"))
            {
                handler = new PresentationHandler();
            }
            return(handler);
        }
Example #10
0
        static void Main(string[] args)
        {
            // Read file
            CSVReader reader = new CSVReader("../../../CsvTest.csv");
            var       words  = reader.Read();

            // Create a list of dictionaries (length:list<string>)
            // Makes the string comparisson a lot quicker as we don't have to
            // iterate over the entire list multiple times.
            var dictionaryList = new List <WordDictionary>();

            CreateDictionaries(words, ref dictionaryList);

            var           wordHandler = new WordHandler();
            List <string> anagrams    = wordHandler.FindAnagrams(dictionaryList);

            ShowAndWrite(anagrams);
        }
Example #11
0
        static void PlayWithPalindrome()
        {
            Console.WriteLine("Enter string to test for palindrome.");
            string s  = Console.ReadLine();
            var    wh = new WordHandler(s);

            // string wordNoSpace = wh.NoSpace();
            // Console.WriteLine(wh.NoSpace());
            // Console.WriteLine(wh.Reverse(wordNoSpace));

            if (wh.IsPalindrome())
            {
                Console.WriteLine("Yes this is a palindrome.");
            }
            else
            {
                Console.WriteLine("No this is not a palindrome.");
            }
        }
        public void AddWordTest()
        {
            IWordModel  model        = new WordModel(target);
            WordHandler @WordHandler = new WordHandler(model, null, null);
            string      nonExistWord = "shoe";

            @WordHandler.AddWord(nonExistWord);
            Assert.DoesNotContain(nonExistWord, model.AddedWords);

            string existWord = "sweet potato";

            Assert.Contains(existWord, model.AvailableWordList);
            @WordHandler.AddWord(existWord);
            Assert.Contains(existWord, model.AddedWords);
            Assert.DoesNotContain(existWord, model.AvailableWordList);
            Assert.True(string.IsNullOrEmpty(model.WordInput));

            //already added, assert that the word is't added anymore
            @WordHandler.AddWord(existWord);
            Assert.Equal(1, model.AddedWords.Count(value => value == existWord));
        }
        public void DeleteWordTest()
        {
            IWordModel  model        = new WordModel(target);
            WordHandler @WordHandler = new WordHandler(model, null, null);

            @WordHandler.AddWord("apple");
            @WordHandler.AddWord("sugar");
            @WordHandler.AddWord("salt");

            string nonExistWord = "computer";

            @WordHandler.DeleteWord(nonExistWord);
            Assert.DoesNotContain(nonExistWord, model.AvailableWordList);
            @WordHandler.DeleteWord(nonExistWord);
            Assert.DoesNotContain(nonExistWord, model.AvailableWordList);

            string existWord = "sugar";

            @WordHandler.DeleteWord(existWord);
            Assert.Contains(existWord, model.AvailableWordList);
            Assert.DoesNotContain(existWord, model.AddedWords);
        }
Example #14
0
        private string ResolveWord(FileSystemInfo file)
        {
            //"if success -> return "true", else return error message string

            var filePath       = file.FullName;
            var objWordHandler = new WordHandler(filePath);

            try
            {
                objWordHandler.WordMain(filePath);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
            finally
            {
                Common.WriteSglText(filePath);
            }

            return("true");

            throw new NotImplementedException();
        }
        private static void Main(string[] args)
        {
            Console.WriteLine(DateTime.Now + " " + "Developed by Moravia Publishing & Media automation team. All rights reserved." + "\n");
            Console.WriteLine("Please input the root directory of loc templates folders >> ");
            Console.WriteLine("========================================");

Input:
            var dirInput = Console.ReadLine();

            Console.WriteLine("========================================");
            Console.WriteLine("In progress of processing, please hold on and wait for a while :) ");
            Console.WriteLine("========================================");

            // Check if input path is empty
            if (string.IsNullOrEmpty(dirInput) && string.IsNullOrWhiteSpace(dirInput))
            {
                Console.WriteLine("Empty or invalid directory, please double check and re-enter it!");
                goto Input;
            }

            // Transfer input directory string to DirectoryInfo
            if (!File.Exists(dirInput) && Directory.Exists(dirInput))
            {
                if (!dirInput.EndsWith("\\"))
                {
                    dirInput = dirInput + "\\";
                }

                var dirInfo = new DirectoryInfo(dirInput);

                // Get all subfolder names and add into LocalLanguage List
                try
                {
                    ListLangFolders(dirInfo);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error when create folders list: " + ex.Message);
                    return;
                }

                foreach (var lang in ListLang)
                {
                    try
                    {
                        var langDirInfo = new DirectoryInfo(dirInput + lang + "\\");
                        SortLocFiles(langDirInfo);
                    }
                    catch (IOException e)
                    {
                        Console.WriteLine("Fail to sort files: " + e.Message);
                        return;
                    }
                }
            }
            else if (File.Exists(dirInput))
            {
                var fileInfo = new FileInfo(dirInput);

                switch (fileInfo.Extension)
                {
                case ".dotx":
                case ".docx":
                case ".dotm":
                    ListWord.Add(fileInfo.FullName);
                    break;

                case ".xltx":
                case ".xlsx":
                case ".xltm":
                    ListExcel.Add(fileInfo.FullName);
                    break;

                case ".potx":
                case ".pptx":
                case ".potm":
                    ListPpt.Add(fileInfo.FullName);
                    break;
                }
            }

            KillProcess();

            // PowerPointHandler
            if (ListPpt.Count > 0)
            {
                foreach (var f in ListPpt)
                {
                    if (f.Contains("~$"))
                    {
                        continue;
                    }
                    Console.Write("\r\n" + "Processing: ");
                    Common.WriteLine("\r\n" + f + "\r\n");
                    var objPpt = new PowerPointHandler(f);
                    objPpt.PptMain(f);
                    Common.WriteSglText(f);
                }
            }

            // WordHandler
            if (ListWord.Count > 0)
            {
                foreach (var f in ListWord)
                {
                    if (f.Contains("~$"))
                    {
                        continue;
                    }
                    Console.Write("\r\n" + "Processing: ");
                    Common.WriteLine("\r\n" + f + "\r\n");
                    var objWordHandler = new WordHandler(f);
                    objWordHandler.WordMain(f);
                    Common.WriteSglText(f);
                }
            }

            // Process ExcelHandler files
            if (ListExcel.Count > 0)
            {
                foreach (var f in ListExcel)
                {
                    if (f.Contains("~$"))
                    {
                        continue;
                    }
                    Console.Write("\r\n" + "Processing: ");
                    Common.WriteLine("\r\n" + f + "\r\n");
                    var objExcelHandler = new ExcelHandler(f);
                    objExcelHandler.ExcelMain(f);
                    Common.WriteSglText(f);
                }
            }

            // Write all Console content to text
            Common.WriteAllText(dirInput);

            // End
            Console.WriteLine("========================================");
            Console.WriteLine("All files process complete! You are good to go!");
            Console.ReadLine();
        }
Example #16
0
        private void ThreadLaunch(Timeline timeline, TimelineHandler handler)
        {
            try
            {
                _log.Trace($"Attempting new thread for: {handler.HandlerType}");

                Thread    t         = null;
                ThreadJob threadJob = new ThreadJob
                {
                    Id      = Guid.NewGuid().ToString(),
                    Handler = handler
                };

                switch (handler.HandlerType)
                {
                case HandlerType.NpcSystem:
                    NpcSystem npc = new NpcSystem(handler);
                    break;

                case HandlerType.Command:
                    t = new Thread(() =>
                    {
                        Cmd o = new Cmd(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    threadJob.ProcessName = ProcessManager.ProcessNames.Command;

                    break;

                case HandlerType.Word:
                    _log.Trace("Launching thread for word");
                    if (_isWordInstalled)
                    {
                        var pids = ProcessManager.GetPids(ProcessManager.ProcessNames.Word).ToList();
                        if (pids.Count > timeline.TimeLineHandlers.Count(o => o.HandlerType == HandlerType.Word))
                        {
                            return;
                        }

                        t = new Thread(() =>
                        {
                            WordHandler o = new WordHandler(timeline, handler);
                        })
                        {
                            IsBackground = true,
                            Name         = threadJob.Id
                        };
                        t.Start();

                        threadJob.ProcessName = ProcessManager.ProcessNames.Word;
                    }
                    break;

                case HandlerType.Excel:
                    _log.Trace("Launching thread for excel");
                    if (_isExcelInstalled)
                    {
                        var pids = ProcessManager.GetPids(ProcessManager.ProcessNames.Excel).ToList();
                        if (pids.Count > timeline.TimeLineHandlers.Count(o => o.HandlerType == HandlerType.Excel))
                        {
                            return;
                        }

                        t = new Thread(() =>
                        {
                            ExcelHandler o = new ExcelHandler(timeline, handler);
                        })
                        {
                            IsBackground = true,
                            Name         = threadJob.Id
                        };
                        t.Start();

                        threadJob.ProcessName = ProcessManager.ProcessNames.Excel;
                    }
                    break;

                case HandlerType.Clicks:
                    _log.Trace("Launching thread to handle clicks");
                    t = new Thread(() =>
                    {
                        Clicks o = new Clicks(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();
                    break;

                case HandlerType.Reboot:
                    _log.Trace("Launching thread to handle reboot");
                    t = new Thread(() =>
                    {
                        Reboot o = new Reboot(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();
                    break;

                case HandlerType.PowerPoint:
                    _log.Trace("Launching thread for powerpoint");
                    if (_isPowerPointInstalled)
                    {
                        var pids = ProcessManager.GetPids(ProcessManager.ProcessNames.PowerPoint).ToList();
                        if (pids.Count > timeline.TimeLineHandlers.Count(o => o.HandlerType == HandlerType.PowerPoint))
                        {
                            return;
                        }

                        t = new Thread(() =>
                        {
                            PowerPointHandler o = new PowerPointHandler(timeline, handler);
                        })
                        {
                            IsBackground = true,
                            Name         = threadJob.Id
                        };
                        t.Start();

                        threadJob.ProcessName = ProcessManager.ProcessNames.PowerPoint;
                    }
                    break;

                case HandlerType.Outlook:
                    _log.Trace("Launching thread for outlook - note we're not checking if outlook installed, just going for it");
                    //if (this.IsOutlookInstalled)
                    //{
                    t = new Thread(() =>
                    {
                        Outlook o = new Outlook(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    threadJob.ProcessName = ProcessManager.ProcessNames.Outlook;
                    //}

                    break;

                case HandlerType.BrowserIE:
                    //IE demands COM apartmentstate be STA so diff thread creation required
                    t = new Thread(() =>
                    {
                        BrowserIE o = new BrowserIE(handler);
                    });
                    t.SetApartmentState(ApartmentState.STA);
                    t.IsBackground = true;
                    t.Name         = threadJob.Id;
                    t.Start();

                    break;

                case HandlerType.Notepad:
                    //TODO
                    t = new Thread(() =>
                    {
                        Notepad o = new Notepad(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    break;

                case HandlerType.BrowserChrome:
                    t = new Thread(() =>
                    {
                        BrowserChrome o = new BrowserChrome(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    threadJob.ProcessName = ProcessManager.ProcessNames.Chrome;

                    break;

                case HandlerType.BrowserFirefox:
                    t = new Thread(() =>
                    {
                        BrowserFirefox o = new BrowserFirefox(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    threadJob.ProcessName = ProcessManager.ProcessNames.Firefox;

                    break;

                case HandlerType.Watcher:
                    t = new Thread(() =>
                    {
                        Watcher o = new Watcher(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    //threadJob.ProcessName = ProcessManager.ProcessNames.Watcher;

                    break;
                }

                if (threadJob.ProcessName != null)
                {
                    _threadJobs.Add(threadJob);
                }

                if (t != null)
                {
                    _threads.Add(t);
                }
            }
            catch (Exception e)
            {
                _log.Error(e);
            }
        }
Example #17
0
 private void Awake()
 {
     _instance = this;
 }
        public ActionResult QuestionPaperDownloadWord(int id)
        {
            var data = WordHandler.DownloadWordFile(id);

            return(data);
        }
Example #19
0
 /// <summary>
 /// Check whether the tile completes a word. If the word is completed and wrong, drop the tile piece into the chasm.
 /// If the word is not completed, lay down a letter where the chasm was and update the word.
 /// If the word is completed and the
 /// </summary>
 public void SubmitTile(Tile tile, int index)
 {
     Tile[] temp_word = word;
     temp_word[index] = tile;
     for (int i = 0; i < temp_word.Length; i++)
     {
         if (temp_word[i] == Tile._)
         {
             //word not complete yet
             Debug.Log("not complete");
             PlaceTileAtChasm(tile, index);
             word = temp_word;
             if (GameController.instance.point_style == PointStyle.PlacedLetterOnly)
             {
                 GameController.instance.total_points += Mathf.FloorToInt(GameController.instance.block_multiplier * WordHandler.GetCharValue(WordHandler.TiletoChar(tile)));
             }
             return;
         }
     }
     //word is now complete check if it works
     if (WordHandler.instance.EvalWord(word) != -1)
     {
         //works, complete word,
         PlaceTileAtChasm(tile, index);
         word = temp_word;
         WordCompleted();
         if (GameController.instance.point_style == PointStyle.PlacedLetterOnly)
         {
             GameController.instance.total_points += Mathf.FloorToInt(GameController.instance.block_multiplier * WordHandler.GetCharValue(WordHandler.TiletoChar(tile)));
         }
     }
     else
     {
         //make tile fall, don't do anything.
     }
     Tile_Selection_Script.instance.Discard();
 }
Example #20
0
        public FileHandler Create(string option)
        {
            var handler = new WordHandler();

            return(handler);
        }