SE

Frederic Rentsch anthra.norell at vtxmail.ch
Fri Nov 3 13:09:35 EST 2006


C or L Smith wrote:
> Hello,
>
> I'm evaluating different methods of handling a transliteration (from an ascii-based representation of the devanagari/indian script to a romanized representation). I found SE and have been working with it today. One thing that I ran into (that I don't see a reason for right off) is the behavior where a single period just gets eaten and no output is produced:
>
>   
>>>> import SE
>>>> s=SE.SE('.=period')
>>>> s('A.')
>>>>         
> 'Aperiod'
>   
>>>> s('.')
>>>>         
>
> It's not the fact that it's a single character target that is causing the problem:
>
>   
>>>> s=SE.SE('x=y')
>>>> s('x')
>>>>         
> 'y'
>
> I also tried the following:
>
>   
>>>> s=SE.SE('(46)=dot')
>>>> s('A.')
>>>>         
> 'Adot'
>   
>>>> s('.')
>>>>         
>
> Am I missing something?
>
> /chris
>
>
>   

No, you are not missing anything. Quite on the contrary. You caught 
something! Thanks for the report.

Here's the patch:

Line 343 in SEL.py is:  if name == '':

Make it:                if name.replace ('.', '') == '':

In Version 2.2 it's line 338. But Version 2.2 should be phased out anyway.

The problem had to do with the automatic typing of the input data that 
tells string input from file names, which of course are also strings. 
The test is done by os.stat (). If it says an input string is an 
existing file, then that file is translated. Admittedly this is not a 
very robust mechanism. In practice, though, I have never had a problem 
with it, because input data just about never are single words. If names 
of existing files are the object of a translation they would be passed 
all together and be unambiguously recognized as a string. To translate a 
single file name SE is hardly a means of choice, but it could still be 
done if the file name is given a leading space.
   Now, if a single dot (or multiple dots) come along, os.stat does not 
raise an error and that results in a typing error at that point. The 
patch above takes care of that.

Frederic



















More information about the Python-list mailing list