You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Mohammad Norouzi <mn...@gmail.com> on 2007/05/22 11:29:17 UTC
regaridng Reader.terms()
Hi all
consider following index
field1 field2 field3
text1 text1 text2 text3 text4
text4 text2 text2 text3 text5
I want to get all terms in filed3
if I use Reader.terms() it will returns: (however i have to put an if
statement to filter result of the field3 only)
text3
text4
text2
text5
but I need following result:
"text3 text4"
"text2 text3 text5"
is this possible? if yes, how? and if no, is there any tricky way to get
this result?
thank you so much.
--
Regards,
Mohammad Norouzi
--------------------------
see my blog: http://brainable.blogspot.com/
Re: WhitespaceAnalyzer [was: Re: regaridng Reader.terms()]
Posted by Steven Rowe <sa...@syr.edu>.
Hi Mohammad,
Mohammad Norouzi wrote:
> [Hoss wrote:]
>> ...are there Persian characters with a category type of SPACE_SEPARATOR,
>> LINE_SEPARATOR, or PARAGRAPH_SEPARATOR ?
>
> How can I know that?
The Unicode standard's codes[1] for these are:
SPACE SEPARATOR: Zs
LINE SEPARATOR: Zl
PARAGRAPH SEPARATOR: Zp
>From <http://www.unicode.org/Public/4.0-Update/PropList-4.0.0.txt>, the
only characters with these properties are:
0020 ; White_Space # Zs SPACE
00A0 ; White_Space # Zs NO-BREAK SPACE
1680 ; White_Space # Zs OGHAM SPACE MARK
180E ; White_Space # Zs MONGOLIAN VOWEL SEPARATOR
2000..200A ; White_Space # Zs EN QUAD..HAIR SPACE
200B ; Other_Default_Ignorable_Code_Point # Zs ZERO WIDTH SPACE
2028 ; White_Space # Zl LINE SEPARATOR
2029 ; White_Space # Zp PARAGRAPH SEPARATOR
202F ; White_Space # Zs NARROW NO-BREAK SPACE
205F ; White_Space # Zs MEDIUM MATHEMATICAL SPACE
3000 ; White_Space # Zs IDEOGRAPHIC SPACE
Modern Persian uses Arabic orthography with four additional letters[2]
-- peh, tcheh, jeh, and gaf -- all of which are included in the Unicode
basic Arabic character set.
The Arabic Unicode character ranges are:
[U+0600 - U+06FF] <http://www.unicode.org/charts/PDF/U0600.pdf>
[U+0750 - U+077F] <http://www.unicode.org/charts/PDF/U0750.pdf>
[U+FB50 - U+FC3F] <http://www.unicode.org/charts/PDF/UFB50.pdf>
[U+FE70 - U+FEFF] <http://www.unicode.org/charts/PDF/UFE70.pdf>
The intersection of the sets { all Arabic characters } and { all Unicode
whitespace characters } is the null set. Thus, it appears, there are no
Arabic-specific (and hence Persian-specific) whitespace characters in
the Unicode standard.
Steve
[1] Unicode 4.0.0 Character Database - Property value codes:
<http://www.unicode.org/Public/4.0-Update/UCD-4.0.0.html#Property_Values>
[2] http://en.wikipedia.org/wiki/Persian_alphabet
--
Steve Rowe
Center for Natural Language Processing
http://www.cnlp.org/tech/lucene.asp
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: WhitespaceAnalyzer [was: Re: regaridng Reader.terms()]
Posted by Mohammad Norouzi <mn...@gmail.com>.
Hi Chris,
>
> * It is a Unicode space character (SPACE_SEPARATOR, LINE_SEPARATOR, or
> PARAGRAPH_SEPARATOR) but is not also a non-breaking space ('\u00A0',
> '\u2007', '\u202F').
> * It is '\u0009', HORIZONTAL TABULATION.
> * It is '\u000A', LINE FEED.
> * It is '\u000B', VERTICAL TABULATION.
> * It is '\u000C', FORM FEED.
> * It is '\u000D', CARRIAGE RETURN.
> * It is '\u001C', FILE SEPARATOR.
> * It is '\u001D', GROUP SEPARATOR.
> * It is '\u001E', RECORD SEPARATOR.
> * It is '\u001F', UNIT SEPARATOR.
...are there Persian characters with a category type of SPACE_SEPARATOR,
> LINE_SEPARATOR, or PARAGRAPH_SEPARATOR ?
>
>
>
How can I know that?
--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
Re: WhitespaceAnalyzer [was: Re: regaridng Reader.terms()]
Posted by Chris Hostetter <ho...@fucit.org>.
: return !Character.isWhitespace(c);
: And my class override that method as this:
: return !((int)c==32);
in my opinion that's a pretty naive change ... it won't split on tab
characters or newlines ... even for trivial ASCII text that's probably not
what you want.
: I think the Character.isWhitespace consider the unicodes as space :))
: so everything will mess up.
every character in java is a unicode character, so your comment doesn't
really make sense to me ... the javadocs are very clear about the
definition of "whitesace" in java...
* It is a Unicode space character (SPACE_SEPARATOR, LINE_SEPARATOR, or
PARAGRAPH_SEPARATOR) but is not also a non-breaking space ('\u00A0',
'\u2007', '\u202F').
* It is '\u0009', HORIZONTAL TABULATION.
* It is '\u000A', LINE FEED.
* It is '\u000B', VERTICAL TABULATION.
* It is '\u000C', FORM FEED.
* It is '\u000D', CARRIAGE RETURN.
* It is '\u001C', FILE SEPARATOR.
* It is '\u001D', GROUP SEPARATOR.
* It is '\u001E', RECORD SEPARATOR.
* It is '\u001F', UNIT SEPARATOR.
...are there Persian characters with a category type of SPACE_SEPARATOR,
LINE_SEPARATOR, or PARAGRAPH_SEPARATOR ?
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: WhitespaceAnalyzer [was: Re: regaridng Reader.terms()]
Posted by Mohammad Norouzi <mn...@gmail.com>.
Sorry Steven
that change is in WhitespaceTokenizer not WhiteSpaceAnalyzer but in Analyzer
I had to call the tokenizer
On 5/24/07, Mohammad Norouzi <mn...@gmail.com> wrote:
>
> Hi Steven
> Thank you so much for your thorough comments about Analyzer
>
> I write that class a couple of months ago, now I take a look at my
> customized Analyzer
>
> the only change I've made as follows:
>
> the original class has this method:
> protected boolean isTokenChar(char c) {
> return !Character.isWhitespace(c);
> }
>
> And my class override that method as this:
>
> protected boolean isTokenChar(char c) {
> return !((int)c==32);
> }
>
>
> I think the Character.isWhitespace consider the unicodes as space :))
> so everything will mess up.
>
> what do you think?
>
> --
> Regards,
> Mohammad
> --------------------------
> see my blog: http://brainable.blogspot.com/
--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
Re: WhitespaceAnalyzer [was: Re: regaridng Reader.terms()]
Posted by Mohammad Norouzi <mn...@gmail.com>.
Hi Steven
Thank you so much for your thorough comments about Analyzer
I write that class a couple of months ago, now I take a look at my
customized Analyzer
the only change I've made as follows:
the original class has this method:
protected boolean isTokenChar(char c) {
return !Character.isWhitespace(c);
}
And my class override that method as this:
protected boolean isTokenChar(char c) {
return !((int)c==32);
}
I think the Character.isWhitespace consider the unicodes as space :))
so everything will mess up.
what do you think?
--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
WhitespaceAnalyzer [was: Re: regaridng Reader.terms()]
Posted by Steven Rowe <sa...@syr.edu>.
Hi Mohammad,
WhitespaceAnalyzer uses Java's Character.isWhitespace(char) method to
determine whether or not a character should be part of a token. As far
as I know, this method is problematic only for characters outside of the
Basic Multilingual Plane (BMP). I think Lucene should switch to using
the int-based character methods, to support characters outside of the BMP.
Arabic characters are all in the BMP[1][2][3][4], so this method should
work properly. The only Arabic or Persian characters I can find outside
of the BMP are in the Old Persian block[5], [ U+103A0 - U+103DF ], but
this is ancient cuneiform - are you really dealing with digital
cuneiform documents?
I suspect that you are using WhitespaceAnalyzer as the basis for a more
sophisticated tokenizer - if this is true, you may want to check out the
tokenizer in the AraMorph project[6][7]. (The AraMorph stemmer probably
will not serve your needs, though, since Persian and Arabic have
different lexicons and grammars.)
Hope it helps,
Steve
[1] Arabic: http://www.unicode.org/charts/PDF/U0600.pdf
[2] Arabic Supplement: http://www.unicode.org/charts/PDF/U0750.pdf
[3] Arabic Presentation Forms A: http://www.unicode.org/charts/PDF/UFB50.pdf
[4] Arabic Presentation Forms B: http://www.unicode.org/charts/PDF/UFE70.pdf
[5] Old Persian: http://www.unicode.org/charts/PDF/U103A0.pdf
[6] AraMorph: http://www.nongnu.org/aramorph/
[7] ArabicTokenizer for Lucene:
http://www.nongnu.org/aramorph/javadoc/gpl/pierrick/brihaye/aramorph/lucene/ArabicTokenizer.html
Mohammad Norouzi wrote:
> Hi Steve,
> No I didn't make any change on WhiteSpaceAnalyzer I just extends my classes
> from the original classes and then override my new changes. so I dont think
> I should to contribute my classes.
>
> and my language is Persian, and only change I've made is not to ignoring
> unicode characters in Persian and arabic language, because with original
> WhitespaceAnalyzer it didnt work fine whether it ignore or something
> else, I
> dont know but I extends my classes and now I am using my analyzer to index.
>
> On 5/22/07, Steven Rowe <sa...@syr.edu> wrote:
>>
>> Hi Mohammad,
>>
>> May I ask what your language is? And what kind of changes to
>> WhitespaceAnalyzer were required to make it work with your language?
>>
>> If you have made modifications to WhitespaceAnalyzer that are generally
>> useful, please consider contributing your changes back to the Lucene
>> project. There is some info here on how to get started:
>>
>> http://wiki.apache.org/jakarta-lucene/HowToContribute
>>
>> Thanks,
>> Steve
>>
>> Mohammad Norouzi wrote:
>> > Walter,
>> > Yes I am using a customized WhiteSpaceAnalyzer while indexing.
>> > I said customized because I realized that standard WhiteSpaceAnalyzer
>> dont
>> > accept unicode terms in my language so I make some change to support
>> that.
>> >
>> > but for reading no Analyzer is used
>> >
>> > if I want to get that result, which analyzer should I use?
>> >
>> > in my case, I dont need any boost factor or any other feature of
>> lucene,
>> I
>> > need just searching through the index.
>> >
>> >
>> > On 5/22/07, Walter Ferrara <wa...@ecomware.it> wrote:
>> >>
>> >> If Reader.terms() gives you:
>> >> text3
>> >> text4
>> >> while you expect
>> >> text3 text4
>> >>
>> >> you should change, I presume, the Analyzer, maybe writing your own
>> one.
>> >>
>> >> Mohammad Norouzi wrote:
>> >> > Hi all
>> >> >
>> >> > consider following index
>> >> >
>> >> > field1 field2 field3
>> >> > text1 text1 text2 text3 text4
>> >> > text4 text2 text2 text3 text5
>> >> >
>> >> > I want to get all terms in filed3
>> >> > if I use Reader.terms() it will returns: (however i have to put
>> an if
>> >> > statement to filter result of the field3 only)
>> >> > text3
>> >> > text4
>> >> > text2
>> >> > text5
>> >> >
>> >> > but I need following result:
>> >> > "text3 text4"
>> >> > "text2 text3 text5"
>> >> >
>> >> >
>> >> > is this possible? if yes, how? and if no, is there any tricky way to
>> >> get
>> >> > this result?
>> >> >
>> >> > thank you so much.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: regaridng Reader.terms()
Posted by Mohammad Norouzi <mn...@gmail.com>.
Hi Steve,
No I didn't make any change on WhiteSpaceAnalyzer I just extends my classes
from the original classes and then override my new changes. so I dont think
I should to contribute my classes.
and my language is Persian, and only change I've made is not to ignoring
unicode characters in Persian and arabic language, because with original
WhitespaceAnalyzer it didnt work fine whether it ignore or something else, I
dont know but I extends my classes and now I am using my analyzer to index.
On 5/22/07, Steven Rowe <sa...@syr.edu> wrote:
>
> Hi Mohammad,
>
> May I ask what your language is? And what kind of changes to
> WhitespaceAnalyzer were required to make it work with your language?
>
> If you have made modifications to WhitespaceAnalyzer that are generally
> useful, please consider contributing your changes back to the Lucene
> project. There is some info here on how to get started:
>
> http://wiki.apache.org/jakarta-lucene/HowToContribute
>
> Thanks,
> Steve
>
> Mohammad Norouzi wrote:
> > Walter,
> > Yes I am using a customized WhiteSpaceAnalyzer while indexing.
> > I said customized because I realized that standard WhiteSpaceAnalyzer
> dont
> > accept unicode terms in my language so I make some change to support
> that.
> >
> > but for reading no Analyzer is used
> >
> > if I want to get that result, which analyzer should I use?
> >
> > in my case, I dont need any boost factor or any other feature of lucene,
> I
> > need just searching through the index.
> >
> >
> > On 5/22/07, Walter Ferrara <wa...@ecomware.it> wrote:
> >>
> >> If Reader.terms() gives you:
> >> text3
> >> text4
> >> while you expect
> >> text3 text4
> >>
> >> you should change, I presume, the Analyzer, maybe writing your own one.
> >>
> >> Mohammad Norouzi wrote:
> >> > Hi all
> >> >
> >> > consider following index
> >> >
> >> > field1 field2 field3
> >> > text1 text1 text2 text3 text4
> >> > text4 text2 text2 text3 text5
> >> >
> >> > I want to get all terms in filed3
> >> > if I use Reader.terms() it will returns: (however i have to put an if
> >> > statement to filter result of the field3 only)
> >> > text3
> >> > text4
> >> > text2
> >> > text5
> >> >
> >> > but I need following result:
> >> > "text3 text4"
> >> > "text2 text3 text5"
> >> >
> >> >
> >> > is this possible? if yes, how? and if no, is there any tricky way to
> >> get
> >> > this result?
> >> >
> >> > thank you so much.
> >> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
>
--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
Re: regaridng Reader.terms()
Posted by Steven Rowe <sa...@syr.edu>.
Hi Mohammad,
May I ask what your language is? And what kind of changes to
WhitespaceAnalyzer were required to make it work with your language?
If you have made modifications to WhitespaceAnalyzer that are generally
useful, please consider contributing your changes back to the Lucene
project. There is some info here on how to get started:
http://wiki.apache.org/jakarta-lucene/HowToContribute
Thanks,
Steve
Mohammad Norouzi wrote:
> Walter,
> Yes I am using a customized WhiteSpaceAnalyzer while indexing.
> I said customized because I realized that standard WhiteSpaceAnalyzer dont
> accept unicode terms in my language so I make some change to support that.
>
> but for reading no Analyzer is used
>
> if I want to get that result, which analyzer should I use?
>
> in my case, I dont need any boost factor or any other feature of lucene, I
> need just searching through the index.
>
>
> On 5/22/07, Walter Ferrara <wa...@ecomware.it> wrote:
>>
>> If Reader.terms() gives you:
>> text3
>> text4
>> while you expect
>> text3 text4
>>
>> you should change, I presume, the Analyzer, maybe writing your own one.
>>
>> Mohammad Norouzi wrote:
>> > Hi all
>> >
>> > consider following index
>> >
>> > field1 field2 field3
>> > text1 text1 text2 text3 text4
>> > text4 text2 text2 text3 text5
>> >
>> > I want to get all terms in filed3
>> > if I use Reader.terms() it will returns: (however i have to put an if
>> > statement to filter result of the field3 only)
>> > text3
>> > text4
>> > text2
>> > text5
>> >
>> > but I need following result:
>> > "text3 text4"
>> > "text2 text3 text5"
>> >
>> >
>> > is this possible? if yes, how? and if no, is there any tricky way to
>> get
>> > this result?
>> >
>> > thank you so much.
>> >
>>
>>
>> ---------------------------------------------------------------------
>> 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
Re: regaridng Reader.terms()
Posted by Mohammad Norouzi <mn...@gmail.com>.
Wow, very nice comments
Thank you so much Erick. You really showed me the way
--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
Re: regaridng Reader.terms()
Posted by Erick Erickson <er...@gmail.com>.
You may have to index things twice, once for searching and once
UN_TOKENIZED for display. Say you have a bunch of service names
you want to display
service one
service two
service three
If you use WhitespaceAnalyzer, TOKENIZED you index the tokens
service (note, there are three of these)
one
two
three
and re-assembling them is a pain. If you used UN_TOKENIZED, you'd
add
service one
service two
service three
as exactly three terms.
Now, simply using TermEnum on that field will return your list. And you
won't
get duplicates even if you indexed "service one" twice.
Another possibility is to index a special document. Remember that not
all documents need to have the same fields. So, say you have a list of all
services. You could index a document with "extra_special_meta_field" that
contained a comma-delimited list of services, and just get *that* document
to
generate your list. A variant of this is to index the *same* field in your
extra-special doc, like
Document doc = new Document();
doc.add("special", "service one"...UN_TOKENIZED);
doc.add("special", "service two"... UN_TOKENIZED);
Now, once you have the document (perhaps do this at startup time), the
call Document.getValues("special") will return a list like
"service one"
"service two".
At least I'm pretty sure....
All this may be in left field, but I thought I'd mention it.
Best
Erick
On 5/23/07, Mohammad Norouzi <mn...@gmail.com> wrote:
>
> Hi Walter,
> let me explain my problem in detail
> I have a web page let user to create his own query simple
> for example a user want to locate a service with specific value. so he/she
> doesnt know exactly the name of the service so I have to provide a list of
> services available (say in a combo box) and after selecting the service
> now
> the user can enter the value for that service so I will build the
> appropriate query and send it to the lucene.
> but my problem is how to display all services? how can I extract the
> services from the index?
>
> I was thinking of IndexReader.terms() but I think because of using
> WhitespaceAnalyzer it returns word by word terms, but I need terms per
> document,
> if we consider a SQL , select distinct service_name from table_name
>
> is there a way to tackle this problem?
>
>
> --
> Regards,
> Mohammad
> --------------------------
> see my blog: http://brainable.blogspot.com/
>
Re: regaridng Reader.terms()
Posted by Mohammad Norouzi <mn...@gmail.com>.
Hi Walter,
let me explain my problem in detail
I have a web page let user to create his own query simple
for example a user want to locate a service with specific value. so he/she
doesnt know exactly the name of the service so I have to provide a list of
services available (say in a combo box) and after selecting the service now
the user can enter the value for that service so I will build the
appropriate query and send it to the lucene.
but my problem is how to display all services? how can I extract the
services from the index?
I was thinking of IndexReader.terms() but I think because of using
WhitespaceAnalyzer it returns word by word terms, but I need terms per
document,
if we consider a SQL , select distinct service_name from table_name
is there a way to tackle this problem?
--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
Re: regaridng Reader.terms()
Posted by Walter Ferrara <wa...@ecomware.it>.
Let's suppose you modify your WhitespaceAnalyzer not to use a
WhitespaceTokenizer, but a modified version of the Tokenizer which
token-ize not by space but by something else, like '/'. (this is just an
example of course).
So suppose your real txt document contain :
/text2 text3/text4 text5/text6
When you add this document to the index using the tokenizer I explained,
terms returned by indexreader.terms should be:
text2 text3
text4 text5
text6
Mohammad Norouzi wrote:
> Walter,
> Yes I am using a customized WhiteSpaceAnalyzer while indexing.
> I said customized because I realized that standard WhiteSpaceAnalyzer
> dont
> accept unicode terms in my language so I make some change to support
> that.
>
> but for reading no Analyzer is used
>
> if I want to get that result, which analyzer should I use?
>
> in my case, I dont need any boost factor or any other feature of
> lucene, I
> need just searching through the index.
>
>
> On 5/22/07, Walter Ferrara <wa...@ecomware.it> wrote:
>>
>> If Reader.terms() gives you:
>> text3
>> text4
>> while you expect
>> text3 text4
>>
>> you should change, I presume, the Analyzer, maybe writing your own one.
>>
>> Mohammad Norouzi wrote:
>> > Hi all
>> >
>> > consider following index
>> >
>> > field1 field2 field3
>> > text1 text1 text2 text3 text4
>> > text4 text2 text2 text3 text5
>> >
>> > I want to get all terms in filed3
>> > if I use Reader.terms() it will returns: (however i have to put an if
>> > statement to filter result of the field3 only)
>> > text3
>> > text4
>> > text2
>> > text5
>> >
>> > but I need following result:
>> > "text3 text4"
>> > "text2 text3 text5"
>> >
>> >
>> > is this possible? if yes, how? and if no, is there any tricky way
>> to get
>> > this result?
>> >
>> > thank you so much.
>> >
>>
>>
>> ---------------------------------------------------------------------
>> 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
Re: regaridng Reader.terms()
Posted by Mohammad Norouzi <mn...@gmail.com>.
Walter,
Yes I am using a customized WhiteSpaceAnalyzer while indexing.
I said customized because I realized that standard WhiteSpaceAnalyzer dont
accept unicode terms in my language so I make some change to support that.
but for reading no Analyzer is used
if I want to get that result, which analyzer should I use?
in my case, I dont need any boost factor or any other feature of lucene, I
need just searching through the index.
On 5/22/07, Walter Ferrara <wa...@ecomware.it> wrote:
>
> If Reader.terms() gives you:
> text3
> text4
> while you expect
> text3 text4
>
> you should change, I presume, the Analyzer, maybe writing your own one.
>
> Mohammad Norouzi wrote:
> > Hi all
> >
> > consider following index
> >
> > field1 field2 field3
> > text1 text1 text2 text3 text4
> > text4 text2 text2 text3 text5
> >
> > I want to get all terms in filed3
> > if I use Reader.terms() it will returns: (however i have to put an if
> > statement to filter result of the field3 only)
> > text3
> > text4
> > text2
> > text5
> >
> > but I need following result:
> > "text3 text4"
> > "text2 text3 text5"
> >
> >
> > is this possible? if yes, how? and if no, is there any tricky way to get
> > this result?
> >
> > thank you so much.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
Re: regaridng Reader.terms()
Posted by Walter Ferrara <wa...@ecomware.it>.
If Reader.terms() gives you:
text3
text4
while you expect
text3 text4
you should change, I presume, the Analyzer, maybe writing your own one.
Mohammad Norouzi wrote:
> Hi all
>
> consider following index
>
> field1 field2 field3
> text1 text1 text2 text3 text4
> text4 text2 text2 text3 text5
>
> I want to get all terms in filed3
> if I use Reader.terms() it will returns: (however i have to put an if
> statement to filter result of the field3 only)
> text3
> text4
> text2
> text5
>
> but I need following result:
> "text3 text4"
> "text2 text3 text5"
>
>
> is this possible? if yes, how? and if no, is there any tricky way to get
> this result?
>
> thank you so much.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: CAD files, Images
Posted by jim shirreffs <jp...@verizon.net>.
thank you for the reply, I knew the answer but was compelled to ask anyway.
CAD files like AutoCad/ProE/CaTia do contain some useful text and it is
possible to get at that and
index it. But mostly it's vectors and there is not much a text engine can do
with a vectors.
thanks again.
jim s
----- Original Message -----
From: "Erick Erickson" <er...@gmail.com>
To: <ja...@lucene.apache.org>
Sent: Wednesday, May 23, 2007 8:21 AM
Subject: Re: CAD files, Images
> No, you can only index text. It's the same thing as indexing HTML
> documents or XML documents. You index "important stuff" from
> the guts of the doc.
>
> So, if you can get some text out of these docs, you can index *that*,
> possibly along with page information that allows you to, say, display
> the relevant page in the original CAD app.
>
> But there's nothing in core Lucene that just takes a CAD doc and
> "does magic" to index it that I know of.
>
> Erick
>
> On 5/23/07, jim shirreffs <jp...@verizon.net> wrote:
>>
>> Is it possibe to index CAD formats such as AutoCad or CGM? I know some
>> commecail products (excalaber) claim to be able to do that? If so what
>> about
>> TIFF?
>>
>>
>> thanks
>> jim s
>>
>>
>> ---------------------------------------------------------------------
>> 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
Re: CAD files, Images
Posted by Erick Erickson <er...@gmail.com>.
No, you can only index text. It's the same thing as indexing HTML
documents or XML documents. You index "important stuff" from
the guts of the doc.
So, if you can get some text out of these docs, you can index *that*,
possibly along with page information that allows you to, say, display
the relevant page in the original CAD app.
But there's nothing in core Lucene that just takes a CAD doc and
"does magic" to index it that I know of.
Erick
On 5/23/07, jim shirreffs <jp...@verizon.net> wrote:
>
> Is it possibe to index CAD formats such as AutoCad or CGM? I know some
> commecail products (excalaber) claim to be able to do that? If so what
> about
> TIFF?
>
>
> thanks
> jim s
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
CAD files, Images
Posted by jim shirreffs <jp...@verizon.net>.
Is it possibe to index CAD formats such as AutoCad or CGM? I know some
commecail products (excalaber) claim to be able to do that? If so what about
TIFF?
thanks
jim s
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: regaridng Reader.terms()
Posted by Grant Ingersoll <gs...@apache.org>.
You have to turn on term vectors when indexing. Take a look at the
Field constructor that passes in TermVector.
-Grant
On May 22, 2007, at 8:09 AM, Mohammad Norouzi wrote:
>> I would use a term vector to get this. See
>> IndexReader.getTermFreqVector. You can get the term vector for just
>> field 3.
>
>
> Grant, thanks, in my case, getTermFreqVector returns null, I dont
> know why
> it accepts a docnumber as parameter, what is it? is that the same
> doc id?
> if yes it restrict the result for just one document, am I right?
>
>
>> Let's suppose you modify your WhitespaceAnalyzer not to use a
>> WhitespaceTokenizer, but a modified version of the Tokenizer which
>> token-ize not by space but by something else, like '/'. (this is
>> just an
>> example of course).
>> So suppose your real txt document contain :
>> /text2 text3/text4 text5/text6
>> When you add this document to the index using the tokenizer I
>> explained,
>> terms returned by indexreader.terms should be:
>> text2 text3
>> text4 text5
>> text6
>
> Walter, thank you so much, may I ask you a question:
> if I am using an analyzer, say, XYAnalyzer while indexing, is it
> affect on
> how to search?
> another thing that buffled me is that by using IndexReader.terms() no
> Analyzer specified so how it possible to do that?
>
> thank you again
>
>
>
> --
> Regards,
> Mohammad
> --------------------------
> see my blog: http://brainable.blogspot.com/
--------------------------
Grant Ingersoll
Center for Natural Language Processing
http://www.cnlp.org/tech/lucene.asp
Read the Lucene Java FAQ at http://wiki.apache.org/jakarta-lucene/
LuceneFAQ
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: regaridng Reader.terms()
Posted by Mohammad Norouzi <mn...@gmail.com>.
>I would use a term vector to get this. See
>IndexReader.getTermFreqVector. You can get the term vector for just
>field 3.
Grant, thanks, in my case, getTermFreqVector returns null, I dont know why
it accepts a docnumber as parameter, what is it? is that the same doc id?
if yes it restrict the result for just one document, am I right?
>Let's suppose you modify your WhitespaceAnalyzer not to use a
>WhitespaceTokenizer, but a modified version of the Tokenizer which
>token-ize not by space but by something else, like '/'. (this is just an
>example of course).
>So suppose your real txt document contain :
>/text2 text3/text4 text5/text6
>When you add this document to the index using the tokenizer I explained,
>terms returned by indexreader.terms should be:
>text2 text3
>text4 text5
>text6
Walter, thank you so much, may I ask you a question:
if I am using an analyzer, say, XYAnalyzer while indexing, is it affect on
how to search?
another thing that buffled me is that by using IndexReader.terms() no
Analyzer specified so how it possible to do that?
thank you again
--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
Re: regaridng Reader.terms()
Posted by Grant Ingersoll <gs...@apache.org>.
I would use a term vector to get this. See
IndexReader.getTermFreqVector. You can get the term vector for just
field 3.
-Grant
On May 22, 2007, at 5:29 AM, Mohammad Norouzi wrote:
> Hi all
>
> consider following index
>
> field1 field2 field3
> text1 text1 text2 text3 text4
> text4 text2 text2 text3 text5
>
> I want to get all terms in filed3
> if I use Reader.terms() it will returns: (however i have to put an if
> statement to filter result of the field3 only)
> text3
> text4
> text2
> text5
>
> but I need following result:
> "text3 text4"
> "text2 text3 text5"
>
>
> is this possible? if yes, how? and if no, is there any tricky way
> to get
> this result?
>
> thank you so much.
>
> --
> Regards,
> Mohammad Norouzi
> --------------------------
> see my blog: http://brainable.blogspot.com/
--------------------------
Grant Ingersoll
Center for Natural Language Processing
http://www.cnlp.org/tech/lucene.asp
Read the Lucene Java FAQ at http://wiki.apache.org/jakarta-lucene/
LuceneFAQ
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org