[
https://issues.apache.org/jira/browse/LUCENE-6874?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14985885#comment-14985885
]
Uwe Schindler edited comment on LUCENE-6874 at 11/2/15 7:44 PM:
----------------------------------------------------------------
One thing to make it full flexible in Lucene Trunk (Java 8 only). I know this
would not help Solr users that want to define the Tokenizer in a config file,
but for real Lucene users the Java 8-like way would be the following static
method on CharTokenizer:
{code:java}
public static CharTokenizer fromPredicate(java.util.function.IntPredicate
predicate)
{code}
This would allow to define a new CharTokenizer with a single line statement
using any predicate:
{code:java}
// long variant with lambda:
Tokenizer tok = CharTokenizer.fromPredicate(c -> !UCharacter.isUWhiteSpace(c));
// method reference:
Tokenizer tok = CharTokenizer.fromPredicate(
(UCharacter::isUWhiteSpace).negate() );
// method reference to custom function:
private boolean myTestFunction(int c) {
return (cracy condition);
}
Tokenizer tok = CharTokenizer.fromPredicate(this::myTestFunction);
{code}
I think we should do this in a separate issue in Lucene trunk for Java 8. This
is really the way for which Java 8 Lambdas are made for. And its fast like
hell, because its compiled to native bytecode so there is no call overhead.
was (Author: thetaphi):
One thing to make it full flexible in Lucene Trunk (Java 8 only). I know this
would not help Solr users that want to define the Tokenizer in a config file,
but for real Lucene users the Java 8-like way would be the following static
method on CharTokenizer:
{code:java}
public static CharTokenizer fromPredicate(java.util.function.IntPredicate
predicate)
{code}
This would allow to define a new CharTokenizer with a single line statement
using any predicate:
{code:java}
// long variant with lambda:
Tokenizer tok = CharTokenizer.fromPredicate(c -> !UCharacter.isUWhiteSpace(c));
// method reference:
Tokenizer tok = CharTokenizer.fromPredicate(
(UCharacter::isUWhiteSpace).negate() );
// method reference to custom function:
private boolean myTestFunction(int c) {
return (cracy condition);
}
Tokenizer tok = CharTokenizer.fromPredicate(c -> this::myTestFunction);
{code}
I think we should do this in a separate issue in Lucene trunk for Java 8. This
is really the way for which Java 8 Lambdas are made for. And its fast like
hell, because its compiled to native bytecode so there is no call overhead.
> WhitespaceTokenizer should tokenize on NBSP
> -------------------------------------------
>
> Key: LUCENE-6874
> URL: https://issues.apache.org/jira/browse/LUCENE-6874
> Project: Lucene - Core
> Issue Type: Improvement
> Components: modules/analysis
> Reporter: David Smiley
> Priority: Minor
> Attachments: LUCENE-6874.patch
>
>
> WhitespaceTokenizer uses [Character.isWhitespace
> |http://docs.oracle.com/javase/8/docs/api/java/lang/Character.html#isWhitespace-int-]
> to decide what is whitespace. Here's a pertinent excerpt:
> bq. It is a Unicode space character (SPACE_SEPARATOR, LINE_SEPARATOR, or
> PARAGRAPH_SEPARATOR) but is not also a non-breaking space ('\u00A0',
> '\u2007', '\u202F')
> Perhaps Character.isWhitespace should have been called
> isLineBreakableWhitespace?
> I think WhitespaceTokenizer should tokenize on this. I am aware it's easy to
> work around but why leave this trap in by default?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]