lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "janwen"<tom.grade1...@163.com>
Subject Re: Re: Phonetic search with Lucene 3.2
Date Thu, 10 Nov 2011 03:41:31 GMT
paul:
   I visited the site you provide and explore the example,but i can not understand the results
from the following example.I thought 
the phonetix is an tel-no analyzer like 010-134323434,400-2343-2342-3234,could you tell me
some more info about this,i need to index phone number in my project.thanks.
public class PhoneticTest
{
    public static void main(String[] argv)
    {
        Metaphone metaphone = new Metaphone();

        String original = "Phonetix";
        String encoded  = metaphone.generateKey(original);

        System.out.println("original="+original+", encoded="+encoded);
    }
}
After compiling and running this example program you will get an output like this:
original=Phonetix, encoded=FNTK




2011-11-10



janwen | China 
website : http://www.qianpin.com/




发件人: Paul Libbrecht <paul@hoplahup.net>
发送时间: 2011-11-09 18:38
主 题: Re: Phonetic search with Lucene 3.2
收件人: java-user@lucene.apache.org



We've been using 
    http://www.tangentum.biz/en/products/phonetix/ 
which does double-metaphone. 
Maybe that helps. 

paul 


Le 9 nov. 2011 à 11:29, Felipe Carvalho a écrit : 

> Using PerFieldAnalyzerWrapper seems to be working for what I need! 
>  
> On indexing: 
>  
>        PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new 
> StandardAnalyzer(Version.LUCENE_33)); 
>        wrapper.addAnalyzer("nome", new MetaphoneReplacementAnalyzer()); 
>        IndexWriterConfig indexWriterConfig = new 
> IndexWriterConfig(Version.LUCENE_33, wrapper); 
>        Directory directory = FSDirectory.open(new File(indexPath)); 
>        IndexWriter indexWriter = new IndexWriter(directory, 
> indexWriterConfig); 
>  
> On search: 
>  
>        Directory directory = FSDirectory.open(new 
> File(lastIndexDir(Calendar.getInstance()))); 
>        IndexSearcher is = new IndexSearcher(directory); 
>        PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new 
> StandardAnalyzer(Version.LUCENE_33)); 
>        wrapper.addAnalyzer("name", new MetaphoneReplacementAnalyzer()); 
>        QueryParser parser = new QueryParser(Version.LUCENE_33, "name", 
> wrapper); 
>        Query query = parser.parse(expression); 
>        ScoreDoc[] hits = is.search(query, 1000).scoreDocs; 
>  
> Does anyone know any other phonetic analyzer implementation? I'm using 
> MetaphoneReplacementAnalyzer from LIA examples. 
>  
> I'm looking at lucene-contrib stuff at 
> http://lucene.apache.org/java/3_4_0/lucene-contrib/index.html but I can't 
> seem to find other phonetic analyzers. 
>  
> Thanks! 
>  
>  
> On Tue, Nov 8, 2011 at 12:19 PM, Erik Hatcher <erik.hatcher@gmail.com>wrote: 
>  
>>  
>> On Nov 8, 2011, at 05:42 , Felipe Carvalho wrote: 
>>>> Yes, quite possible, including boosting on exact matches if you want. 
>> Use 
>>>> a BooleanQuery to wrap clauses parsed once with phonetic analysis, and 
>> once 
>>>> without, including fields at indexing time for both too of course. 
>>>>  
>>>  
>>> Would it be possible to point to an example where this is done. The best 
>>> example of a BooleanQuery I've found so far is this one: 
>>>  
>> http://www.avajava.com/tutorials/lessons/how-do-i-combine-queries-with-a-boolean-query.html

>>>  
>>> But I couldn't find a boolean query using different analyzers for 
>> different 
>>> fields of the attribute. 
>>  
>> You could use two different QueryParser instances with different 
>> analyzers.  Or use the PerFieldAnalyzerWrapper, though you'll still need to 
>> instances in order to have a different default field for each expression. 
>> But then use the techniques you saw in that article (or in Lucene in 
>> Action, since you mentioned having that) to combine Query objects into a 
>> BooleanQuery. 
>>  
>>       Erik 
>>  
>>  
>> --------------------------------------------------------------------- 
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org 
>> For additional commands, e-mail: java-user-help@lucene.apache.org 
>>  
>>  


--------------------------------------------------------------------- 
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org 
For additional commands, e-mail: java-user-help@lucene.apache.org 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message