| 1 | package Treex::Block::W2A::EN::TagMorphoDiTa; | ||
| 2 | $Treex::Block::W2A::EN::TagMorphoDiTa::VERSION = '2.20151102'; | ||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use Treex::Core::Common; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | extends 'Treex::Block::W2A::TagMorphoDiTa'; | ||
| 8 | |||
| 9 | has '+model' => ( default => 'data/models/morphodita/en/english-morphium-wsj-140407.tagger' ); | ||
| 10 | |||
| 11 | has 'negative_prefixes_in_lemma' => ( | ||
| 12 | is => 'ro', | ||
| 13 | isa => 'Bool', | ||
| 14 | default => 0, | ||
| 15 | documentation => 'Some English MorphoDiTa models lemmatize words with negative prefixes' | ||
| 16 | . ' e.g. as "unable"->"able^un". Do we want to have such lemmas? Default is false.', | ||
| 17 | ); | ||
| 18 | |||
| 19 | |||
| 20 | after 'process_atree' => sub { | ||
| 21 | my ($self, $atree) = @_; | ||
| 22 | if ($self->lemmatize && $self->model !~ /no_negation.tagger$/ && !$self->negative_prefixes_in_lemma){ | ||
| 23 | foreach my $anode ($atree->get_descendants()){ | ||
| 24 | my ($lemma, $prefix) = split /\^/, $anode->lemma; | ||
| 25 | if (defined $prefix){ | ||
| 26 | $anode->set_lemma($lemma); | ||
| 27 | $anode->set_iset(negativeness => 'neg'); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | } | ||
| 31 | return; | ||
| 32 | }; | ||
| 33 | |||
| 34 | 1; | ||
| 35 | |||
| 36 | __END__ | ||