NLTK带有一些语料库样本: http://nltk.googlecode.com/svn/trunk/nltk_data/index.xml如何从NLTK附带的样本语料库中提取单词?
我希望只有没有编码的文本。我不知道如何提取这些内容。我想提取的是:
1)nps_chat:文件名与解压缩后的文件名相同,如10-19-20s_706posts.xml。 这样的文件是XML格式,如:
<Posts>
<Post class="Statement" user="10-19-20sUser7">now im left with this gay name<terminals>
<t pos="RB" word="now"/>
<t pos="PRP" word="im"/>
<t pos="VBD" word="left"/>
<t pos="IN" word="with"/>
<t pos="DT" word="this"/>
<t pos="JJ" word="gay"/>
<t pos="NN" word="name"/>
</terminals>
</Post>
...
...
我只想要实际岗位:
now im left with this gay name
如何在NLTK或做(什么)保存在本地磁盘剥离编码后裸露的帖子吗?
2)总机转录本。这种类型的文件(解压缩后的文件名是话语)包含以下格式。我要的是剥夺前面标记:
o A.1 utt1: Okay,/
qy A.1 utt2: have you ever served as a juror?/
ng B.2 utt1: Never./
sd^e B.2 utt2: I've never been served on the jury, never been called up in a jury, although some of my friends have been jurors./
b A.3 utt1: Uh-huh./
sd A.3 utt2: I never have either./
% B.4 utt1: You haven't, {F huh. }/
...
...
我只想有:
Okay,/
have you ever served as a juror?/
Never./
I've never been served on the jury, never been called up in a jury, although some of my friends have been jurors./
Uh-huh./
I never have either./
You haven't, {F huh. }/
...
...
非常感谢你提前。
谢谢inspectorG4dget所有的话,我正在测试你的代码。 – Dylan 2011-01-22 10:52:21