[ Skip to the content ]

Institute of Formal and Applied Linguistics Wiki


[ Back to the navigation ]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
user:zeman:interset:how-to-write-a-driver [2009/09/08 15:45]
zeman Replacing feature values and the other feature.
user:zeman:interset:how-to-write-a-driver [2009/09/08 17:46]
zeman Current solution.
Line 149: Line 149:
 $fs1 = tagset::common::enforce_permitted_joint($fs0, $permitted); $fs1 = tagset::common::enforce_permitted_joint($fs0, $permitted);
 </code> </code>
 +
  
 ===== Replacing and the other feature ===== ===== Replacing and the other feature =====
Line 163: Line 164:
  
 **Another possible solution** is to implement a new subroutine that returns the list of the tags that can be used for scanning of permitted feature value combinations. By default, the subroutine would return the list of non-o-tags. For tagsets such as ''zh::conll'', it could create a taylored list of tags. **Another possible solution** is to implement a new subroutine that returns the list of the tags that can be used for scanning of permitted feature value combinations. By default, the subroutine would return the list of non-o-tags. For tagsets such as ''zh::conll'', it could create a taylored list of tags.
 +
 +**Current solution:** New (third) parameter to ''tagset::common::get_permitted_structures_joint()'', when set to 1 (''true''), says that o-tags shall be ignored. Note that it requires changing the beginning of ''encode()''. We must not enforce permitted combinations if source tagset is same as target (because we would be violating o-tags without knowing their permitted values). Instead, we should just do a simple deep copy of the feature structure to protect it from incidential modifications during encoding. The following example is taken from the ''pl::ipipan'' driver, which was the first place where the solution was applied.
 +
 +<code perl>    my $f0 = shift;
 +    # Modify the feature structure so that it contains values expected by this
 +    # driver. Do not do that if this was also the source tagset (because the
 +    # modification would damage tags using 'other'). However, in any case
 +    # create a deep copy of the original feature structure so that it is
 +    # protected from changes during encoding.
 +    my $f;
 +    if($f0->{tagset} eq 'pl::ipipan')
 +    {
 +        $f = tagset::common::duplicate($f0);
 +    }
 +    else
 +    {
 +        $f = tagset::common::enforce_permitted_joint($f0, $permitted);
 +    }
 +    my %f = %{$f};
 +</code>
  
 ===== Common problems ===== ===== Common problems =====

[ Back to the navigation ] [ Back to the content ]