private bool IsImportantMessageProc(string message) { var importantWordsConfig = ConfigurationManager.AppSettings["Important_Words"]; if (string.IsNullOrEmpty(importantWordsConfig)) { return(false); } if (string.IsNullOrEmpty(message)) { return(false); } var importantWords = new HashSet <string>(importantWordsConfig.ToLower().Split('|').Distinct()); var words = new WordParser().Parse(message) .Where(x => !string.IsNullOrEmpty(x)) .Select(x => x.ToLower()) .Distinct() .ToList(); if (words.Any(x => importantWords.Contains(x))) { return(true); } return(false); }
public override void Initialize(AnalysisContext context) { context.EnableConcurrentExecution(); context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.RegisterSymbolAction(context => { var eventName = context.Symbol.Name; if (!eventName.StartsWith(BeforeKeyword, StringComparison.Ordinal) && !eventName.StartsWith(AfterKeyword, StringComparison.Ordinal)) { return; } var wordParse = new WordParser(eventName, WordParserOptions.SplitCompoundWords); if (wordParse.NextWord() is string firstWord && s_invalidPrefixes.Contains(firstWord) && wordParse.NextWord() is string) // Do not report if this is the only word { context.ReportDiagnostic(context.Symbol.CreateDiagnostic(Rule)); } }, SymbolKind.Event); }
public override ProblemCollection Check(Resource resource) { using (MemoryStream mstream = new MemoryStream(resource.Data, false)) { using (ResourceReader reader = new ResourceReader(mstream)) { foreach (DictionaryEntry entry in reader) { string s = entry.Value as string; if (s != null) { foreach (String word in WordParser.Parse(s, WordParserOptions.None)) { if (NamingService.DefaultNamingService.CheckSpelling(word) != WordSpelling.SpelledCorrectly) { this.Problems.Add(new Problem(this.GetResolution(word), word)); } } } } } } return(this.Problems); }
public void AddWord() { Word word = new Word(WordParser.GetRandomWord(), spawner.SpawnWord()); words.Add(word); Debug.Log("Random word was spawned succesfully : " + word.text); }
private static void Main(string[] args) { var filePath = args.Length > 0 ? args[0] : DefaultPath; try { var parser = new WordParser(); parser.Parse(filePath); Console.WriteLine("Total words: {0}. Different words: {1}", parser.Result.TotalWordsCount, parser.Result.DifferentWordsCount); Console.WriteLine("Least used word: '{0}'. Usages count: {1}", parser.Result.LeastUsedWord.Word, parser.Result.LeastUsedWord.UsagesCount); Console.WriteLine("Most used word: '{0}'. Usages count: {1}", parser.Result.MostUsedWord.Word, parser.Result.MostUsedWord.UsagesCount); SaveResultToFile(ResultPath, parser.Result); } catch (FileNotFoundException ex) { Console.WriteLine("File '{0}' could not be found. Please specify path to existing file or use 'Content\\input.txt' file", ex.FileName); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
/// <summary> /// This method returns the Extensions /// </summary> public static List <string> GetExtensions(string text) { // initial value List <string> extensions = new List <string>(); // If the text string exists if (TextHelper.Exists(text)) { // only use commas or semicolons char[] delimiterChars = { ',', ';' }; // Parse the words List <Word> words = WordParser.GetWords(text, delimiterChars); // if there are one or more words if (ListHelper.HasOneOrMoreItems(words)) { // Iterate the collection of Word objects foreach (Word word in words) { // Add this extension extensions.Add(word.Text); } } } // return value return(extensions); }
public override void Initialize(AnalysisContext analysisContext) { analysisContext.EnableConcurrentExecution(); analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); analysisContext.RegisterSymbolAction(context => { var field = (IFieldSymbol)context.Symbol; if (field.ContainingType == null || field.ContainingType.TypeKind != TypeKind.Enum || !WordParser.ContainsWord(field.Name, WordParserOptions.SplitCompoundWords, reservedWords)) { return; } // FxCop compat: only analyze externally visible symbols by default. if (!field.MatchesConfiguredVisibility(context.Options, Rule, context.CancellationToken)) { return; } context.ReportDiagnostic(field.CreateDiagnostic(Rule, field.ContainingType.Name, field.Name)); }, SymbolKind.Field); }
/// <summary> /// Returns True if the text has incorrect spelling. /// </summary> /// <param name="element"> /// The element containing the text we're checking. /// </param> /// <param name="text"> /// The text to check. /// </param> /// <param name="spellingError"> /// Returns a comma separated list of words encountered as spelling errors. /// </param> /// <returns> /// True if the text contains an incorrect spelling. /// </returns> private static bool TextContainsIncorectSpelling(CsElement element, string text, out string spellingError) { NamingService namingService = NamingService.GetNamingService(element.Document.SourceCode.Project.Culture); spellingError = string.Empty; if (namingService.SupportsSpelling) { WordParser parser = new WordParser(text, WordParserOptions.SplitCompoundWords); if (parser.PeekWord() != null) { ICollection <string> recognizedWords = element.Document.SourceCode.Project.RecognizedWords; string word = parser.NextWord(); do { // Ignore words starting and ending with '$'. // Ignore if in our recognized words list or correct spelling if ((word.StartsWith("$") && word.EndsWith("$")) || (recognizedWords.Contains(word) || IsSpelledCorrectly(namingService, word))) { continue; } if (!string.IsNullOrEmpty(spellingError)) { spellingError += ", "; } spellingError += word; }while ((word = parser.NextWord()) != null); } } return(!string.IsNullOrEmpty(spellingError)); }
public void TestUnderscoreCase1() { var result = WordParser.BreakWords("FIX_1"); Assert.AreEqual(2, result.Count); Assert.AreEqual("FIX", result [0]); Assert.AreEqual("1", result [1]); }
public void ParseAsyncは単語後のスペースを読み飛ばします() { var cursol = new Cursol("public "); var tested = new WordParser("public"); var result = tested.Parse(cursol); result.cursol.Index.Is(7); }
public void PopQuoteWord() { var words = new WordParser("one \"two bits\" three"); Assert.Equal("one", words.Pop()); Assert.Equal("two bits", words.Pop()); Assert.Equal("three", words.Pop()); Assert.Null(words.Pop()); }
public void ParseAsyncは指定していない単語を読み込みに失敗します() { var cursol = new Cursol("publi"); var tested = new WordParser("public"); var result = tested.Parse(cursol); result.isSuccess.IsFalse(); }
public void ParseAsyncは読み込みに成功した場合に単語の長さだけ進んだカーソルを返します() { var cursol = new Cursol("void"); var tested = new WordParser("void"); var result = tested.Parse(cursol); result.cursol.Index.Is(4); }
public void ParseAsyncは指定した単語を読み込みます() { var cursol = new Cursol("public"); var tested = new WordParser("public"); var result = tested.Parse(cursol); result.parsed.Is("public"); }
public void ParseAsyncは読み込みに失敗した場合には進んでいないカーソルを返します() { var cursol = new Cursol("publi"); var tested = new WordParser("public"); var result = tested.Parse(cursol); result.cursol.Index.Is(0); }
public void ParseAsyncは指定した単語を読み込みに成功します() { var cursol = new Cursol("public"); var tested = new WordParser("public"); var result = tested.Parse(cursol); result.isSuccess.IsTrue(); }
public void Pop() { var words = new WordParser("one two three"); Assert.Equal("one", words.Pop()); Assert.Equal("two", words.Pop()); Assert.Equal("three", words.Pop()); Assert.Null(words.Pop()); }
public void StartProcessTestMethod() { string testSentence = "Where are you, going today?"; string finalSentence = string.Empty; finalSentence = WordParser.start_Processing(testSentence); // Assert.AreSame("xyz", finalSentence); Assert.AreEqual("W3e a1e y1u, g3g t3y?", finalSentence); }
[InlineData("gubernātōrem", "short:2 long:3 long:2 long:2 long:3")] // gu.ˌber.naː.ˈtoː.rem public void GetSyllableTheory(string latin, string syllable) { var parser = new WordParser(); var word = parser.Parse(latin); new SyllableAnalyzer().Analyze(word); new AccentAnalyzer().Analyze(word); WordAssert.Field(word, "syllable", syllable); }
public void TestUnderscore() { var result = WordParser.BreakWords("some_Very_long_NAME"); Assert.AreEqual(4, result.Count); Assert.AreEqual("some", result [0]); Assert.AreEqual("Very", result [1]); Assert.AreEqual("long", result [2]); Assert.AreEqual("NAME", result [3]); }
public void TestCamelCaseWords() { var result = WordParser.BreakWords("someVeryLongName"); Assert.AreEqual(4, result.Count); Assert.AreEqual("some", result [0]); Assert.AreEqual("Very", result [1]); Assert.AreEqual("Long", result [2]); Assert.AreEqual("Name", result [3]); }
[InlineData("gubernātōrem", "initial:2 tonic:3 pre-tonic:2 tonic:2 final:3")] // gu.ˌber.naː.ˈtoː.rem public void GetAccentTheory(string latin, string accent) { var parser = new WordParser(); var word = parser.Parse(latin); new SyllableAnalyzer().Analyze(word); new AccentAnalyzer().Analyze(word); WordAssert.Field(word, "accent", accent); }
public void TestUpperCaseSubWord() { var result = WordParser.BreakWords("someVeryLongXMLName"); Assert.AreEqual(5, result.Count); Assert.AreEqual("some", result [0]); Assert.AreEqual("Very", result [1]); Assert.AreEqual("Long", result [2]); Assert.AreEqual("XML", result [3]); Assert.AreEqual("Name", result [4]); }
private void WordEvaluator(string _inputexpr, string _inputresult) { var tokens = Helper_ConvertStringToList(_inputexpr); int _index = 0; WordParser p = new WordParser(tokens, ref _index); var _actual = p.word.expression; var _expected = _inputresult; Assert.AreEqual(_expected, _actual); }
public void AnalyzeTheory(string graphical, string phonemic, string graphemic) { var analyzer = new WordParser(); var latinWord = analyzer.Parse(graphical); var phonemes = ParsePhonemic(phonemic); var graphemes = Core.Alignment.ParseIntervals(graphemic); Assert.Equal(phonemes, latinWord.Phonemes); Assert.Equal(graphemes, latinWord.GraphicalForms[0].Intervals); }
private static ValueValidator?GetValueValidator(string name) { foreach (var valueValidator in s_tokensToValueValidator) { if (WordParser.ContainsWord(name, WordParserOptions.SplitCompoundWords, valueValidator.AcceptedTokens)) { return(valueValidator); } } return(null); }
protected virtual void GenerateNewWord(Worker w) { List <char> bannedCharacters = new List <char>(); for (int i = 0; i < workers.Count; i++) { if (!workers[i].Fired && !string.IsNullOrEmpty(workers[i].CurrentWord)) { bannedCharacters.Add(workers[i].CurrentWord[0]); } } w.SetWord(WordParser.GetRandomWord(DifficultyManager.GetWordLength(), bannedCharacters.ToArray())); }
private static bool HasCorrectPrefix(ISymbol symbol, char prefix) { WordParser parser = new WordParser(symbol.Name, WordParserOptions.SplitCompoundWords, prefix); string firstWord = parser.NextWord(); if (firstWord == null || firstWord.Length > 1) { return(false); } return(firstWord[0] == prefix); }
static void Main(string[] args) { Console.WriteLine("Devis Machine Console"); Console.WriteLine("====================="); Console.WriteLine("Caching..."); Thread thread = new Thread(PreCacheParser <MockScope> .PreCache); thread.Priority = ThreadPriority.AboveNormal; thread.Start(); Console.WriteLine("Scope creation..."); MockScope scope = new MockScope { Id = 1, Text = "Hello World", FileName = "WordParser" }; for (int i = 0; i < 10; i++) { scope.List.Add(new ABC { Label = "Label" + i.ToString(), A = "A" + i.ToString(), B = "B" + i.ToString(), C = "C" + i.ToString() }); } while (true) { WordParser <MockScope> parser = new WordParser <MockScope>(scope); Console.WriteLine("Parsing..."); parser.Parse(); int nbCache = 0; if (Expression <MockScope> .Cache != null) { nbCache = Expression <MockScope> .Cache.Count; } Console.WriteLine("Mapping " + parser.Expressions.Count + " expression(s) with " + nbCache + " item(s) in cache"); parser.Map(); Console.WriteLine("Saving..."); parser.Save(); string fileName = Directory.GetCurrentDirectory() + "\\" + parser.TempFile; Console.WriteLine("Opening " + fileName); Process process = new Process(); process.StartInfo.FileName = fileName; process.Start(); if (parser.NbError > 0) { Console.WriteLine(parser.NbError + " ERROR(S)"); } Console.WriteLine("Press any key..."); Console.ReadKey(); Console.WriteLine(); } }
public void AddItems(int size) { NLBHT table = new NLBHT(new MultFunc((Math.Sqrt(5) - 1) / 2)); string fileLocation = "../../../wikiwords.txt"; var tuples = WordParser.ParseFromFile(fileLocation, numLines: size); foreach (var tuple in tuples) { table.Put(tuple.Item1, tuple.Item2); } // Assert.AreEqual(table.Count, 100); Console.WriteLine(table.TabSize); Console.WriteLine("Table load factor = {0}", table.LoadFactor); }
public static bool SymbolNameContainsUriWords(this ISymbol symbol, CancellationToken cancellationToken) { if (symbol.Name == null || !symbol.SymbolNameContainsUriWordSubstring(cancellationToken)) { // quick check failed return false; } string word; var parser = new WordParser(symbol.Name, WordParserOptions.SplitCompoundWords); while ((word = parser.NextWord()) != null) { if (s_uriWords.Contains(word)) { return true; } } return false; }