001: /*
002: * Copyright 2004-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.compass.core;
018:
019: import java.io.Reader;
020:
021: /**
022: * A set of Analyzer related helper methods. Aimed to help understand and simulate
023: * the analysis process. As well as helping build advance query building capabilities.
024: *
025: * @author kimchy
026: */
027: public interface CompassAnalyzerHelper {
028:
029: /**
030: * Sets the analyzer that will be used for the analysis of the text.
031: *
032: * @param analyzerName The analyzer name that will be used.
033: * @return the analyzer helper
034: * @throws CompassException
035: */
036: CompassAnalyzerHelper setAnalyzer(String analyzerName)
037: throws CompassException;
038:
039: /**
040: * Sets the analyzer that will be used for the analysis of the text.
041: * Uses the resource to derive the analyzer
042: * that will be used (works also with per resource property analyzer).
043: *
044: * @param resource The resource to derive the analyzer from
045: * @return the analyzer helper
046: * @throws CompassException
047: */
048: CompassAnalyzerHelper setAnalyzer(Resource resource)
049: throws CompassException;
050:
051: /**
052: * Sets the analyzer that will be used for the analysis of the text.
053: * Uses the alias to get the mapping deinfitions and build a specific analyzer
054: * if there is a certain property that is associated with a specific analyzer
055: * (builds a per resource property analyzer).
056: *
057: * @param alias The alias to derive the analyzer from
058: * @return the analyzer helper
059: * @throws CompassException If the analyzer if not found
060: */
061: CompassAnalyzerHelper setAnalyzerByAlias(String alias)
062: throws CompassException;
063:
064: /**
065: * Analyzes the given text, returning the first token.
066: *
067: * @param text The text to analyze
068: * @return The first token.
069: * @throws CompassException
070: */
071: CompassToken analyzeSingle(String text) throws CompassException;
072:
073: /**
074: * Analyzes the given text, returning a set of tokens.
075: *
076: * @param text The text to analyze
077: * @return A set of tokens resulting from the analysis process.
078: * @throws CompassException
079: */
080: CompassToken[] analyze(String text) throws CompassException;
081:
082: /**
083: * Analyzes the given text, using (if needed) the anlayzer that is bound
084: * to the supplied property. Should be used with {@link #setAnalyzer(Resource)}
085: * so the analyzer can be dynamically detected from the resource.
086: *
087: * @param propertyName The property name for analyze bound properties
088: * @param text The text to analyze
089: * @return A set of tokens resulting from the analysis process.
090: * @throws CompassException
091: */
092: CompassToken[] analyze(String propertyName, String text)
093: throws CompassException;
094:
095: /**
096: * Analyzes the given text, returning a set of tokens.
097: *
098: * @param textReader The text to analyze
099: * @return A set of tokens resulting from the analysis process.
100: * @throws CompassException
101: */
102: CompassToken[] analyze(Reader textReader) throws CompassException;
103:
104: /**
105: * Analyzes the given text, using (if needed) the anlayzer that is bound
106: * to the supplied property. Should be used with {@link #setAnalyzer(Resource)}
107: * so the analyzer can be dynamically detected from the resource.
108: *
109: * @param propertyName The property name for analyze bound properties
110: * @param textReader The text to analyze
111: * @return A set of tokens resulting from the analysis process.
112: * @throws CompassException
113: */
114: CompassToken[] analyze(String propertyName, Reader textReader)
115: throws CompassException;
116:
117: }
|