X-Git-Url: https://git.mdrn.pl/pylucene.git/blobdiff_plain/a2e61f0c04805cfcb8706176758d1283c7e3a55c..aaeed5504b982cf3545252ab528713250aa33eed:/lucene-java-3.4.0/lucene/src/java/org/apache/lucene/analysis/standard/UAX29URLEmailTokenizer.java diff --git a/lucene-java-3.4.0/lucene/src/java/org/apache/lucene/analysis/standard/UAX29URLEmailTokenizer.java b/lucene-java-3.4.0/lucene/src/java/org/apache/lucene/analysis/standard/UAX29URLEmailTokenizer.java deleted file mode 100644 index 4ff6b7f..0000000 --- a/lucene-java-3.4.0/lucene/src/java/org/apache/lucene/analysis/standard/UAX29URLEmailTokenizer.java +++ /dev/null @@ -1,255 +0,0 @@ -package org.apache.lucene.analysis.standard; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; - -import org.apache.lucene.analysis.Tokenizer; -import org.apache.lucene.analysis.standard.std31.StandardTokenizerImpl31; -import org.apache.lucene.analysis.standard.std31.UAX29URLEmailTokenizerImpl31; -import org.apache.lucene.analysis.tokenattributes.OffsetAttribute; -import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; -import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; -import org.apache.lucene.analysis.tokenattributes.TypeAttribute; -import org.apache.lucene.util.AttributeSource; -import org.apache.lucene.util.Version; -import org.apache.lucene.util.AttributeSource.AttributeFactory; - -/** - * This class implements Word Break rules from the Unicode Text Segmentation - * algorithm, as specified in - * Unicode Standard Annex #29 - * URLs and email addresses are also tokenized according to the relevant RFCs. - *
- * Tokens produced are of the following types: - *You must specify the required {@link Version} - * compatibility when creating UAX29URLEmailTokenizer: - *
- * See Unicode Line Breaking Algorithm: http://www.unicode.org/reports/tr14/#SA
- * @deprecated use {@link #TOKEN_TYPES} instead
- */
- @Deprecated
- public static final String SOUTH_EAST_ASIAN_TYPE = TOKEN_TYPES[SOUTHEAST_ASIAN];
-
- /** @deprecated use {@link #TOKEN_TYPES} instead */
- @Deprecated
- public static final String IDEOGRAPHIC_TYPE = TOKEN_TYPES[IDEOGRAPHIC];
-
- /** @deprecated use {@link #TOKEN_TYPES} instead */
- @Deprecated
- public static final String HIRAGANA_TYPE = TOKEN_TYPES[HIRAGANA];
-
- /** @deprecated use {@link #TOKEN_TYPES} instead */
- @Deprecated
- public static final String KATAKANA_TYPE = TOKEN_TYPES[KATAKANA];
-
- /** @deprecated use {@link #TOKEN_TYPES} instead */
- @Deprecated
- public static final String HANGUL_TYPE = TOKEN_TYPES[HANGUL];
-
- private int maxTokenLength = StandardAnalyzer.DEFAULT_MAX_TOKEN_LENGTH;
-
- /** Set the max allowed token length. Any token longer
- * than this is skipped. */
- public void setMaxTokenLength(int length) {
- this.maxTokenLength = length;
- }
-
- /** @see #setMaxTokenLength */
- public int getMaxTokenLength() {
- return maxTokenLength;
- }
-
- /** @deprecated use {@link #UAX29URLEmailTokenizer(Version, Reader)} instead. */
- @Deprecated
- public UAX29URLEmailTokenizer(Reader input) {
- this(Version.LUCENE_31, input);
- }
-
- /** @deprecated use {@link #UAX29URLEmailTokenizer(Version, Reader)} instead. */
- @Deprecated
- public UAX29URLEmailTokenizer(InputStream input) {
- this(Version.LUCENE_31, new InputStreamReader(input));
- }
-
- /** @deprecated use {@link #UAX29URLEmailTokenizer(Version, AttributeSource, Reader)} instead. */
- @Deprecated
- public UAX29URLEmailTokenizer(AttributeSource source, Reader input) {
- this(Version.LUCENE_31, source, input);
- }
-
- /** @deprecated use {@link #UAX29URLEmailTokenizer(Version, AttributeSource.AttributeFactory, Reader)} instead. */
- @Deprecated
- public UAX29URLEmailTokenizer(AttributeFactory factory, Reader input) {
- this(Version.LUCENE_31, factory, input);
- }
-
- /**
- * Creates a new instance of the UAX29URLEmailTokenizer. Attaches
- * the input
to the newly created JFlex scanner.
- *
- * @param input The input reader
- */
- public UAX29URLEmailTokenizer(Version matchVersion, Reader input) {
- super(input);
- this.scanner = getScannerFor(matchVersion, input);
- }
-
- /**
- * Creates a new UAX29URLEmailTokenizer with a given {@link AttributeSource}.
- */
- public UAX29URLEmailTokenizer(Version matchVersion, AttributeSource source, Reader input) {
- super(source, input);
- this.scanner = getScannerFor(matchVersion, input);
- }
-
- /**
- * Creates a new UAX29URLEmailTokenizer with a given {@link AttributeFactory}
- */
- public UAX29URLEmailTokenizer(Version matchVersion, AttributeFactory factory, Reader input) {
- super(factory, input);
- this.scanner = getScannerFor(matchVersion, input);
- }
-
- private static StandardTokenizerInterface getScannerFor(Version matchVersion, Reader input) {
- if (matchVersion.onOrAfter(Version.LUCENE_34)) {
- return new UAX29URLEmailTokenizerImpl(input);
- } else {
- return new UAX29URLEmailTokenizerImpl31(input);
- }
- }
-
- // this tokenizer generates three attributes:
- // term offset, positionIncrement and type
- private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
- private final OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class);
- private final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
- private final TypeAttribute typeAtt = addAttribute(TypeAttribute.class);
-
- @Override
- public final boolean incrementToken() throws IOException {
- clearAttributes();
- int posIncr = 1;
-
- while(true) {
- int tokenType = scanner.getNextToken();
-
- if (tokenType == StandardTokenizerInterface.YYEOF) {
- return false;
- }
-
- if (scanner.yylength() <= maxTokenLength) {
- posIncrAtt.setPositionIncrement(posIncr);
- scanner.getText(termAtt);
- final int start = scanner.yychar();
- offsetAtt.setOffset(correctOffset(start), correctOffset(start+termAtt.length()));
- typeAtt.setType(TOKEN_TYPES[tokenType]);
- return true;
- } else
- // When we skip a too-long term, we still increment the
- // position increment
- posIncr++;
- }
- }
-
- @Override
- public final void end() {
- // set final offset
- int finalOffset = correctOffset(scanner.yychar() + scanner.yylength());
- offsetAtt.setOffset(finalOffset, finalOffset);
- }
-
- @Override
- public void reset(Reader reader) throws IOException {
- super.reset(reader);
- scanner.yyreset(reader);
- }
-}