# File lib/linguistics/en/infinitive.rb, line 1048
    def infinitive( word )
        word = word.to_s
        word1 = word2 = suffix = rule = newword = ''

        if IrregularInfinitives.key?( word )
            word1    = IrregularInfinitives[ word ]
            rule = 'irregular'
        else
            # Build up $prefix{$suffix} as an array of prefixes, from longest to shortest.
            prefix, suffix = nil
            prefixes = Hash::new {|hsh,key| hsh[key] = []}

            # Build the hash of prefixes for the word
            1.upto( word.length ) {|i|
                prefix = word[0, i]
                suffix = word[i..-1]

                (suffix.length - 1).downto( 0 ) {|j|
                    newword = prefix + suffix[0, j]
                    prefixes[ suffix ].push( newword )
                }
            }

            $stderr.puts "prefixes: %p" % prefixes if $DEBUG

            # Now check for rules covering the prefixes for this word, picking
            # the first one if one was found.
            if (( suffix = ((InfSuffixRuleOrder & prefixes.keys).first) ))
                rule = InfSuffixRules[ suffix ][:rule]
                shortestPrefix = InfSuffixRules[ suffix ][:word1]
                $stderr.puts "Using rule %p (%p) for suffix %p" % 
                    [ rule, shortestPrefix, suffix ] if $DEBUG

                case shortestPrefix
                when 0
                    word1 = prefixes[ suffix ][ 0 ]
                    word2 = prefixes[ suffix ][ 1 ]
                    $stderr.puts "For sp = 0: word1: %p, word2: %p" %
                        [ word1, word2 ] if $DEBUG

                when -1
                    word1 = prefixes[ suffix ].last +
                        InfSuffixRules[ suffix ][:suffix1]
                    word2 = ''
                    $stderr.puts "For sp = -1: word1: %p, word2: %p" %
                        [ word1, word2 ] if $DEBUG

                when -2
                    word1 = prefixes[ suffix ].last +
                        InfSuffixRules[ suffix ][:suffix1]
                    word2 = prefixes[ suffix ].last
                    $stderr.puts "For sp = -2: word1: %p, word2: %p" %
                        [ word1, word2 ] if $DEBUG

                when -3
                    word1 = prefixes[ suffix ].last +
                        InfSuffixRules[ suffix ][:suffix1]
                    word2 = prefixes[ suffix ].last +
                        InfSuffixRules[ suffix ][:suffix2]
                    $stderr.puts "For sp = -3: word1: %p, word2: %p" %
                        [ word1, word2 ] if $DEBUG

                when -4
                    word1 = word
                    word2 = ''
                    $stderr.puts "For sp = -4: word1: %p, word2: %p" %
                        [ word1, word2 ] if $DEBUG

                else
                    raise IndexError,
                        "Couldn't find rule for shortest prefix %p" %
                        shortestPrefix
                end

                # Rules 12b and 15: Strip off 'ed' or 'ing'.
                if rule == '12b' or rule == '15'
                    # Do we have a monosyllable of this form:
                    # o 0+ Consonants
                    # o 1+ Vowel
                    # o    2 Non-wx
                    # Eg: tipped => tipp?
                    # Then return tip and tipp.
                    # Eg: swimming => swimm?
                    # Then return tipswim and swimm.

                    if /^([^aeiou]*[aeiou]+)([^wx])\2$/ =~ word2
                        word1 = $1 + $2
                        word2 = $1 + $2 + $2
                    end
                end
            end
        end

        return Infinitive::new( word1, word2, suffix, rule )
    end