public void SoundexTest() { string s1 = Soundex.For("Jansen"); string s2 = Soundex.For("Jenssen"); Assert.AreEqual(s1, s2); }
public static int SoundExComparision(Person person) { string[] Words = new[] { "Spotify", "amal", "Sputfy", "Sputfi" }; int val = 0; //MatchRatingApproach _generator = new MatchRatingApproach(); //Console.WriteLine(_generator.IsSimilar(Words)); if (Soundex.For(person.FirstName) == Soundex.For(fName)) { val = val + 1; } if (Soundex.For(person.LastName) == Soundex.For(LName)) { val = val + 1; } else { val = val + 0; } return(val); }
private static string GetSoundexCode(string text) { if (text == null) { return(null); } return(Soundex.GetCode(text)); }
private static bool SoundsLike(string left, string right) { if (left == null || right == null) { return(false); } return(Soundex.GetCode(left) == Soundex.GetCode(right)); }
private bool checkForWord(string word) { while (true) { if (rawWords.Any(x => Soundex.Generate(word) == Soundex.Generate(x.Word))) { return(true); } } }
private bool checkForCommand(string word, int applicationId) { while (true) { if (processedWords.Any(x => Soundex.Generate(word) == Soundex.Generate(x.Word) && x.WordType == VoiceWord.wordType.ApplicationCommand && x.ApplicationIdCommand == applicationId)) { return(true); } } }
private void cmdSoundex2_Click(object sender, EventArgs e) { var msg = Soundex.Encode(txtSecondText.Text.Trim()); MessageBox.Show(msg); var phonetic = new PhoneticMatch(); var pMsg = phonetic.CreateToken(txtSecondText.Text.Trim()); MessageBox.Show(pMsg); }
public bool wordWasSaid(string word) { if (rawWords.Any(x => Soundex.Generate(word) == Soundex.Generate(x.Word))) { return(true); } else { return(false); } }
public bool commandWasSaid(string command, int applicationId) { if (processedWords.Any(x => Soundex.Generate(command) == Soundex.Generate(x.Word) && x.WordType == VoiceWord.wordType.ApplicationCommand && x.ApplicationIdCommand == applicationId)) { return(true); } else { return(false); } }
public override bool IncrementToken() { if (input.IncrementToken()) { string currentTerm = _termAttr.Term; // Any phonetic hash calculation will work here. var hash = Soundex.For(currentTerm); _termAttr.SetTermBuffer(hash); return(true); } return(false); }
private List <VoiceWord> getCommandMessage(string word, int applicationId) { var command = processedWords.Where(x => Soundex.Generate(word) == Soundex.Generate(x.Word) && x.WordType == VoiceWord.wordType.ApplicationCommand && x.ApplicationIdCommand == applicationId).FirstOrDefault(); if (command != null) { var message = rawWords.Where(x => x.MessageId == command.MessageId).ToList(); return(message); } else { return(null); } }
private List <VoiceWord> getWordMessage(string word, int applicationId) { var requestedWord = rawWords.Where(x => Soundex.Generate(word) == Soundex.Generate(x.Word)).FirstOrDefault(); if (requestedWord != null) { var message = rawWords.Where(x => x.MessageId == requestedWord.MessageId).ToList(); return(message); } else { return(null); } }
public static SqlString LongPhonetic(SqlInt16 PhoneticType, SqlString InputString) { BasePhonetics PhoneticObject; string _inputString; if (InputString.IsNull || InputString.Value.Trim() == String.Empty) { _inputString = " "; } else { _inputString = InputString.Value; } switch (PhoneticType.Value) { case 0: PhoneticObject = new Soundex(_inputString); break; case 1: PhoneticObject = new RefinedSoundex(_inputString); break; case 2: PhoneticObject = new NYSIIS(_inputString); break; case 3: PhoneticObject = new DaitchMokotoff(_inputString); break; case 4: PhoneticObject = new Metaphone(_inputString); break; case 6: PhoneticObject = new ColognePhonetic(_inputString); break; default: PhoneticObject = new Soundex(_inputString); PhoneticType = 0; break; } PhoneticObject.Iterate(); return(PhoneticObject.ReadOutput()); }
static void Main(string[] args) { Soundex snd = new Soundex("Riya"); Soundex snd1 = new Soundex("Ria"); Soundex snd2 = new Soundex("Rajeev"); Soundex snd3 = new Soundex("Rajiv"); Soundex snd6 = new Soundex("Pascal"); Soundex snd7 = new Soundex("Pascul"); Soundex snd8 = new Soundex("Sanket"); Soundex snd9 = new Soundex("Sunket"); Soundex snd10 = new Soundex("Sankat"); Console.WriteLine("Soundex For Riya :" + snd.IN_Soundex + " Soundex For Ria :" + snd1.IN_Soundex); //Matches Console.WriteLine("Soundex For Rajeev :" + snd2.IN_Soundex + " Soundex For Rajivv :" + snd3.IN_Soundex); //Matches Console.WriteLine("Soundex For Pascal :" + snd6.IN_Soundex + " Soundex For Pascul :" + snd7.IN_Soundex); //Matches Console.WriteLine("Soundex For Sanket :" + snd8.IN_Soundex + " Soundex For Sunket :" + snd9.IN_Soundex); //Matches Console.WriteLine("Soundex For Sanket :" + snd8.IN_Soundex + " Soundex For Sunkat :" + snd10.IN_Soundex); //Doesn't Match Console.WriteLine(""); while (true) { Console.WriteLine("Insert Name To calulate Soundex: "); string name = ""; name = Console.ReadLine(); if (String.IsNullOrEmpty(name.Trim()) || name.Trim() == "13") { Console.WriteLine("Insert Some Text To calulate Soundex: "); name = Console.ReadLine(); } else { Soundex result = new Soundex(name); Console.WriteLine("Soundex For The text \" " + name + " \": " + result.IN_Soundex); string cont = ""; Console.WriteLine("Do you want to continue... Press Y/y to countinue: "); cont = Console.ReadLine(); if (cont.ToUpper().Trim() != "Y") { break; } } } Console.WriteLine("Press any key to exit...."); Console.ReadKey(); }
public void ForTests() { Soundex soundex = new Soundex(); string word, expected, actual; word = ""; expected = "0000"; actual = soundex.For(word); Assert.AreEqual(expected, actual); word = null; expected = "0000"; actual = soundex.For(word); Assert.AreEqual(expected, actual); word = "Robert"; expected = "R163"; actual = soundex.For(word); Assert.AreEqual(expected, actual); word = "Rupert".ToLower(); actual = soundex.For(word); Assert.AreEqual(expected, actual); word = "Rubin"; expected = "R150"; actual = soundex.For(word); Assert.AreEqual(expected, actual); word = "Ashcraft"; expected = "A261"; actual = soundex.For(word); Assert.AreEqual(expected, actual); word = "Ashcroft"; actual = soundex.For(word); Assert.AreEqual(expected, actual); word = "Tymczak"; expected = "T522"; actual = soundex.For(word); Assert.AreEqual(expected, actual); word = "Pfister"; expected = "P236"; actual = soundex.For(word); Assert.AreEqual(expected, actual); }
public CheakSpell() { try { _globalDic = new List <string>(); _userDic = new List <string>(); _ignoreList = new List <string>(); _stopWordList = new List <string>(); _ignoreCharList = new List <char>(); var persianWordFrequencyOpration = new PS_PersianWordFrequencyOpration(); //load from DB var listParsianWordfreq = persianWordFrequencyOpration.GetAll(); _sundex = new Soundex(listParsianWordfreq.Where(x => x.Sundex.Length > 0).ToList()); _norvan = new NorvigSpellChecker(listParsianWordfreq); _stemmr = new Stemmer(listParsianWordfreq); foreach (var item in listParsianWordfreq) { _globalDic.Add(item.Val1.Trim()); } var lsStop = new PS_StopWordOpration(); foreach (var item in lsStop.GetAll()) { _stopWordList.Add(item.Val1.Trim()); } var userDicOpration = new UserDicOpration(); _userDic = userDicOpration.LoadAll(); } catch (Exception) { // ignored } }
private bool compareWords(WordGuess firstWordGuess, WordGuess secondWordGuess) { var firstWordModel = new WordModel { Word = firstWordGuess.Word.ToLower().Trim() }; var secondWordModel = new WordModel { Word = secondWordGuess.Word.ToLower().Trim() }; var stringArray = new string[] { firstWordModel.Word, secondWordModel.Word }; var metaphone = new Metaphone(); var soundex = new Soundex(); var similarMetaphone = metaphone.IsSimilar(stringArray); var similarSoundex = soundex.IsSimilar(stringArray); return(similarMetaphone || similarSoundex); }
public static bool MISTpassed( string question, bool answer, string server_name, string database_name, string user_name, string password, string table_name) { bool passed = false; int hash = GetHashCode(question); if ((server_name == "") || (server_name == null)) { server_name = "localhost"; } string connection_str = "server=" + server_name + ";" + "database=" + database_name + ";" + "uid=" + user_name + ";" + "password="******";"; string Query = "SELECT * FROM " + table_name + " WHERE Hash = " + hash.ToString() + ";"; int YesVotes = 0; int NoVotes = 0; Guid best_result = Guid.Empty; ArrayList pixels = RunMySqlCommand(Query, connection_str, 5); if (pixels.Count > 0) { char[] template = Soundex.ToSoundexCode(question).ToCharArray(); int max_score = -1; // update existing pixel for (int ctr = 0; ctr < pixels.Count; ctr++) { ArrayList row = (ArrayList)pixels[ctr]; string result_question = (string)row[2]; char[] s = Soundex.ToSoundexCode(result_question).ToCharArray(); int score = 0; for (int i = 0; i < s.Length; i++) { score += Math.Abs((int)s[i] - (int)template[i]); } if (score > max_score) { best_result = (Guid)row[0]; max_score = score; YesVotes = Convert.ToInt32(row[3]); NoVotes = Convert.ToInt32(row[4]); } } if (best_result != Guid.Empty) { // update the mindpixel coherence float coherence = YesVotes / (float)(YesVotes + NoVotes); if ((answer == true) && (coherence >= 0.5)) { passed = true; } if ((answer == false) && (coherence < 0.5)) { passed = true; } } } return(passed); }
public void CombinesDuplicateEncodingsSeparatedByHOrW() { Assert.AreEqual("J100", Soundex.EncodeToSoundex("Jbwb")); }
public void CombinesDuplicateCodesWhen2ndLetterDuplicates1st() { Assert.AreEqual("B230", Soundex.EncodeToSoundex("Bbcd")); }
public void DoesNotCombineDuplicateEncodingsSeparatedByVowels() { Assert.AreEqual("J110", Soundex.EncodeToSoundex("Jbob")); }
public void ReplacesConsonantsWithAppropriateDigitsIgnoresCase() { Assert.AreEqual("B234", Soundex.EncodeToSoundex("BCDL")); }
public void CombinesDuplicateEncodings() { Assert.AreEqual("G123", Soundex.EncodeToSoundex("Gbfcgdt")); }
public void IgnoresVowelLikeLetters() { Assert.AreEqual("C123", Soundex.EncodeToSoundex("CAaEeIiOoUuHhYybcd")); }
public void LimitsLengthToFourCharacters() { Assert.AreEqual("D123", Soundex.EncodeToSoundex("Dbcdlmr")); }
public void ReplacesThreeConsonantsWithAppropriateDigits() { Assert.AreEqual("A256", Soundex.EncodeToSoundex("Ajmr")); }
public void ReplacesTwoConsonantsWithAppropriateDigits() { Assert.AreEqual("A340", Soundex.EncodeToSoundex("Adl")); }
public static bool MISTpassedInterpolated( string question, bool answer, string server_name, string database_name, string user_name, string password, string table_name, int image_width, float[] coherence, int no_of_records) { bool passed = false; string index_ngram3 = phoneme.ToNgramStandardised(question, 3, false); string standardised_index_primary = "", standardised_index_secondary = ""; //Metaphone.ToMetaphoneStandardised(question, false, ref standardised_index_primary, ref standardised_index_secondary); //string index_metaphone = standardised_index_primary; string index_soundex = Soundex.ToSoundexStandardised(question, false, false); string index_verbs = verbs.GetVerbClasses(question); float coordinate_ngram3 = GetNgramIndex(index_ngram3, 80); float coordinate_soundex = GetNgramIndex(index_soundex, 80); float coordinate_verbs = GetNgramIndex(index_verbs, 80); //float coordinate_metaphone = GetNgramIndex(index_metaphone, 80); if ((server_name == "") || (server_name == null)) { server_name = "localhost"; } string connection_str = "server=" + server_name + ";" + "database=" + database_name + ";" + "uid=" + user_name + ";" + "password="******";"; string Query = "SELECT Hash,Ngram3 FROM " + table_name + " WHERE Ngram3 < " + coordinate_ngram3.ToString() + " ORDER BY Ngram3;"; ArrayList pixels = RunMySqlCommand(Query, connection_str, 2); int index_x = pixels.Count * image_width / no_of_records; Query = "SELECT Hash,Soundex FROM " + table_name + " WHERE Soundex < " + coordinate_soundex.ToString() + " ORDER BY Soundex;"; pixels = RunMySqlCommand(Query, connection_str, 2); int index_y = pixels.Count * image_width / no_of_records; Query = "SELECT Hash,verbs FROM " + table_name + " WHERE verbs < " + coordinate_verbs.ToString() + " ORDER BY verbs;"; pixels = RunMySqlCommand(Query, connection_str, 2); int index_z = pixels.Count * 3 / no_of_records; int n = (((index_y * image_width) + index_x) * 3) + index_z; float prob = LogOddsToProbability(coherence[n]); if (prob >= 0.5) { Console.WriteLine("System says YES"); } else { Console.WriteLine("System says NO"); } if (answer == true) { if (prob >= 0.5) { passed = true; } } else { if (prob < 0.5) { passed = true; } } return(passed); }
public void ReplacesConsonantCWithDigit2() { Assert.AreEqual("A200", Soundex.EncodeToSoundex("Ac")); }
public void UppercasesFirst() { Assert.AreEqual("A123", Soundex.EncodeToSoundex("abcd")); }