C # Chinese Word Segmentation Algorithm: chineseanalyzer

Source: Internet
Author: User
C # Chinese Word Segmentation Algorithm : Chineseanalyzer.

 

First, we need to reference the two dll library files Lucene. net. dll + Lucene. China. dll, which will be packaged at the end of this article and debugged using vs2008:

 

Using Lucene. net;
Using Lucene. net. analysis;
Using Lucene. China;

 

----------

 

Example:

 

Private void button#click (Object sender, eventargs E)
{
Stringbuilder sb = new stringbuilder ();
SB. Remove (0, SB. Length );
String T1 = "";
Int I = 0;
Analyzer analyzer = new Lucene. China. chineseanalyzer ();
Stringreader sr = new stringreader (richtextbox1.text );
Tokenstream stream = analyzer. tokenstream (null, Sr );

Long begin = system. datetime. Now. ticks;
Token T = stream. Next ();
While (T! = NULL)
{
T1 = T. tostring (); // display format: (keyword,), to be processed
T1 = t1.replace ("(","");
Char [] separator = {','};
T1 = t1.split (separator) [0];

SB. append (I + ":" + t1 + "\ r \ n ");
T = stream. Next ();
I ++;
}
Richtextbox2.text = sb. tostring ();
Long end = system. datetime. Now. ticks; // 100 milliseconds
Int time = (INT) (end-begin)/10000); // MS

 

Richtextbox2.text + = "Time consumed" + (time) + "Ms \ r \ n ==================================== \ r \ n ";
}

 

As follows:

 

:
Chinese Word Segmentation Algorithm: chineseanalyzer.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.