Stanford Parser句法分析器使用教程
最近在寻找一些开源的语法分析软件,找到了stanford parser语句分析器。
安装过程如下:
首先下载源码,地址为:https://nlp.stanford.edu/software/lex-parser.shtml
选择最新版本下载,点击Download Stanford parser version 3.9.2部分进行下载:
如需使用Stanford Parser进行图形化分析请参考这篇博文:https://www.cnblogs.com/Denise-hzf/p/6612574.html
下载之后为如下所示
将其解压到你的maven的repository目录下
解压之后的重要的架包为stanford-parser.jar和stanford-parser-3.9.2-models.jar这两个架包,这两个架包是需要我们在idea中引入的
架包下载完成之后就需要在idea中引入架包,选择File——>Project Structure——>Modules——>点击加号选择JARs or directroies引入stanford-parser.jar和stanford-parser-3.9.2-models.jar这两个架包,引入stanford-parser-3.9.2-models.jar时选择Classes
idea架包引入之后有锁并不影响架包的使用
Stanford Parser句法分析测试
测试方法一
public static void main(String[] args) {
String[] arg2 = {"-encoding", "utf-8",
"-outputFormat", "penn,typedDependenciesCollapsed",
"edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz",
"C:\\Users\\J\\Desktop\\临时数据文件夹\\test.txt"};
LexicalizedParser.main(arg2);
}
测试方法二
public static void main(String[] args) {
String model_path = "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz";
String str = "this is an apple ";//输入测试语句
String[] options = { "-maxLength", "140", "-MAX_ITEMS","500000"};
LexicalizedParser lp = LexicalizedParser.loadModel(model_path,options);
Tree t = lp.parse(str);
int depth = t.depth();
t.pennPrint();
System.out.println(depth);
EnglishGrammaticalStructure gs = new EnglishGrammaticalStructure(t);//中文语法结构
Collection tdl = gs.typedDependenciesCollapsed();//依存关系分析
System.out.println(tdl.toString());
String s = "";
for (int i = 0; i < tdl.size(); i++) {
TypedDependency td = (TypedDependency) tdl.toArray()[i];
String age = td.dep().toString();
s += age + "/";
s += " ";
}
System.out.println(s);
}
运行结果如下:
单词属性翻译参考网站:https://stackoverflow.com/questions/1833252/java-stanford-nlp-part-of-speech-labels
常用解释翻译可参考:https://blog.csdn.net/pipisorry/article/details/42976457?utm_source=itdadao&utm_medium=referral
翻译来自CSDN博主「-柚子皮-」的原创文章,谢谢大佬的博文
词性解释
CC: conjunction, coordinatin 表示连词
CD: numeral, cardinal 表示基数词
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 情态助动词
NN: noun, common, singular or mass
NNS: noun, common, plural
NNP: noun, proper, singular
NNPS: noun, proper, plural
PDT: pre-determiner 前位限定词
POS: genitive marker 所有格标记
PRP: pronoun, personal 人称代词
PRP
:
p
r
o
n
o
u
n
,
p
o
s
s
e
s
s
i
v
e
所
有
格
代
词
R
B
:
a
d
v
e
r
b
副
词
R
B
R
:
a
d
v
e
r
b
,
c
o
m
p
a
r
a
t
i
v
e
副
词
比
较
级
R
B
S
:
a
d
v
e
r
b
,
s
u
p
e
r
l
a
t
i
v
e
副
词
最
高
级
R
P
:
p
a
r
t
i
c
l
e
小
品
词
S
Y
M
:
s
y
m
b
o
l
符
号
T
O
:
"
t
o
"
a
s
p
r
e
p
o
s
i
t
i
o
n
o
r
i
n
f
i
n
i
t
i
v
e
m
a
r
k
e
r
作
为
介
词
或
不
定
式
标
记
U
H
:
i
n
t
e
r
j
e
c
t
i
o
n
插
入
语
V
B
:
v
e
r
b
,
b
a
s
e
f
o
r
m
V
B
D
:
v
e
r
b
,
p
a
s
t
t
e
n
s
e
V
B
G
:
v
e
r
b
,
p
r
e
s
e
n
t
p
a
r
t
i
c
i
p
l
e
o
r
g
e
r
u
n
d
V
B
N
:
v
e
r
b
,
p
a
s
t
p
a
r
t
i
c
i
p
l
e
V
B
P
:
v
e
r
b
,
p
r
e
s
e
n
t
t
e
n
s
e
,
n
o
t
3
r
d
p
e
r
s
o
n
s
i
n
g
u
l
a
r
V
B
Z
:
v
e
r
b
,
p
r
e
s
e
n
t
t
e
n
s
e
,
3
r
d
p
e
r
s
o
n
s
i
n
g
u
l
a
r
W
D
T
:
W
H
−
d
e
t
e
r
m
i
n
e
r
W
H
限
定
词
W
P
:
W
H
−
p
r
o
n
o
u
n
W
H
代
词
W
P
: pronoun, possessive 所有格代词 RB: adverb 副词 RBR: adverb, comparative 副词比较级 RBS: adverb, superlative 副词最高级 RP: particle 小品词 SYM: symbol 符号 TO:"to" as preposition or infinitive marker 作为介词或不定式标记 UH: interjection 插入语 VB: verb, base form VBD: verb, past tense VBG: verb, present participle or gerund VBN: verb, past participle VBP: verb, present tense, not 3rd person singular VBZ: verb, present tense,3rd person singular WDT: WH-determiner WH限定词 WP: WH-pronoun WH代词 WP
:pronoun,possessive所有格代词RB:adverb副词RBR:adverb,comparative副词比较级RBS:adverb,superlative副词最高级RP:particle小品词SYM:symbol符号TO:"to"asprepositionorinfinitivemarker作为介词或不定式标记UH:interjection插入语VB:verb,baseformVBD:verb,pasttenseVBG:verb,presentparticipleorgerundVBN:verb,pastparticipleVBP:verb,presenttense,not3rdpersonsingularVBZ:verb,presenttense,3rdpersonsingularWDT:WH−determinerWH限定词WP:WH−pronounWH代词WP: WH-pronoun, possessive WH所有格代词
WRB:Wh-adverb WH副词
句法分析(句法树)
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 掌控者
[Stanford Parser 标记含义]
[POS Tagging]
————————————————
版权声明:本文为CSDN博主「-柚子皮-」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/pipisorry/article/details/42976457