Identifying Dialogue Act Type
Natural Language Processing with Python
Chapter 6.2
import nltk
from nltk.corpus import nps_chat as nchat def dialogue_act_features(post):
features={}
for word in nltk.word_tokenize(post):
features['contains(%s)' % word.lower()] = True
return features def test_dialogue_act_types():
posts=nchat.xml_posts()[:10000]
featuresets = [(dialogue_act_features(post.text),post.get('class'))
for post in posts]
size=int(len(featuresets)*0.1)
train_set, test_set = featuresets[size:],featuresets[:size]
classifier = nltk.NaiveBayesClassifier.train(train_set)
print nltk.classify.accuracy(classifier,test_set)
classifier.show_most_informative_features(5)
运行结果:
0.668
Most Informative Features
contains(hi) = True Greet : System = 408.2 : 1.0
contains(>) = True Other : System = 384.6 : 1.0
contains(empty) = True Other : System = 339.4 : 1.0
contains(part) = True System : Statem = 302.0 : 1.0
contains(no) = True nAnswe : System = 262.3 : 1.0
Identifying Dialogue Act Type的更多相关文章
- RTTI(Runtime Type Information )
RTTI 是“Runtime Type Information”的缩写,意思是:运行时类型信息.它提供了运行时确定对象类型的方法.本文将简略介绍 RTTI 的一些背景知识.描述 RTTI 的概念,并通 ...
- RFC 2616
Network Working Group R. Fielding Request for Comments: 2616 UC Irvine Obsoletes: 2068 J. Gettys Cat ...
- 自然语言处理领域重要论文&资源全索引
自然语言处理(NLP)是人工智能研究中极具挑战的一个分支.随着深度学习等技术的引入,NLP领域正在以前所未有的速度向前发展.但对于初学者来说,这一领域目前有哪些研究和资源是必读的?最近,Kyubyon ...
- NLP项目
GitHub NLP项目:自然语言处理项目的相关干货整理 自然语言处理(NLP)是计算机科学,人工智能,语言学关注计算机和人类(自然)语言之间的相互作用的领域.本文作者为自然语言处理NLP初学者整理了 ...
- Xenko基础API笔记2-手势
交互: Drag Gesture Type : Continuous Configuration class: GestureConfigDrag Event class: GestureEventD ...
- 转: Linux磁盘扩容
from:https://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-expanding-the-virtual-mach ...
- php服务器探针
<?php /* ---------------------------------------------------- */ /* 程序名称: PHP探针-Yahei /* 程序功能: 探测 ...
- ECSHOP在线手册布局参考图--登录/注册页 user_passport.dwt
A.会员登录框 1,设置方法 自带模块 2,代码相关 user_passport.dwt 中 <div class="usBox_1 f_l"> <div ...
- selectpicker下拉多选框ajax异步或者提前赋值=》默认值
Bootstrap select多选下拉框赋值 success: function (data) { var oldnumber = new Array(); $.each(data, functio ...
随机推荐
- asp中的动态数组
<% Dim array1(),i ReDim array1(3)array1(3)=10response.Write(array1(3)&"<br>") ...
- 四种xml的解析方式
这篇文章是我上网找资料,加上自己总结了一些而得 资料来源: http://www.cnblogs.com/allenzheng/archive/2012/12/01/2797196.html http ...
- 1.2 Python基本语法
1.交互模式编程 cmd窗口 =>输入 Python => 输入 print "hello,python!"; ps:如果是新版本Python,需要输 ...
- Goods transportation
Goods transportation time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- 初学.net 网页打开过程
一个网页打开的过程 1.进入控制器里的方法里 控制器的命名必须以Controll结尾前面的名字要和view层的命名一致 2.控制器完了以后 就进入view层对应的视图里 3.视图里调用model ...
- UVA 10200 Prime Time (打表)
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
- Python之路【第二篇】:Python基础(二)
windows的换行符:\n\r linux的换行符:\n 文件的数据处理: r 以只读模式打开文件(默认模式)w 以只写模式打开文件a 以追加模式打开文件 r+b 以读写模式打开文件(以读/写方式打 ...
- nat和打洞
http://michankong.blog.51cto.com/1464983/761270 可能有点乱,下面以故事的形式叙述一下这个情景. 人物:A(男) NAT_A(A家接线员) B(女) NA ...
- C# 经典入门15章 RadioButton和CheckBox
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAswAAAF6CAIAAACCyJm4AAAgAElEQVR4nOyd91sTzdrH379kEyD0Hk
- 【转】php缓冲 output_buffering和ob_start
原文: http://blog.csdn.net/21aspnet/article/details/7389427 php缓冲 output_buffering和ob_start buffer buf ...