Word Segmentation for search keywords in the hubbledotnet example

Source: Internet
Author: User
Public String getkeywordanalyzerstringfromserver (string tablename, string fieldname, string keywords, int cachetimeout, out string byspace) {stringbuilder sb = new stringbuilder (); sb. appendformat ("Exec sp_fieldanalyze '{0}', '{1}', '{2}', 'sqlclient'", tablename. replace ("'", "'' "), fieldname. replace ("'", "'' "), keywords. replace ("'", "'' "); system. data. dataset dssp = new maticsoft. bll. job_job (). joblist (sb. tostring (); stringbuilder result = new stringbuilder (); stringbuilder byspacesb = new stringbuilder (); foreach (system. data. datarow row in dssp. tables [0]. rows) {string word = row ["word"]. tostring (). replace ("'", "'' "); byspacesb. appendformat ("{0}", word); result. appendformat ("{0} ^ {1} ^ {2}", word, row ["rank"], row ["position"]);} byspace = byspacesb. tostring (). trim (); return result. tostring (). trim ();}

 

Strkeyword = getkeywordanalyzerstringfromserver ("job_job_select", "jobtitle", keyword, Int. maxvalue, out wordssplitbyspace );

Word splitting table name and field (for example, pangu for title and English for content). If you enter the title, the score is pangu, and the score for content is English, because different fields may have different word Divider

) Keywords to be segmented

 

If you want to precisely search words, such as advanced user inputProgramMember Lenovo China is displayed only when there are senior programmers and Lenovo In the title

Just change the foreach above.

 Foreach (System. Data. datarow row In Table. Rows)
{
String WORD = string. empty;
If (Table. Rows. Count>1 )
{
WORD = row [ " Word " ]. Tostring (). Replace ( " ' " , " '' " );
Byspacesb. appendformat ( " {0} " , Word );
Result. appendformat ( " {0} ^ {1} ^ {2} ^ 0 " , Word, row [ " Rank " ], Row [ " Position " ]);
}
Else
{
WORD = row [ " Word " ]. Tostring (). Replace ( " ' " , " '' " );
Byspacesb. appendformat ( " {0} " , Word );
Result. appendformat ( " {0} ^ {1} ^ {2} ^ 1 " , Word, row [ " Rank " ], Row [ " Position " ]);
}

}

You can see the result. appendformat ("{0} ^ {1} ^ {2} ^ 1", word, row ["rank"], row ["position"]); if one parameter is added, the value 0 indicates that the parameter is equal to 1 or

Note: this parameter is valid only when the search is contains and the match parameter is invalid.

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.