Dependency Parsing

Dependency Parsing related modeling class

class pororo.tasks.dependency_parsing.PororoDpFactory(task: str, lang: str, model: Optional[str])[source]

Bases: pororo.tasks.utils.base.PororoFactoryBase

Conduct dependency parsing

Korean (posbert.base.ko.dp)

Parameters

sent – (str) sentence to be parsed dependency

Returns

token index, token label, token head and its relation

Return type

List[Tuple[int, str, int, str]]

Examples

>>> dp = Pororo(task="dep_parse", lang="ko")
>>> dp("분위기도 좋고 음식도 맛있었어요. 한 시간 기다렸어요.")
[(1, '분위기도', 2, 'NP_SBJ'), (2, '좋고', 4, 'VP'), (3, '음식도', 4, 'NP_SBJ'), (4, '맛있었어요.', 7, 'VP'), (5, '한', 6, 'DP'), (6, '시간', 7, 'NP_OBJ'), (7, '기다렸어요.', -1, 'VP')]
>>> dp("한시간 기다렸어요.")
[(1, '한시간', 2, 'NP_OBJ'), (2, '기다렸어요.', -1, 'VP')]
static get_available_langs()[source]
static get_available_models()[source]
load(device: str)[source]

Load user-selected task-specific model

Parameters

device (str) – device information

Returns

User-selected task-specific model

Return type

object

class pororo.tasks.dependency_parsing.PororoSegmentBertDP(model, tagger, config)[source]

Bases: pororo.tasks.utils.base.PororoSimpleBase

predict(sent: str, **kwargs)[source]

Conduct dependency parsing

Parameters

sent – (str) sentence to be parsed dependency

Returns

token index, token label, token head and its relation

Return type

List[Tuple[int, str, int, str]]