Hi,
I want sample sode for stemming txt file using stemming algorithem in c# windows or Asp.net.
Stemming means,If i enter "playing cicket" the algorithen return
"play","cricket"
it remove ing ,ed,and join words etc.
some example
watched->watch
crying->cry
dangerous->danger

Bechir BejaouiRank #144 · 15.9K reputationPosted Feb 11, 2009, 11:47 AM EST
Posted Feb 11, 2009, 6:36 PM EST
Hi,
Stemming means,If i enter "playing cicket" the algorithen return
"play","cricket"
it remove ing ,ed,and join words etc.
some example
watched->watch
crying->cry
dangerous->danger
Bechir BejaouiRank #144 · 15.9K reputationPosted Feb 12, 2009, 12:02 AM EST
First you add the namespace
System.Text.RegularExpressions
Then you have to stock all suffixes within a data base or a table. I put them in an array to simplify the issue. Then you retrive all sufixes in a list. You retrieve also all targeted words in a list here an example of what to do exactly:
string[] instances = {"hopeless","powerful","freedom"};
string[] suffixes = { "less", "ful", "dom" };
string result = "";
foreach (string instance in instances)
{
foreach (string suffix in suffixes)
{
if (Regex.IsMatch(instance, suffix))
{
result = Regex.Replace(instance, suffix, "", RegexOptions.None);
Console.WriteLine(result);
}
}
}
Console.WriteLine("The job is done");
Console.Read();
MHD Fawaz Enaya2 reputationPosted Mar 10, 2009, 9:54 AM EDT
http://tartarus.org/~martin/PorterStemmer/