private void button3_Click(object sender, EventArgs e) { label4.Text = ""; Stopwatch sw = new Stopwatch(); listBox2.Items.Clear(); string aranan = textBox1.Text; string text; dosyauzantisi = ".docx"; ComponentInfo.SetLicense("FREE-LIMITED-KEY"); var document = new DocumentModel(); document = DocumentModel.Load(@"C:\Users\raman\Desktop\Osman\kelime-listesi-turkce.docx"); text = document.Sections[0].Blocks.Cast <Paragraph>(0).Inlines.Cast <Run>(0).Text; sw.Start(); BruteForce(aranan, text); sw.Stop(); Spelling spelling = new Spelling(); string word = ""; word = textBox1.Text; if (word != spelling.Correct(word)) { linkLabel1.Text = spelling.Correct(word); } if (listBox2.Items.Count != 0) { label4.Text += listBox2.Items.Count + " adet sonuç " + sw.ElapsedMilliseconds.ToString() + " milisaniyede bulunmuştur"; } }
private void button2_Click(object sender, EventArgs e) { label4.Text = ""; Stopwatch sw = new Stopwatch(); listBox2.Items.Clear(); dosyauzantisi = ".html"; string aranan = textBox1.Text; sw.Start(); dosyadanOku(aranan, dosyauzantisi); sw.Stop(); Spelling spelling = new Spelling(); string word = ""; word = textBox1.Text; if (word != spelling.Correct(word)) { linkLabel1.Text = spelling.Correct(word); } if (listBox2.Items.Count != 0) { label4.Text += listBox2.Items.Count + " adet sonuç " + sw.ElapsedMilliseconds.ToString() + " milisaniyede bulunmuştur"; } }
public void should_correct_single_words(string mispelled, string expected) { // Arrange var spelling = new Spelling(_dictionary); // Act string actual = spelling.Correct(mispelled); // Assert Assert.AreEqual(expected, actual); }
static void Main(string[] args) { Spelling spelling = new Spelling(); string word = ""; word = "speling"; Console.WriteLine("{0} => {1}", word, spelling.Correct(word)); word = "korrecter"; // 'correcter' is not in the dictionary file so this doesn't work Console.WriteLine("{0} => {1}", word, spelling.Correct(word)); word = "korrect"; Console.WriteLine("{0} => {1}", word, spelling.Correct(word)); word = "acess"; Console.WriteLine("{0} => {1}", word, spelling.Correct(word)); word = "supposidly"; Console.WriteLine("{0} => {1}", word, spelling.Correct(word)); // A sentence string sentence = "I havve speled thes woord wwrong"; // sees speed instead of spelled (see notes on norvig.com) string correction = ""; foreach (string item in sentence.Split(' ')) { correction += " " + spelling.Correct(item); } Console.WriteLine("Did you mean:" + correction); Console.Read(); }
static void Main(string[] args) { GetAppSettings settings = new GetAppSettings(); Console.WriteLine(settings.GetSetting("Test")); Spelling spelling = new Spelling(); string word = ""; word = "PORK"; Console.WriteLine("{0} => {1}", word, spelling.Correct(word)); word = "FUU"; // 'correcter' is not in the dictionary file so this doesn't work Console.WriteLine("{0} => {1}", word, spelling.Correct(word)); word = "LAMM"; Console.WriteLine("{0} => {1}", word, spelling.Correct(word)); word = "PAINT"; Console.WriteLine("{0} => {1}", word, spelling.Correct(word)); word = "ETAE"; Console.WriteLine("{0} => {1}", word, spelling.Correct(word)); // A sentence string sentence = "I havve speled thes woord wwrong"; // sees speed instead of spelled (see notes on norvig.com) string correction = ""; foreach (string item in sentence.Split(' ')) { correction += " " + spelling.Correct(item); } Console.WriteLine("Did you mean:" + correction); Enumerable.Range(Convert.ToInt32('A'), 26).Union(Enumerable.Range(Convert.ToInt32('0'), 10)).ToList(). ForEach(e => Console.WriteLine(Convert.ToChar(e))); Console.WriteLine($"{DuoVia.FuzzyStrings.StringExtensions.FuzzyMatch("HONG", "HONG")}"); Console.WriteLine($"{DuoVia.FuzzyStrings.StringExtensions.FuzzyMatch("HOONG", "HONG")}"); Console.WriteLine($"{DuoVia.FuzzyStrings.StringExtensions.FuzzyMatch("HOONG", "HSOUNG")}"); Console.WriteLine($"{DuoVia.FuzzyStrings.StringExtensions.FuzzyMatch("HOONG", "HSIN")}"); Console.WriteLine($"{DuoVia.FuzzyStrings.StringExtensions.FuzzyMatch("Hello Wor1ld3", "Hello Warl12d3")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.JaccardDistance("Hello World", "Hello World")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.JaccardDistance("Hello World", "Hello Warld")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.JaccardDistance("Hello World", "Hello Warl12d3")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.JaccardDistance("Hello Wor1ld3", "Hello Warl12d3")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.HammingDistance("Hello World", "Hello World")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.HammingDistance("Hello World", "Hello Warld")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.HammingDistance("Hello World", "Hello Warl12d3")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.HammingDistance("Hello Wor1ld3", "Hello Warl12d3")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.SorensenDiceDistance("Hello World", "Hello World")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.SorensenDiceDistance("Hello World", "Hello Warld")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.SorensenDiceDistance("Hello World", "Hello Warl12d3")}"); Console.WriteLine($"{FuzzyString.ComparisonMetrics.SorensenDiceDistance("Hello Wor1ld3", "Hello Warl12d3")}"); Console.WriteLine("Hello World".DiceCoefficient("Hello World")); Console.WriteLine("Hello World".DiceCoefficient("Hello Warld")); Console.WriteLine("Hello World".DiceCoefficient("Heo Warl12d3")); Console.WriteLine("Hello World".DiceCoefficient("Hello Warl12d3")); StringTrie <string> Trie = new StringTrie <string>(); Trie.Add("ABC", "ABC"); Trie.Add("ABCDEF", "ABCDEF"); Trie.Add("FGHIJK", "FGHIJK"); Trie.Add("KKK", "KKK"); Trie.Add("LLLLL", "LLLLL"); Trie.Add("LLLLLT", "LLLLLT"); Trie.Add("Tai Po", "Tai Po"); Trie.Add("Tai Po ABC", "Tai Po ABC"); Trie.Add("Tai Po ABC DEF", "Tai Po ABC DEF"); Trie.Add("Tai Po XXX", "Tai Po XXX"); Trie.Add("Tai Po YYY", "Tai Po YYY"); TraverseTrie(Trie, n => { Console.WriteLine($"Node: {n.Value}"); }, lf => { Console.WriteLine($"Leaf: *****"); }); var node = Trie.Find("Tai Po A"); Console.WriteLine(node.IsLeaf + " " + node.HasValue); Console.WriteLine("*************************"); node.Descendants.ToList().ForEach(e => { if (e.HasValue) { Console.WriteLine(e.Value); } }); Console.WriteLine("*************************"); node = Trie.Find("Tai Po AB"); Console.WriteLine(node.IsLeaf + " " + node.HasValue); node = Trie.Find("Tai Po ABC"); Console.WriteLine(node.IsLeaf + " " + node.HasValue); List <string> l = new List <string>(); l.Add(""); l.Add(null); l.Add("Hello World"); foreach (var ll in l) { if (string.IsNullOrEmpty(ll)) { continue; } Console.WriteLine(ll); } var s = "([([}) [] A [] [] Test ]]]]] "; Console.WriteLine(s.Replace('(', Convert.ToChar(32)).Replace(')', Convert.ToChar(32)).Replace('[', Convert.ToChar(32))); /* * FileStream fs = new FileStream(@"C:\Temp\TestAddr.csv", FileMode.Open, FileAccess.Read); * var reader = new CsvReader(new StreamReader(fs)); * reader.ReadHeader(); * int i = 0; * while (reader.Read()) * { * var addr = reader.GetRecord<Addr>(); * Console.WriteLine(addr); * if (i++ >= 10) * break; * } * var p = System.IO.Path.GetTempPath(); */ var r = "A".CompareTo("B"); var cm = new CodeMappings(); HashSet <int> hs = new HashSet <int>(); hs.Add(1); hs.Add(2); hs.Add(1); hs.Add(2); hs.Add(3); foreach (var x in hs) { Console.WriteLine(x); } Console.WriteLine("First Result Set ******************************************************************************"); var res1 = LCSFinder.GetLCS("A B C D E F G H", "A B C D U V Y K"); var res2 = LCSFinder.GetLCS("A B C D E F G H", "A I B T C O D L"); Console.WriteLine(res1); Console.WriteLine(res2); Console.WriteLine("Second Result Set ******************************************************************************"); var res3 = LCSFinder.GetLCS("AA BB CC DDD EE FFFF GG H", "AA XXXX BDB YYYYYY CC DD123DD U EE V Y K"); var res4 = LCSFinder.GetLCS("AA BB CC DDD EE FFFF GG H", "AA I BB T CC OXXXXX DDD L EE"); Console.WriteLine(res3); Console.WriteLine(res4); Console.WriteLine("Third Result Set ******************************************************************************"); var res5 = LCSFinder.GetLCS("AA BB CC DD E F G", "AA BB CC BB II CC KK DD H I K"); var res6 = LCSFinder.GetLCS("AA BB CC DD E F G", "AA BB CCCC DD II E A F B G"); Console.WriteLine(res5); Console.WriteLine(res6); Console.WriteLine("******************************************************************************"); Console.WriteLine("First Result Set ******************************************************************************"); var resX = "A B C D E F G H".LongestCommonSubsequence("A B C D U V Y K"); var resY = "A B C D E F G H".LongestCommonSubsequence("A I B T C O D L"); Console.WriteLine(resX); Console.WriteLine(resY); Console.WriteLine("Second Result Set ******************************************************************************"); var resA = "AA BB CC DDD EE FFFF GG H".LongestCommonSubsequence("AA XXXX BDB YYYYYY CC DD123DD U EE V Y K"); var resB = "AA BB CC DDD EE FFFF GG H".LongestCommonSubsequence("AA I BB T CC OXXXXX DDD L EE"); Console.WriteLine(resA); Console.WriteLine(resB); Console.WriteLine("Third Result Set ******************************************************************************"); var resC = "AA BB CC DD E F G".LongestCommonSubsequence("AA BB CC BB II CC KK DD H I K"); var resD = "AA BB CC DD E F G".LongestCommonSubsequence("AA BB CCCC DD II E A F B G"); Console.WriteLine(resC); Console.WriteLine(resD); Console.WriteLine("******************************************************************************"); Console.WriteLine("1 Result Set ******************************************************************************"); var r1 = "ABCDEFGH".LongestCommonSubsequence("ABCDUVYK"); var r2 = "ABCDEFGH".LongestCommonSubsequence("AIBTCODL"); Console.WriteLine(r1); Console.WriteLine(r2); Console.WriteLine("2 Result Set ******************************************************************************"); var r3 = "AABBCCDDDEEFFFFGGH".LongestCommonSubsequence("AAXXXXBDBYYYYYYCCDD123DDUEEVYK"); var r4 = "AABBCCDDDEEFFFFGGH".LongestCommonSubsequence("AAIBBTCCOXXXXXDDDLEE"); Console.WriteLine(r3); Console.WriteLine(r4); Console.WriteLine("3 Result Set ******************************************************************************"); var r5 = "AABBCCDDEFG".LongestCommonSubsequence("AABBCCBBIICCKKDDHIK"); var r6 = "AABBCCDDEFG".LongestCommonSubsequence("AABBCCCCDDIIEAFBG"); Console.WriteLine(r5); Console.WriteLine(r6); Console.WriteLine("******************************************************************************"); Console.WriteLine("4 Result Set ******************************************************************************"); var r7 = "SUN FUNG WAI".LongestCommonSubsequence("SAN FUNG WAI"); var r8 = "SUN FUNG WAI".LongestCommonSubsequence("SAN WAI COURT"); Console.WriteLine(r7); Console.WriteLine(r8); Console.WriteLine("******************************************************************************"); Enumerable.Range(1, 20).ToList().ForEach(e => { var rA = ToRoman(e); var sA = ConvertRomanToNumber(rA); Console.WriteLine($"{rA}->{sA}"); }); MainStore ms = new MainStore(); ms.Serialize(@"C:\Temp\tt.json"); List <StreetNoExpansion> stl = new List <StreetNoExpansion>() { new StreetNoExpansion(13, "A", 13, "A"), //0 new StreetNoExpansion(13, "L", 14, "L"), //1 new StreetNoExpansion(13, "L", 17, "L"), //2 new StreetNoExpansion(13, "L", 20, "L"), //3 new StreetNoExpansion(13, "L", 14, "M"), //4 new StreetNoExpansion(12, "", 12, ""), //5 new StreetNoExpansion(12, "A", 12, "A"), //6 new StreetNoExpansion(12, "", 19, ""), //7 new StreetNoExpansion(12, "", 20, ""), //8 new StreetNoExpansion(12, "", 12, ""), //9 new StreetNoExpansion(12, "", 13, ""), //10 new StreetNoExpansion(12, "A", 12, "B"), //11 new StreetNoExpansion(14, "D", 21, "S"), //12 new StreetNoExpansion(15, "A", 17, ""), //13 new StreetNoExpansion(15, "A", 29, ""), //14 new StreetNoExpansion(15, "B", 16, ""), //15 new StreetNoExpansion(15, "C", 15, ""), //16 new StreetNoExpansion(16, "", 17, "B"), //17 new StreetNoExpansion(16, "", 18, "B"), //18 new StreetNoExpansion(16, "", 16, "B"), //19 new StreetNoExpansion(16, "", 20, "D"), //20 new StreetNoExpansion(16, "A", 17, ""), //21 new StreetNoExpansion(16, "B", 18, ""), //22 new StreetNoExpansion(16, "C", 16, ""), //23 new StreetNoExpansion(16, "D", 20, ""), //24 new StreetNoExpansion(3, "EA3", 3, "EA3"), //25 new StreetNoExpansion(3, "A", 0, ""), //26 new StreetNoExpansion(3, "", 0, ""), //27 }; stl.ForEach(e => Console.WriteLine(e)); var line = ""; while (!string.IsNullOrEmpty(line = Console.ReadLine())) { Console.Write(">"); if (!ConvertStreetNoFromStringToComponents(line, out int from, out string fromA, out int to, out string toA)) { Console.WriteLine("Conversion Failed"); continue; } int idx = 0; stl.ForEach(e => { Console.WriteLine($"{idx++}->{e.MatchStreetNo(from, fromA, to, toA)}"); }); } }
// Corrects a given course name or course code and returns the corrected version. public string Correct(string query) { return(spelling.Correct(query)); }