English 中文(简体)
在C#中利用reg子对复数进行校对
原标题:Matching plurals using regex in C#

我期望在C#中使用reg,以寻找术语,我想将这些术语的复数列入搜索。 例如,如果用户想要寻找管道,那么我也希望把结果归还给管道。

So I can do this...

string s ="\b" + term + "s*\b";
if (Regex.IsMatch(bigtext, s) {  /* do stuff */ }

我将如何修改上述内容,以便让我在用户进入压力和仍然为管道/管道工作时作出相应的强调?

最佳回答

这里是为消除复数而设立的一个管理机构:

 /(?<![aei])([ie][d])(?=[^a-zA-Z])|(?<=[ertkgwmnl])s(?=[^a-zA-Z])/g

(

我知道这并不是你所需要的,而是可以帮助你找到一些东西。

问题回答

您可以面临的问题是,有许多不正规的禁区,例如<条码>man<>/条码>、<条码>、<条码>和<条码>。 Pluralizationservice/code><><>>http://msdn.microsoft.com/en-us/library/system.data.entity. Design.pluralizationservices.pluralizationservices.plcomplicize_03.aspx> 在这里,是显示如何使用该产品的一个例子。

在你获得该词的复数之后,你可以很容易地建造一个可以搜索复数或单数词的雷管。

PluralizationService ps = PluralizationService.CreateService(CultureInfo.CurrentCulture);
string plural = ps.Pluralize(term);
string s = @"("+term+"|"+plural+")";
if (Regex.IsMatch(bigtext, s)) {
    /* do stuff */
}

如果你使用Kingk服务器作为你的后台,你会利用Sperex。 我对你试图寻找的东西感到不安。 我假定,你正试图以搜索投入来创造充满活力的飞跃。 如果没有,我认为,有适当的准则。

EDIT:我的立场得到纠正,似乎有一些利克实体可以做些什么去做。

However, MSDN does have a soundex example, which for the simple tests I ran this morning seems to do fine as far as what I tested. http://msdn.microsoft.com/en-us/library/bb669073.aspx

我所作的改动不是使用ToUpper (invariant) i 。

这方面的一个例子是我所经历的情况。

List<string> animals = new List<string>();
animals.Add("dogs");
animals.Add("dog");
animals.Add("cat");
animals.Add("rabbits");
animals.Add("doggie");

string dog = "dog";
var data = from animal in animals
where animal.SoundEx() == dog.SoundEx()
select animal;

数据:狗、狗、狗

现在使用服务器,使用孔隙/自由Text/ContainsTable等,并使用Latlog(我不熟悉LQ服务器的新版本——回到2000年所使用的执行方式),你也可以把结果排在首位。

Also if you have the ability to use sql server you may want to look into this option: LINQ to SQL SOUNDEX - possible?

对多元化解决方案的关切,你必须能够利用4.Net。

还有一个可能有用的Levenshtein远程算法。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...