texts(list[list[str] or list[list[str]]]): the input texts to be parse. It should be a list with elements: untokenized string or tokens list.
return_visual(bool): if set True, the result will contain the dependency visualization.
Returns:
results(list[dict]): a list, with elements corresponding to each of the elements in texts. The element is a dictionary of shape:
{
'word': list[str], the tokenized words.
'head': list[int], the head ids.
'deprel': list[str], the dependency relation.
'prob': list[float], the prediction probility of the dependency relation.
'postag': list[str], the POS tag. If the element of the texts is list, the key 'postag' will not be returned.
}
visuals : list[numpy.array]: the dependency visualization. Use cv2.imshow to show or cv2.imwrite to save it. If return_visual=False, it will not be empty.
"""
ifnottexts:
return
ifall([isinstance(i,str)andiforiintexts]):
do_parse=self.ddp.parse
elifall([isinstance(i,list)andiforiintexts]):
do_parse=self.ddp.parse_seg
else:
raiseValueError("All of the elements should be string or list")