(5) [integration] machine learning-based hotel comment text trend analysis

Source: Internet
Author: User

Hotel comment sentiment analysis system (5 )--

[Integration] Analysis of hotel comment text trend based on machine learning

This article mainly integrates the sections described in section 3 and section 4.

Process:

For the comments text entered on the GUI, perform Chinese Word Segmentation and deprecated words first, and then classify them by "environment, price, hygiene, and service". At the same time, call dynamiclmclassifier in lingpipe, to learn the labeled "Chinese sentiment mining hotel comment corpus" library and construct a classifier for basic polarity analysis. Finally, this classifier is used to give an overall evaluation of the entire comment text and an emotional evaluation of the four aspects respectively.

Environment:

1. Operating System: Windows 7, x86, 32-bit

2. Java jdk1.6

3. lingpipe4.1

4. eclipse3.4

5. netbeans6.9

6. Chinese word segmentation tool: ictclas4j

 

Project running illustration:

Results of classification by four aspects:

 

The above classification results can be inferred:

Environment: POS hygiene: neg price: neg service: POS

Project running result:

 

Project Integration:

Integrate two fileexcludestopword and fenglei classes in (3) with myclassifier and sentimentanalysisui in (4), and make corresponding adjustments to the code, do not change the core idea.

 

Here we will mainly explain the sentimentanalysisui class:

Define and initialize classifier variables:

 

1 dynamiclmclassifier <ngramprocesslm> sclassifier; 2 myclassifier mclassifier = new myclassifier (); 3 fileexcludestopword fesw = new fileexcludestopword (); // word segmentation and deprecated WORD 4 fenglei FL = new fenglei (); // category by four aspects 5 6/** creates new form sentimentanalysisui */7 public sentimentanalysisui () {8 initcomponents (); 9 sclassifier = mclassifier. getclassifier (); // classifier 10}

 

Events triggered by the commit button in the interface:

 

1 private void jbutton1actionreceivmed (Java. AWT. event. actionevent EVT) throws unsupportedencodingexception {// gen-First: event_jbutton1actionreceivmed 2 3 string temp, review; 4 string resultall, resulte, resultp, results, resulth; 5 temp = string. valueof (jtextarea1.gettext (); // The Source comment text entered on the page 6 Review = new string (temp. getbytes ("gb2312"), "ISO-8859-1"); // [general evaluation] text encoding conversion 7 classification = sclassifier. classify (review); // [general evaluation] category 8 resultall = string. valueof (classification. bestcategory (); // [general evaluation] classification result 9 string [] finalstr = fesw. fileexcludestopword (temp); // word segmentation and deactivating 10 string [] tempre = FL. fenlei (finalstr); // category by four aspects [review] 11 string [] tempfi = new string [tempre. length]; 12 for (INT I = 0; I <tempre. length; I ++) {13 tempfi [I] = new string (tempre [I]. getbytes ("gb2312"), "ISO-8859-1"); // [review] text encoding conversion 14} 15 resulte = string. valueof (sclassifier. classify (tempfi [0]). bestcategory (); // 0-Environment 16 resulth = string. valueof (sclassifier. classify (tempfi [1]). bestcategory (); // 1-Health 17 resultp = string. valueof (sclassifier. classify (tempfi [2]). bestcategory (); // 2-price 18 results = string. valueof (sclassifier. classify (tempfi [3]). bestcategory (); // 3-service 19 20 jtextarea2.settext (string. valueof ("general evaluation:" + resultall + "\ n" + "environment:" + resulte + "\ n" + "Health: "+ resulth +" \ n "+ 21" Price: "+ resultp +" \ n "+" service: "+ results +" \ n ")); // display analysis result 22 23} // gen-last: event_jbutton1actionreceivmed

Disadvantages of this project:

A. five corpus (environmentref, healthref, priceref, serviceref, refwords) should be improved. the number of texts in the training set should be larger, so that the classifier accuracy can be improved significantly. the result of text Orientation analysis is highly dependent on the input format of the source text.

(5) [integration] machine learning-based hotel comment text trend analysis

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.