Changeset 95

Show
Ignore:
Timestamp:
07/17/06 16:12:39 (2 years ago)
Author:
robin
Message:

bugfix: ensure a plural param matched as the last field picks up all the tail words

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freeform/trunk/freeform/match.py

    r48 r95  
    229229        #_debug_current_production(match, candidateforms, formfieldtypes, 
    230230        #    ifield-1,ifield,iword,ipluralstart,fieldcount-1) 
     231    # if the last field was a plural, make sure we collect all the trailing 
     232    # words. 
     233    if ipluralstart > -1: 
     234        match[-1].extend(words[iword:]) 
    231235    return match, candidateforms 
    232236 
  • freeform/trunk/freeform_tests/profile_match.py

    r50 r95  
    88 
    99try: 
    10     import hotshot, hotshot.stats 
     10    #import hotshot, hotshot.stats 
    1111    PROFILE=1 
    1212except ImportError: 
  • freeform/trunk/freeform_tests/test_match.py

    r48 r95  
    199199 
    200200class TestDisambiguation(unittest.TestCase): 
     201    def test_plurals_as_last_candidatefield(self): 
     202        compiler = self.compiler 
     203        commandforms,e = compiler(['''\ 
     204easy_track: 
     205    easytrac {label} {location} from {track(s)};''']) 
     206        formtable = formtable_prepare(create_formtable(*commandforms)) 
     207        result = match_command(formtable, 
     208            'easytrac barnwel-1 barnwell from tG,tS:0,60 0,60 25,40'.split()) 
     209        self.assertNotEqual(result, None) 
     210        self.assertNotEqual(result[0], None) 
     211        (cmd,form),valuemap=result 
     212        self.assertEqual(cmd, 'easy_track') 
     213        self.assertEqual(valuemap.has_key('track'), True) 
     214        self.assertEqual(len(valuemap['track'][0]), 3) 
     215 
    201216    def _generic_source_tests(self, name, compiler = None): 
    202217        compiler = compiler or self.compiler