在内容中单独的句子然后使用斯坦福依赖解析器

时间:2017-01-24 07:43:34

标签: python nltk stanford-nlp

通过使用此代码,我可以获得整个文本依赖:

.signout_btn{
text-transform: uppercase;
outline: none;
border: 0;
background-color: #673a9a;
line-height: 40px;
color: #fff;    display: inline-block;
font-size: 16px;
margin: 10px;
cursor: pointer;

,输出为:

$( ".menu" ).click(function() {
$('.slide-menu').addClass('active');
$('.slide-wrapper').addClass('active');
});

$( "li.sub-menu" ).click(function() {
  $(this).toggleClass('act');
  $(this).find('ul').slideToggle();
});

我的问题是如何修改此代码以便为每个句子单独获得此结果?欲望输出可以是这样的:

from nltk.parse.stanford import StanfordDependencyParser
from nltk.tokenize import word_tokenize
from nltk.tree import Tree
stanford_models = 'E:\stanford-parser\stanford-parser-3.7.0-models.jar'
stanford_jar = 'E:\stanford-parser\stanford-parser.jar'
st = StanfordDependencyParser(stanford_models, stanford_jar, encoding='utf-8')
text = 'She is doing phd. She is studying civil engineering.'
result = st.raw_parse(text)
dep = result.__next__()
list(dep.triples()) 

0 个答案:

没有答案