1 package Text::Tradition::Language::English;
5 use Lingua::TagSet::TreeTagger::English;
6 use Text::Tradition::Language::Base qw/ lemmatize_treetagger reading_lookup_treetagger
7 lfs_morph_tags unicode_regularize /;
12 Text::Tradition::Language::English - language-specific module for English
16 Implements morphology lookup for English words in context. This module
17 depends on the TreeTagger software
18 (L<http://www.ims.uni-stuttgart.de/projekte/corplex/TreeTagger/>), which is
19 (for now) expected to be installed in $MORPHDIR/TreeTagger.
23 =head2 lemmatize( $text )
25 Evaluates the string using the TreeTagger, and returns the results.
29 binmode STDOUT, ':utf8';
31 use_ok( 'Text::Tradition::Language::English' );
38 my $tradition = shift;
40 'language' => 'English',
41 'callback' => sub { _parse_wordform( @_ ) }
43 return lemmatize_treetagger( $tradition, %opts );
46 =head2 reading_lookup( $rdg[, $rdg, ...] )
48 Looks up one or more readings using the Flemm package, and returns the
49 possible results. This uses the same logic as L<lemmatize> above for the
50 entire tradition, but can also be used to (re-)analyze individual readings.
57 'language' => 'English',
58 'callback' => sub { _parse_wordform( @_ ) },
61 return reading_lookup_treetagger( %opts );
64 =head2 morphology_tags
66 Return a data structure describing the available parts of speech and their attributes.
71 return lfs_morph_tags();
74 # Utility function to turn a TreeTagger result into a WordForm
76 my $tagresult = shift;
77 my( $orig, $tag, $lemma ) = split( /\t/, $tagresult );
78 return () unless $tag =~ /\w/; # skip punct-only "tags"
79 my $morphobj = Lingua::TagSet::TreeTagger::English->tag2structure( $tag );
81 return ( Text::Tradition::Collation::Reading::WordForm->new(
82 'language' => 'English',
84 'morphology' => $morphobj,
87 warn "No morphology found for word: $tagresult";
95 =head2 regularize( $text )
97 Returns a regularized form of the reading for the purposes of collation.
102 return unicode_regularize( @_ );