Constituency Parsing

Constituency Parsing related modeling class

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

Bases: pororo.tasks.utils.base.PororoFactoryBase

Constituency parsing using Transformer model

English (transformer.base.en.const)

  • dataset: OntoNotes 5.0

  • metric: TBU

Korean (transformer.base.en.const)

  • dataset: Sejong Corpus

  • metric: TBU

Chinese (transformer.base.zh.const)

  • dataset: OntoNotes 5.0

  • metric: TBU

Parameters
  • text (str) – input text

  • beam (int) – size of beam search

  • pos (bool) – contains PoS tagging or not

Returns

result of constituency parsing

Return type

result

Examples

>>> const = Pororo(task="const", lang="en")
>>> const("I love this place")
<TOP>
    <S>
        <NP>I</NP>
        <VP>
            love
            <NP>this place</NP>
        </VP>
    </S>
</TOP>
>>> const = Pororo(task="const", lang="zh")
>>> const("我喜欢饼干")
<TOP>
    <IP>
        <NP>我</NP>
        <VP>
            喜欢
            <NP>饼干</NP>
        </VP>
    </IP>
</TOP>
>>> const = Pororo(task="const", lang="ko")
>>> const("미국에서도 같은 우려가 나오고 있다.")
<S>
  <NP_AJT>미국/NNP+에서/JKB+도/JX</NP_AJT>
    <S>
      <NP_SBJ>
        <VP_MOD>같/VA+은/ETM</VP_MOD>
        <NP_SBJ>우려/NNG+가/JKS</NP_SBJ>
      </NP_SBJ>
      <VP>
        <VP>나오/VV+고/EC</VP>
        <VP>있/VX+다/EF+./SF</VP>
      </VP>
    </S>
</S>
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.constituency_parsing.PororoConstBase(config: pororo.tasks.utils.base.TaskConfig)[source]

Bases: pororo.tasks.utils.base.PororoTaskBase

Constituency Parsing base class containinig various methods related to Const. Parsing

class pororo.tasks.constituency_parsing.PororoTransConstKo(model, tagger, config)[source]

Bases: pororo.tasks.constituency_parsing.PororoConstBase

predict(text: str, beam: int = 5, pos: bool = False, **kwargs)[source]

Conduct constituency parsing

Parameters
  • text (str) – input text

  • beam (int) – size of beam search

  • pos (bool) – contains PoS tagging or not

Returns

result of constituency parsing

class pororo.tasks.constituency_parsing.PororoTransConstEn(model, tagger, config)[source]

Bases: pororo.tasks.constituency_parsing.PororoConstBase

predict(text: str, beam: int = 5, pos: bool = False, **kwargs)[source]

Conduct constituency parsing

Parameters
  • text (str) – input sentence

  • beam (int) – size of beam search

  • pos (bool) – contains PoS tagging or not

Returns

result of constituency parsing

class pororo.tasks.constituency_parsing.PororoTransConstZh(model, tagger, config)[source]

Bases: pororo.tasks.constituency_parsing.PororoConstBase

predict(text: str, beam: int = 5, pos: bool = False, **kwargs)[source]

Conduct constituency parsing

Parameters
  • text (str) – input sentence

  • beam (int) – size of beam search

  • pos (bool) – contains PoS tagging or not

Returns

result of constituency parsing