Issue Details (XML | Word | Printable)

Key: LUCENE-1032
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Andrew Lynch
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

CJKAnalyzer should convert half width katakana to full width katakana

Created: 25/Oct/07 06:14 AM   Updated: 11/Mar/08 05:30 AM
Return to search
Component/s: Analysis
Affects Version/s: 2.0.0
Fix Version/s: None

Time Tracking:
Not Specified

Lucene Fields: New


 Description  « Hide
Some of our Japanese customers are reporting errors when performing searches using half width characters.
The desired behavior is that a document containing half width characters should be returned when performing a search using full width equivalents or when searching by the half width character itself.
Currently, a search will not return any matches for half width characters.

Here is a test case outlining desired behavior (this may require a new Analyzer).

public class TestJapaneseEncodings extends TestCase
{

    byte[] fullWidthKa = new byte[]{(byte) 0xE3, (byte) 0x82, (byte) 0xAB};
    byte[] halfWidthKa = new byte[]{(byte) 0xEF, (byte) 0xBD, (byte) 0xB6};

    public void testAnalyzerWithHalfWidth() throws IOException
    {
        Reader r1 = new StringReader(makeHalfWidthKa());
        TokenStream stream = new CJKAnalyzer().tokenStream("foo", r1);
        assertNotNull(stream);
        Token token = stream.next();
        assertNotNull(token);
        assertEquals(makeFullWidthKa(), token.termText());
    }

    public void testAnalyzerWithFullWidth() throws IOException
    {
        Reader r1 = new StringReader(makeFullWidthKa());
        TokenStream stream = new CJKAnalyzer().tokenStream("foo", r1);
        assertEquals(makeFullWidthKa(), stream.next().termText());
    }

    private String makeFullWidthKa() throws UnsupportedEncodingException
    {
        return new String(fullWidthKa, "UTF-8");
    }

    private String makeHalfWidthKa() throws UnsupportedEncodingException
    {
        return new String(halfWidthKa, "UTF-8");
    }
}


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Hiroaki Kawai added a comment - 11/Mar/08 05:30 AM
I think this feature should merged to https://issues.apache.org/jira/browse/LUCENE-1215

Unicode compatibility decomposition will fix this issue.