lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another patch (this one is important) to abc2ly


From: Juergen Reuter
Subject: Re: Another patch (this one is important) to abc2ly
Date: Wed, 4 Oct 2006 15:02:29 +0200 (CEST)

On Mon, 2 Oct 2006, Laura Conrad wrote:

I just tested it and in actual code, yours seems to do the same thing
mine does,

N.B.: There should be a minor difference in the handling of white space before/after the hyphen, which however is not essential, I guess.

except I find it harder to read.  What do you think is the
advantage of yours over mine?


Your approach

     a = re.sub ( '-', '- ', a)        # split words with -

applies a rule which holds for most cases, but not all cases. Therefore, you introduce another rule

+    a = re.sub ( ' - - ', ' -- ', a)  # unless was originally " -- "

to compensate for the error in the first rule. Why not fixing the original rule rather than adding another rule for compensation? Compensation usually increases the oevrall complexity and thereby makes the code difficult to understand.

As far as readability is concerned, well, this probably depends on the point of view. Looking at your compensation rule, I find it difficult to understand, as it is not immediately clear to me, what happens if e.g. you have "---" or similar. My suggested rule simply says: replace "-" by "- " if and only if there is not another "-" immediately before or after the "-", and no further compensation is needed (hopefully). This is quite clear to understand, isn't it? ;-)

The code I tested on was:

  The normal way to type multiple syllables in ABC:

  a = "mul- ti- ple syl- la- bles"

Where your version produces:
a = re.sub ( '([^-])-([^-])', '\\1- \\2', a)
print a
mul-  ti-  ple-  syl-  la-  bles

...

There shouldn't be a hyphen after "ple".  I hope, that's just a typo?

Greetings,
Juergen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]