← Back to team overview

openlp-core team mailing list archive

Re: [Merge] lp:~orangeshirt/openlp/bibles into lp:openlp

 

> It is difficult for me to understand your code (or maybe it is too late and I
> should go to bed).

What other points are difficult to understand or did you mean the whole thing?
I would try to explain it.
My main strategy to find a solution is to take always the book_reference_id instead of the name, because this id is independent from the language. In Advanced Search this isn't to difficult, but in Quicksearch this isn't possible and so I first have to find out which book the user want, to match the correct book_reference_id.
(I hope this helps you to understand my solution)

> For example: What are you doing in line 167?

My thought was that e.g. "ma" only matches "Mark" or "Matthew" and not "Romans" and that the numbers are optional in order that "cor" matches with "1 Corinther" instead of throwing an error.

But if i realize after reading your lines I didn't realize the specieal characters in a regex. And that is possible for the user to write regular expressions. That wasn't the way I want to go.
And your right too. The dot was inspired by my german mindset.
 
> My suggestion:
> Make hard decission.
> If you want to make it the best way possible:
> Take the match.group(u'book') string, and escape all reserved characters:
> # escape reserved characters
>         for character in u'\\.^$*+?{}[]()':
>             bookname = bookname.replace(character, u'\\' + character)
> Then you can replace all whitespaces by a abriatary number of whitespaces and
> make a caseinsensitivematch:
> re.compile(u'\s*%s\s*' % u'\s*'.join(bookname.split()), re.UNICODE |
> re.IGNORECASE)
> Use regex.match() and not regexp.search(). Otherwhise John would be found in
> the Epistle of John as well. (And users will enter two-letter shortcuts and
> find something completely different)

Thanks for your suggestion. And for the explanation of the difference of match and search. I read the doc more than one time, but I always read over the little phrase "at the beginning" in the description of match.
I'll change the code and test your solution in next time.



-- 
https://code.launchpad.net/~orangeshirt/openlp/bibles/+merge/95805
Your team OpenLP Core is subscribed to branch lp:openlp.


References