Word Sense Disambiguation

Word Sense Disambiguation related modeling class

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

Bases: pororo.tasks.utils.base.PororoFactoryBase

Conduct Word Sense Disambiguation

Korean (transformer.large.ko.wsd)
Parameters

text (str) – sentence to be inputted

Returns

list of token and its disambiguated meaning tuple

Return type

List[Tuple[str, str]]

Examples

>>> wsd = Pororo(task="wsd", lang="ko")
>>> wsd("머리에 이가 있나봐.")
[detail(morph='머리', pos='NNG', sense_id='01', original=None, meaning='사람이나 동물의 목 위의 부분', english='head'),
detail(morph='에', pos='JKB', sense_id=None, original=None, meaning=None, english=None),
detail(morph='▁', pos='SPACE', sense_id=None, original=None, meaning=None, english=None),
detail(morph='이', pos='NNG', sense_id='01', original=None, meaning='이목의 곤충을 통틀어 이르는 말', english='louse'),
detail(morph='가', pos='JKS', sense_id=None, original=None, meaning=None, english=None),
detail(morph='▁', pos='SPACE', sense_id=None, original=None, meaning=None, english=None),
detail(morph='있', pos='VA', sense_id='01', original=None, meaning='사람이나 동물이 어느 곳에서 떠나거나 벗어나지 아니하고 머물다', english='be; stay'),
detail(morph='나', pos='EC', sense_id=None, original=None, meaning=None, english=None),
detail(morph='보', pos='VX', sense_id=None, original=None, meaning=None, english=None),
detail(morph='아', pos='EF', sense_id=None, original=None, meaning=None, english=None),
detail(morph='.', pos='SF', sense_id=None, original=None, meaning=None, english=None)]
static get_available_langs()[source]
static get_available_models()[source]
load(device: str)[source]

Load user-selected task-specific model :param device: device information :type device: str

Returns

User-selected task-specific model

Return type

object

class pororo.tasks.word_sense_disambiguation.PororoTransformerWsd(model, morph2idx, tag2idx, query2origin, query2meaning, query2eng, config)[source]

Bases: pororo.tasks.utils.base.PororoTaskGenerationBase

predict(text: str, beam: int, **kwargs) → Optional[List[Tuple[str, str]]][source]

Conduct Word Sense Disambiguation

Parameters
  • text (str) – sentence to be inputted

  • beam (int) – beam search argument

  • ignore_none (bool) – whether to ignore none meaning

Returns

list of token and its disambiguated information tuple

Return type

List[Tuple[str]]