Identifying Dialogue Act Type

Source: Internet
Author: User
Tags nltk

Natural Language processing with Python

Chapter 6.2

1 ImportNLTK2  fromNltk.corpusImportNps_chat as NChat3 4 defDialogue_act_features (POST):5features={}6      forWordinchnltk.word_tokenize (POST):7features['contains (%s)'% word.lower ()] =True8     returnfeatures9     Ten deftest_dialogue_act_types (): OnePosts=nchat.xml_posts () [: 10000] AFeaturesets = [(Dialogue_act_features (Post.text), Post.get ('class'))  -                      forPostinchPosts] -Size=int (Len (featuresets) *0.1) theTrain_set, Test_set =Featuresets[size:],featuresets[:size] -Classifier =NLTK. Naivebayesclassifier.train (Train_set) -     Printnltk.classify.accuracy (Classifier,test_set) -Classifier.show_most_informative_features (5)

Operation Result:

0.668
Most informative Features
Contains (HI) = True Greet:system = 408.2:1
Contains (>) = True other:system = 384.6:1
Contains (empty) = True Other:system = 339.4:1
Contains (part) = True System:statem = 302:1
Contains (NO) = True Nanswe:system = 262.3:1

Identifying Dialogue Act Type

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.