Possible bug using FLAG_WORD_BREAKS with fullwidth Unicode codepoints

Olly Betts olly at survex.com
Sun Jan 7 18:45:10 GMT 2024


On Thu, Jan 04, 2024 at 05:50:22PM +0100, Robert Stepanek wrote:
> Since I am undecided yet if and how to fix this in Xapian I haven't
> come up with a pull request. Because trac currently is offline, I
> could not file a bug. I hope it's OK to post my analysis here first,
> I'll be happy to follow up reporting that bug proper later (should we
> conclude that it actually is a bug).

I've restarted trac.

> Still, I do think it is a bug for Xapian not to return a result when
> querying for a term that's verbatim in the original input and the
> database. Should you agree I will be happy to discuss how to fix this
> and might come up with a pull request once we agreed on a solution.

I think the cause is that the list of ranges of characters which need
word breaks findings includes this block of full- and half-width latin
forms, coupled with an assumption that there's no lowercase vs uppercase
forms in these alphabets.

Assuming the latter is valid, just removing this block (or removing the
parts of it which are Lu or Ll) should fix the problem as then
tokenisation will switch mode - I tried this and it fixes your case at
least:

diff --git a/xapian-core/queryparser/word-breaker.cc b/xapian-core/queryparser/word-breaker.cc
index 8108523ccd53..4fabc23f4b56 100644
--- a/xapian-core/queryparser/word-breaker.cc
+++ b/xapian-core/queryparser/word-breaker.cc
@@ -103,7 +103,7 @@ is_unbroken_script(unsigned p)
 	// FE30..FE4F; CJK Compatibility Forms
 	0xFE30 - 1, 0xFE4F,
 	// FF00..FFEF; Halfwidth and Fullwidth Forms
-	0xFF00 - 1, 0xFFEF,
+	//0xFF00 - 1, 0xFFEF,
 	// 1AFF0..1AFFF; Kana Extended-B
 	// 1B000..1B0FF; Kana Supplement
 	// 1B100..1B12F; Kana Extended-A

If we're fixing it this way we should check this list for other
instances of this (and doing this would probably reveal if that
assumption is valid).

Cheers,
    Olly



More information about the Xapian-devel mailing list