Treex::Tutorial::Scen - Treex::Scen:: scenario syntax and guidelines
version 2.20150928
Aside from the old scenario (.scen) files with the following syntax:
... # Some comment W2A::Block1 A2T::Block2 # Some other comment ...
Treex scenarios can now be represented as a separate Perl "Treex::Scen::" packages. This gives the user larger expressive power when creating various Treex scenarios:
You can write your scenario module in any way you find comfortable. There are only a few things your module must contain to become a Treex-readable scenario.
Your module should have a Treex::Scen:: prefix. You should also include these modules:
package Treex::Scen::MyScenario; use Moose; use Treex::Core::Common; with 'Treex::Core::RememberArgs';
Another thing you should not forget is a BUILD subroutine (which can be empty):
sub BUILD { my ($self) = @_; # Initialize your scenario return; }
Finally, in order to be able to communicate with Treex, the module must contain get_scenario_string method:
get_scenario_string
sub get_scenario_string { my ($self) = @_; my $scen = ""; # Add desired treex blocks to the $scen return $scen; }
The method should return a string, which follows the syntax of the ".scen" files . For example the following scenario
W2A::Tokenize W2A::TagTreeTagger W2A::Lemmatize
can be created in the following manner (of course you can use your own method):
my $scen = join "\n", 'W2A::Tokenize', 'W2A::TagTreeTagger', 'W2A::Lemmatize', ;
Of course instead of treex blocks, you can list another Treex::Scen:: module in the $scen string.
Additionally, thanks to the Treex::Core::RememberArgs role we can define arguments for our scenario:
Treex::Core::RememberArgs
has example_argument => ( is => 'ro', isa => enum( [qw(value1 value2)] ), default => 'value1', documentation => 'example of an argument definition', );
You can then modify get_scenario_string method to return a slightly different string depending on the value of the "example_argument". The argument can then be specified like this:
treex Scen::MyScenario example_argument=value2
Dušan Variš <varis@ufal.mff.cuni.cz>
Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Treex::Tutorial::Scen, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Treex::Tutorial::Scen
CPAN shell
perl -MCPAN -e shell install Treex::Tutorial::Scen
For more information on module installation, please visit the detailed CPAN module installation guide.