Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
user:zeman:interset:how-to-use [2008/03/10 13:14] zeman New location of driver-test.pl. |
user:zeman:interset:how-to-use [2017/01/16 13:03] zeman |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Manual ===== | + | ====== DZ Interset |
- | ==== Installation ==== | + | ===== Installation |
- | If you exist on the ÚFAL network, you can use directly Dan's version | + | If you exist on the ÚFAL network |
- | **Note:** I decided to put the whole thing under version control. At the same time, I moved it from my lib folder to my project folder. So the current ÚFAL location is ''/ | + | <code bash> |
- | **Contributions welcome!** If you write your own driver, please share it with others! If you send it to me, I will add it to the package | + | **Contributions welcome!** If you write your own driver, please share it with others! If you send it to me, I will add it to the package |
- | === Existing drivers === | + | ==== Existing drivers |
- | * tagset:: | + | Use the tool '' |
- | * tagset:: | + | |
- | * tagset:: | + | |
- | * tagset:: | + | |
- | * tagset:: | + | |
- | * tagset:: | + | |
- | * tagset:: | + | |
- | * tagset:: | + | |
- | * tagset:: | + | |
- | === Directory Structure === | + | ==== Directory Structure |
- | The drivers are Perl modules and must be somewhere under '' | + | The drivers are Perl modules and must be somewhere under '' |
<code perl> | <code perl> | ||
- | use tagset::ll::xxx; | + | use Lingua::Interset::Tagset:: |
</ | </ | ||
- | Besides drivers, there is a library of useful functions that can be called from within drivers: '' | + | but usually it is more convenient to just call the main module and then refer to the tagset using the lowercased identifier: |
+ | |||
+ | <code perl> | ||
+ | use Lingua:: | ||
+ | my $fs = decode('ll::xxx', $tag); | ||
+ | </code> | ||
+ | |||
+ | The main object in Interset is of the class '' | ||
There is also the driver testing script, '' | There is also the driver testing script, '' | ||
- | ==== How to use the Interset ==== | + | ===== How to use the Interset |
- | You can write your own tag conversion Perl script, and use the Interset driver library. You have to tell Perl where to find the drivers: | + | You can write your own tag conversion Perl script, and use the Interset driver library. You may have to tell Perl where to find Interset (the following commands work in '' |
- | < | + | < |
+ | setenv PATH / | ||
- | Once the variable is set, writing a conversion script is very easy. For instance, my '' | + | Once the variable is set, writing a conversion script is very easy. Here is an example (note that in CoNLL-X files we often merge the contents of the CPOS, POS and FEATS columns to create one long string that will be seen by Interset as one “tag”): |
<code perl> | <code perl> | ||
- | use tagset::cs::pdt; | + | use Lingua::Interset::Converter; |
- | use tagset:: | + | |
+ | my $c = new Lingua:: | ||
+ | |||
+ | # Read the CoNLL-X file from STDIN or from files given as arguments. | ||
while(<> | while(<> | ||
{ | { | ||
- | | + | |
{ | { | ||
- | my $tag0 = $1; | + | |
- | my $features | + | my @f = split(/\t/, $_); |
- | my $tag1 = tagset:: | + | |
- | | + | my $utag = $c-> |
+ | my ($upos, $ufeat) | ||
+ | $f[3] = $upos; | ||
+ | $f[5] = $ufeat; | ||
+ | $_ = join(" | ||
} | } | ||
- | print; | + | |
+ | | ||
} | } | ||
</ | </ | ||
- | |||
- | Note the two-step replacement of the original tag. I do not dare to use the original tag in a regular expression because there could be special characters in the tag. | ||