介绍下两种标注工具:NLTK和StanfordNLP
stanford有web借口,可以访问,连接为下列前两个
两种工具都可以在python上配置,在pycharm中调用
0、stanford 工具使用
from stanfordcorenlp import StanfordCoreNLP
nlp = StanfordCoreNLP(r'G:\stanford-corenlp-full-2018-02-27')
sentence = 'Guangdong University of Foreign Studies is located in Guangzhou.'
print( 'Tokenize:', nlp.word_tokenize(sentence))
print ('Part of Speech:', nlp.pos_tag(sentence))
print ('Named Entities:', nlp.ner(sentence))
print ('Constituency Parsing:', nlp.parse(sentence))
print ('Dependency Parsing:', nlp.dependency_parse(sentence))
1、https://corenlp.run
![](https://img.haomeiwen.com/i19601533/2c6659504dee63eb.png)
这个工具能够可视化各种NLP注释,包括命名实体、词性、依存句法分析、共指和情感.
问题是在词性分析部分,把
attack
动词识别为名词,我改成单三形式,识别出来的也是名词复数。能识别共指,如下图coreference所示:
![](https://img.haomeiwen.com/i19601533/cfbf5547c9a9a106.png)
2、http://nlp.stanford.edu:8080/ner/process
这里我故意把baltimore
改成了小写,但是还是能识别出实体。有个疑问:为什么没有识别ransomware
“恶意软件”这个名词。
![](https://img.haomeiwen.com/i19601533/b56c909b3ee9ad5f.png)
3、NLTK
感觉识别不是很好,baltimore County Public Schools
这个实体小写部分没有识别出来,且把County Public Schools
识别成了人,就很荒唐了。
GPE通常表示地理—政治条目,比如城市,州,国家,洲等。LOCATION除了上述内容外,还能表示名山大川等。FACILITY通常表示知名的纪念碑或人工制品等。
![](https://img.haomeiwen.com/i19601533/3ac09dc5897ec34a.png)
4、stanford corenlp标注参考
ROOT:要处理文本的语句
IP:简单从句
NP:名词短语
VP:动词短语
PU:断句符,通常是句号、问号、感叹号等标点符号
LCP:方位词短语
PP:介词短语
CP:由‘的’构成的表示修饰性关系的短语
DNP:由‘的’构成的表示所属关系的短语
ADVP:副词短语
ADJP:形容词短语
DP:限定词短语
QP:量词短语
NN:常用名词
NR:固有名词
NT:时间名词
PN:代词
VV:动词
VC:是
CC:表示连词
VE:有
VA:表语形容词
AS:内容标记(如:了)
VRD:动补复合词
CD: 表示基数词
DT: determiner 表示限定词
EX: existential there 存在句
FW: foreign word 外来词
IN: preposition or conjunction, subordinating 介词或从属连词
JJ: adjective or numeral, ordinal 形容词或序数词
JJR: adjective, comparative 形容词比较级
JJS: adjective, superlative 形容词最高级
LS: list item marker 列表标识
MD: modal auxiliary 情态助动词
PDT: pre-determiner 前位限定词
POS: genitive marker 所有格标记
PRP: pronoun, personal 人称代词
RB: adverb 副词
RBR: adverb, comparative 副词比较级
RBS: adverb, superlative 副词最高级
RP: particle 小品词
SYM: symbol 符号
TO:”to” as preposition or infinitive marker 作为介词或不定式标记
WDT: WH-determiner WH限定词
WP: WH-pronoun WH代词
WP$: WH-pronoun, possessive WH所有格代词
WRB:Wh-adverb WH副词
关系表示
abbrev: abbreviation modifier,缩写
acomp: adjectival complement,形容词的补充;
advcl : adverbial clause modifier,状语从句修饰词
advmod: adverbial modifier状语
agent: agent,代理,一般有by的时候会出现这个
amod: adjectival modifier形容词
appos: appositional modifier,同位词
attr: attributive,属性
aux: auxiliary,非主要动词和助词,如BE,HAVE SHOULD/COULD等到
auxpass: passive auxiliary 被动词
cc: coordination,并列关系,一般取第一个词
ccomp: clausal complement从句补充
complm: complementizer,引导从句的词好重聚中的主要动词
conj : conjunct,连接两个并列的词。
cop: copula。系动词(如be,seem,appear等),(命题主词与谓词间的)连系
csubj : clausal subject,从主关系
csubjpass: clausal passive subject 主从被动关系
dep: dependent依赖关系
det: determiner决定词,如冠词等
dobj : direct object直接宾语
expl: expletive,主要是抓取there
infmod: infinitival modifier,动词不定式
iobj : indirect object,非直接宾语,也就是所以的间接宾语;
mark: marker,主要出现在有“that” or “whether”“because”, “when”,
mwe: multi-word expression,多个词的表示
neg: negation modifier否定词
nn: noun compound modifier名词组合形式
npadvmod: noun phrase as adverbial modifier名词作状语
nsubj : nominal subject,名词主语
nsubjpass: passive nominal subject,被动的名词主语
num: numeric modifier,数值修饰
number: element of compound number,组合数字
parataxis: parataxis: parataxis,并列关系
partmod: participial modifier动词形式的修饰
pcomp: prepositional complement,介词补充
pobj : object of a preposition,介词的宾语
poss: possession modifier,所有形式,所有格,所属
possessive: possessive modifier,这个表示所有者和那个’S的关系
preconj : preconjunct,常常是出现在 “either”, “both”, “neither”的情况下
predet: predeterminer,前缀决定,常常是表示所有
prep: prepositional modifier
prepc: prepositional clausal modifier
prt: phrasal verb particle,动词短语
punct: punctuation,这个很少见,但是保留下来了,结果当中不会出现这个
purpcl : purpose clause modifier,目的从句
quantmod: quantifier phrase modifier,数量短语
rcmod: relative clause modifier相关关系
ref : referent,指示物,指代
rel : relative
root: root,最重要的词,从它开始,根节点
tmod: temporal modifier
xcomp: open clausal complement
xsubj : controlling subject 掌控者
中心语为谓词
subj — 主语
nsubj — 名词性主语(nominal subject) (同步,建设)
top — 主题(topic) (是,建筑)
npsubj — 被动型主语(nominal passive subject),专指由“被”引导的被动句中的主语,一般是谓词语义上的受事 (称作,镍)
csubj — 从句主语(clausal subject),中文不存在
xsubj — x主语,一般是一个主语下面含多个从句 (完善,有些)
中心语为谓词或介词
obj — 宾语
dobj — 直接宾语 (颁布,文件)
iobj — 间接宾语(indirect object),基本不存在
range — 间接宾语为数量词,又称为与格 (成交,元)
pobj — 介词宾语 (根据,要求)
lobj — 时间介词 (来,近年)
中心语为谓词
comp — 补语
ccomp — 从句补语,一般由两个动词构成,中心语引导后一个动词所在的从句(IP) (出现,纳入)
xcomp — x从句补语(xclausal complement),不存在
acomp — 形容词补语(adjectival complement)
tcomp — 时间补语(temporal complement) (遇到,以前)
lccomp — 位置补语(localizer complement) (占,以上)
— 结果补语(resultative complement)
中心语为名词
mod — 修饰语(modifier)
pass — 被动修饰(passive)
tmod — 时间修饰(temporal modifier)
rcmod — 关系从句修饰(relative clause modifier) (问题,遇到)
numod — 数量修饰(numeric modifier) (规定,若干)
ornmod — 序数修饰(numeric modifier)
clf — 类别修饰(classifier modifier) (文件,件)
nmod — 复合名词修饰(noun compound modifier) (浦东,上海)
amod — 形容词修饰(adjetive modifier) (情况,新)
advmod — 副词修饰(adverbial modifier) (做到,基本)
vmod — 动词修饰(verb modifier,participle modifier)
prnmod — 插入词修饰(parenthetical modifier)
neg — 不定修饰(negative modifier) (遇到,不)
det — 限定词修饰(determiner modifier) (活动,这些)
possm — 所属标记(possessive marker),NP
poss — 所属修饰(possessive modifier),NP
dvpm — DVP标记(dvp marker),DVP (简单,的)
dvpmod — DVP修饰(dvp modifier),DVP (采取,简单)
assm — 关联标记(associative marker),DNP (开发,的)
assmod — 关联修饰(associative modifier),NP|QP (教训,特区)
prep — 介词修饰(prepositional modifier) NP|VP|IP(采取,对)
clmod — 从句修饰(clause modifier) (因为,开始)
plmod — 介词性地点修饰(prepositional localizer modifier) (在,上)
asp — 时态标词(aspect marker) (做到,了)
partmod– 分词修饰(participial modifier) 不存在
etc — 等关系(etc) (办法,等)
中心语为实词
conj — 联合(conjunct)
cop — 系动(copula) 双指助动词????
cc — 连接(coordination),指中心词与连词 (开发,与)
其它
attr — 属性关系 (是,工程)
cordmod– 并列联合动词(coordinated verb compound) (颁布,实行)
mmod — 情态动词(modal verb) (得到,能)
ba — 把字关系
tclaus — 时间从句 (以后,积累)
— semantic dependent
cpm — 补语化成分(complementizer),一般指“的”引导的CP (振兴,的)
5、NLTK中的标注参考
nltk词性标注POS中的词性
CC 连词 and, or,but, if, while,although
CD 数词 twenty-four, fourth, 1991,14:24
DT 限定词 the, a, some, most,every, no
EX 存在量词 there, there’s
FW 外来词 dolce, ersatz, esprit, quo,maitre
IN 介词连词 on, of,at, with,by,into, under
JJ 形容词 new,good, high, special, big, local
JJR 比较级词语 bleaker braver breezier briefer brighter brisker
JJS 最高级词语 calmest cheapest choicest classiest cleanest clearest
LS 标记 A A. B B. C C. D E F First G H I J K
MD 情态动词 can cannot could couldn’t
NN 名词 year,home, costs, time, education
NNS 名词复数 undergraduates scotches
NNP 专有名词 Alison,Africa,April,Washington
NNPS 专有名词复数 Americans Americas Amharas Amityvilles
PDT 前限定词 all both half many
POS 所有格标记 ’ ‘s
PRP 人称代词 hers herself him himself hisself
PRP 所有格 her his mine my our ours
RB 副词 occasionally unabatingly maddeningly
RBR 副词比较级 further gloomier grander
RBS 副词最高级 best biggest bluntest earliest
RP 虚词 aboard about across along apart
SYM 符号 % & ’ ” ”. ) )
TO 词to to
UH 感叹词 Goodbye Goody Gosh Wow
VB 动词 ask assemble assess
VBD 动词过去式 dipped pleaded swiped
VBG 动词现在分词 telegraphing stirring focusing
VBN 动词过去分词 multihulled dilapidated aerosolized
VBP 动词现在式非第三人称时态 predominate wrap resort sue
VBZ 动词现在式第三人称时态 bases reconstructs marks
WDT Wh限定词 who,which,when,what,where,how
WP WH代词 that what whatever
WP$ WH代词所有格 whose
WRB WH副词
网友评论