You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Uwe Schindler (Issue Comment Edited) (JIRA)" <ji...@apache.org> on 2011/12/29 11:45:32 UTC

[jira] [Issue Comment Edited] (LUCENE-2906) Filter to process output of ICUTokenizer and create overlapping bigrams for CJK

    [ https://issues.apache.org/jira/browse/LUCENE-2906?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13177097#comment-13177097 ] 

Uwe Schindler edited comment on LUCENE-2906 at 12/29/11 10:44 AM:
------------------------------------------------------------------

Hi Robert,

I had no time to review before, there is one small thing that should maybe fixed. Currently this finter relies on the fact that TypeAttribute strings are interned, as it compares by identity:

{code:java}
String type = typeAtt.type();
if (type == doHan || type == doHiragana || type == doKatakana || type == doHangul) {
{code}

This is documented nowhere that Strings in TypeAttribute need to be interned. We should maybe replace that check by a simple equals(). It seems that you already wanted to do that, as you added a sentinel value Object NO = new Object(). -With the above check this sentinel value is useless, a simple null would be enough-. *EDIT:* Sentinel value is also useful for not enabling bigramming is a Tokenizer sets "null" as TypeAttribute. When using equals() this sentinel makes real sense. The check is not costly. String.equals() already does an identity check for early exit, if the sentinel is used it will also quickly return false (if String.equals(sentinel) is used, it will return false on instanceof Check, if you call sentinel.equals(String) it will even be faster).

So I would change this check to:

{code:java}
String type = typeAtt.type();
if (doHan.equals(type) || doHiragana.equals(type) || doKatakana.equals(type) || doHangul.equals(type)) {
{code}

(this is the fastest check, if the doXXX is the sentinel, it's default Object.equals() will return false. If its a string, String.equals() will return true on identity very quick, but if it's not interned it will be slower. So we loose nothing but dont require useless interned strings.
                
      was (Author: thetaphi):
    Hi Robert,

I had no time to review before, there is one small thing that should maybe fixed. Currently this finter relies on the fact that TypeAttribute strings are interned, as it compares by identity:

{code:java}
String type = typeAtt.type();
if (type == doHan || type == doHiragana || type == doKatakana || type == doHangul) {
{code}

This is documented nowhere that Strings in TypeAttribute need to be interned. We should maybe replace that check by a simple equals(). It seems that you already wanted to do that, as you added a sentinel value Object NO = new Object(). With the above check this sentinel value is useless, a simple null would be enough. But when using equals() this sentinel makes sense. The check is not costly. String.equals() already does an identity check for early exit, if the sentinel is used it will also quickly return false (if String.equals(sentinel) is used, it will return false on instanceof Check, if you call sentinel.equals(String) it will even be faster).

So I would change this check to:

{code:java}
String type = typeAtt.type();
if (doHan.equals(type) || doHiragana.equals(type) || doKatakana.equals(type) || doHangul.equals(type)) {
{code}

(this is the fastest check, if the doXXX is the sentinel, it's default Object.equals() will return false. If its a string, String.equals() will return true on identity very quick, but if it's not interned it will be slower. So we loose nothing but dont require useless interned strings.
                  
> Filter to process output of ICUTokenizer and create overlapping bigrams for CJK 
> --------------------------------------------------------------------------------
>
>                 Key: LUCENE-2906
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2906
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: modules/analysis
>            Reporter: Tom Burton-West
>            Assignee: Robert Muir
>            Priority: Minor
>             Fix For: 3.6, 4.0
>
>         Attachments: LUCENE-2906.patch, LUCENE-2906.patch, LUCENE-2906.patch, LUCENE-2906.patch
>
>
> The ICUTokenizer produces unigrams for CJK. We would like to use the ICUTokenizer but have overlapping bigrams created for CJK as in the CJK Analyzer.  This filter would take the output of the ICUtokenizer, read the ScriptAttribute and for selected scripts (Han, Kana), would produce overlapping bigrams.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org