分解英文数据:
(1)首先下载stanford的资源包,可以在官网上下载
也可以在相应的下载网站上下载,推荐官网下载
(2).开始前要检查一下java的版
我是下载的1.8版本,测试后没有问题
安装JDK的时候注意配置环境变量即可
(3)英文数据测试:
参数说明:
①-mx1g:给java虚拟机分配的最大内存为1g(大小可自行设置)。
②-cp :为了加载java包stanford-parser-2011-04-20.jar。 LexicalizedParser:parser类.
③-maxLength:指定句子单词长度最大为100。
④–outputFormat:指定输出句子的格式。 outputFormat具体选项值如下: Oneline:成分句法分析输出文件的格式为每行一句的广义表形式的树结构。 Penn:成分句法分析输出文件的格式为层次化树的形式。默认选项为penn。 latexTree:格式类似于penn Words:只给出分词格式。如: 继续 播报 详细 的 新闻 内容 。 wordsAndTags:给出分词文本和标记。如: 继续/VV 播报/VV 详细/VA 的/DEC 新闻/NN 内容/NN 。/PU rootSymbolOnly:只给出ROOT结点 typedDependencies:给出依存句法分析结果。 mmod(播报-2, 继续-1) rcmod(内容-6, 详细-3) cpm(详细-3, 的-4) nn(内容-6, 新闻-5) dobj(播报-2, 内容-6) conllStyleDependencies、conll2008:conll格式(每行一词,每词十项)如下: 1 继续 _ VV _ _ 2 _ _ _ 2 播报 _ VV _ _ 0 _ _ _ 3 详细 _ VA _ _ 4 _ _ _ 4 的 _ DEC _ _ 6 _ _ _ 5 新闻 _ NN _ _ 6 _ _ _ 6 内容 _ NN _ _ 2 _ _ _ 7 。 _ PU _ _ 2 _ _ _
⑤-escaper:字符的标准化(例如将英文的”(”改成”-LRB-”,默认情况即这样转换)。英文的escaper为edu.stanford.nlp.process.PTBEscapingProcessor。中文为:edu.stanford.nlp.trees.international.pennchinese.ChineseEscaper。 举例: java -mx500m -cp stanford-parser.jar edu.stanford.nlp.parser.lexparser.LexicalizedParser -escaper edu.stanford.nlp.trees.international.pennchinese.ChineseEscaper -sentences newline chineseFactored.ser.gz chinese-onesent > chinese-onesent.stp
⑥-sentences:指定句子之间的边界,一般为newline :输入文件的句子通过换行符分割。Parser得到的文本是每行一句,一句一句的进行分析。
⑩-outputFilesDirectory :指定输出文件目录,默认为当前目录。 在这一小节中,我们用到的parser类为parser.lexparser.LexicalizedParser,这个类既能生成基于短语结构的成分句法树(指定输出格式为penn或oneline),又可以生成基于依存结构的依存句法树(指定输出格式为typedDependencies)。 接下来,我们用到的类名为:trees.EnglishGrammaticalStruct ure。我们使用这个类将已经是成分句法树结构(penn Treebank-style trees)转化为依存句法树结构。这里的成分句法树来源,既可以是stanford parser生成的,又可以是其他种类的parser(如:berkeley parser、charniak parser)生成的。
输入的文档是:
Scores of properties are under extreme fire threat as a huge blaze
continues to advance through Sydney's north-western suburbs. Fires
have also shut down the major road and rail links between Sydney and
Gosford.
The promotional stop in Sydney was everything to be expected for a
Hollywood blockbuster - phalanxes of photographers, a stretch limo to
a hotel across the Quay - but with one difference. A line-up of
masseurs was waiting to take the media in hand. Never has the term
"massaging the media" seemed so accurate.
continues to advance through Sydney's north-western suburbs. Fires
have also shut down the major road and rail links between Sydney and
Gosford.
The promotional stop in Sydney was everything to be expected for a
Hollywood blockbuster - phalanxes of photographers, a stretch limo to
a hotel across the Quay - but with one difference. A line-up of
masseurs was waiting to take the media in hand. Never has the term
"massaging the media" seemed so accurate.
输出文档时:
也可以使用图形化界面:
直接点击lexparser-gui.bat工具,利用提示进行分解:
对于大规模大数据的句法分析将在后文中介绍
ROOT:要处理文本的语句
IP:简单从句
NP:名词短语
VP:动词短语
PU:断句符,通常是句号、问号、感叹号等标点符号
LCP:方位词短语
PP:介词短语
CP:由‘的’构成的表示修饰性关系的短语
CP:由‘的’构成的表示修饰性关系的短语
DNP:由‘的’构成的表示所属关系的短语
ADVP:副词短语
ADJP:形容词短语
DP:限定词短语
QP:量词短语
NN:常用名词
NR:固有名词
NT:时间名词
PN:代词
VV:动词
VC:是
CC:不是(应该是吧!!不太确定)
CC:不是(应该是吧!!不太确定)
VE:有
VA:表语形容词
VA:表语形容词
AS:内容标记(如:了)
VRD:动补复合词