in reply to Implication is not enough

My first thought is that perhaps you are using your logic backwards. Instead of progressing through a list of possibilities, it might be better to test in reverse.

Admittedly my familiarity with German is limited to reading road signs and asking the border guards if we were entering or leaving Germany, as winding through the alps along the border you can lose track of that sort of thing, the road following geography more than political boundaries.

Maybe what you are saying is this:
$g = "m"; $q = "singular"; if ($word =~ /en$/) { $g = "f"; $q = "plural" if ($word =~ /inen$/); }
Of course, I am just condensing your logic here.

The big question is "Where are you going with this?", because that will have a large bearing on the sophistication of your methodology.

Replies are listed 'Best First'.
Re^2: Implication is not enough
by tadman (Prior) on Jul 30, 2001 at 17:32 UTC
    I might be missing the boat here, but "Ägypterinen" would match both if statements, meaning at the end you would have $g = "f", $q = "plural", which I can only presume is the intent of the exercise.

    Like you pointed out, though, this is just a bunch of if statements, and goes one way only.

    However, you really haven't given any idea as to where you're going with this, other than some loose hints. Are you trying to write a parser for German, or a sub-set of German, or a parser that can work on any language, including German. The scope is important.

    First, I would try and express the rules in Perl using some sort of data structure. In many cases, the design of your algorithm can come straight from your data design. In others, it is the other way around. Either way, you have to start somewhere, so if you have no idea how to implement it, at least you can describe it.
Re: Re: Implication is not enough
by PetaMem (Priest) on Jul 30, 2001 at 17:21 UTC
    Hi,

    That way, you stil have *only* implication but changed
    the precedence of some steps (badly). Look:

    If the word you get to test would be "Ägypterinen", you
    never would come to the guts of if($word =~ /en$/)

    Ok. Where am I going with this? Well - theres no correct
    or complete morphological parser of the german language as
    of today. I could write one, but I would like to write it
    elegantly. Seems I´m missing a feature in Perl. Or just
    some decent way to craft code that can potentially both
    analyze and generate.

    The task is easy.
    
    Given 3 german words. Ägypter, Ägypterin, Ägypterinen
    
    Write a routine that takes a list of 3 Arguments:
    word, genus, numerus.
    
    and returns a list of 3 elements:
    word, genus, numerus
    
    where "word" is the word that was given to the routine
    after applying genus and numerus to it.
    genus and numerus are the genus and numerus the word HAD
    BEFORE applying the new genus and numerus to it.
    
    Like so:
    sub mystical_de_morphology_ruleprocessor { my $word = shift; my $new_genus = shift; my $new_numerus = shift; TRY_RULE1: (word (m,sg) <-> word + "in" (f, sg)) TRY_RULE2: (word (f,sg) <-> word + "en" (f,pl)) return newword, old_gen, old_num; }
    The TRY_RULE part is it. I just want to apply rules
    2 rules = 4 IFs, 3 rules = 8 IFs, 10 rules = forget it.
    Prolog would be nice, but I want stick with perl for that.

    Ciao