本文整理匯總了Java中org.apache.lucene.analysis.util.TokenFilterFactory.create方法的典型用法代碼示例。如果您正苦於以下問題:Java TokenFilterFactory.create方法的具體用法?Java TokenFilterFactory.create怎麽用?Java TokenFilterFactory.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.lucene.analysis.util.TokenFilterFactory
的用法示例。
在下文中一共展示了TokenFilterFactory.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testIgnoreWhitespace
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testIgnoreWhitespace() throws Exception {
String withSpace = "foo bar";
String withoutSpace = "foobar";
String withPunctuation = "foo-bar";
TokenFilterFactory factory = tokenFilterFactory("ICUCollationKey",
"locale", "en",
"strength", "primary",
"alternate", "shifted",
"variableTop", " ");
TokenStream tsWithSpace = factory.create(
new KeywordTokenizer(new StringReader(withSpace)));
TokenStream tsWithoutSpace = factory.create(
new KeywordTokenizer(new StringReader(withoutSpace)));
assertCollatesToSame(tsWithSpace, tsWithoutSpace);
// now assert that punctuation still matters: foo-bar < foo bar
tsWithSpace = factory.create(
new KeywordTokenizer(new StringReader(withSpace)));
TokenStream tsWithPunctuation = factory.create(
new KeywordTokenizer(new StringReader(withPunctuation)));
assertCollation(tsWithPunctuation, tsWithSpace, -1);
}
示例2: testBasicUsage
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testBasicUsage() throws Exception {
String turkishUpperCase = "I WİLL USE TURKİSH CASING";
String turkishLowerCase = "ı will use turkish casıng";
TokenFilterFactory factory = tokenFilterFactory("ICUCollationKey",
"locale", "tr",
"strength", "primary");
TokenStream tsUpper = factory.create(
new KeywordTokenizer(new StringReader(turkishUpperCase)));
TokenStream tsLower = factory.create(
new KeywordTokenizer(new StringReader(turkishLowerCase)));
assertCollatesToSame(tsUpper, tsLower);
}
示例3: testNormalization
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testNormalization() throws Exception {
String turkishUpperCase = "I W\u0049\u0307LL USE TURKİSH CASING";
String turkishLowerCase = "ı will use turkish casıng";
TokenFilterFactory factory = tokenFilterFactory("ICUCollationKey",
"locale", "tr",
"strength", "primary",
"decomposition", "canonical");
TokenStream tsUpper = factory.create(
new KeywordTokenizer(new StringReader(turkishUpperCase)));
TokenStream tsLower = factory.create(
new KeywordTokenizer(new StringReader(turkishLowerCase)));
assertCollatesToSame(tsUpper, tsLower);
}
示例4: testSecondaryStrength
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testSecondaryStrength() throws Exception {
String upperCase = "TESTING";
String lowerCase = "testing";
TokenFilterFactory factory = tokenFilterFactory("ICUCollationKey",
"locale", "en",
"strength", "secondary",
"decomposition", "no");
TokenStream tsUpper = factory.create(
new KeywordTokenizer(new StringReader(upperCase)));
TokenStream tsLower = factory.create(
new KeywordTokenizer(new StringReader(lowerCase)));
assertCollatesToSame(tsUpper, tsLower);
}
示例5: testIgnorePunctuation
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testIgnorePunctuation() throws Exception {
String withPunctuation = "foo-bar";
String withoutPunctuation = "foo bar";
TokenFilterFactory factory = tokenFilterFactory("ICUCollationKey",
"locale", "en",
"strength", "primary",
"alternate", "shifted");
TokenStream tsPunctuation = factory.create(
new KeywordTokenizer(new StringReader(withPunctuation)));
TokenStream tsWithoutPunctuation = factory.create(
new KeywordTokenizer(new StringReader(withoutPunctuation)));
assertCollatesToSame(tsPunctuation, tsWithoutPunctuation);
}
示例6: testNumerics
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testNumerics() throws Exception {
String nine = "foobar-9";
String ten = "foobar-10";
TokenFilterFactory factory = tokenFilterFactory("ICUCollationKey",
"locale", "en",
"numeric", "true");
TokenStream tsNine = factory.create(
new KeywordTokenizer(new StringReader(nine)));
TokenStream tsTen = factory.create(
new KeywordTokenizer(new StringReader(ten)));
assertCollation(tsNine, tsTen, -1);
}
示例7: testIgnoreAccentsButNotCase
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testIgnoreAccentsButNotCase() throws Exception {
String withAccents = "résumé";
String withoutAccents = "resume";
String withAccentsUpperCase = "Résumé";
String withoutAccentsUpperCase = "Resume";
TokenFilterFactory factory = tokenFilterFactory("ICUCollationKey",
"locale", "en",
"strength", "primary",
"caseLevel", "true");
TokenStream tsWithAccents = factory.create(
new KeywordTokenizer(new StringReader(withAccents)));
TokenStream tsWithoutAccents = factory.create(
new KeywordTokenizer(new StringReader(withoutAccents)));
assertCollatesToSame(tsWithAccents, tsWithoutAccents);
TokenStream tsWithAccentsUpperCase = factory.create(
new KeywordTokenizer(new StringReader(withAccentsUpperCase)));
TokenStream tsWithoutAccentsUpperCase = factory.create(
new KeywordTokenizer(new StringReader(withoutAccentsUpperCase)));
assertCollatesToSame(tsWithAccentsUpperCase, tsWithoutAccentsUpperCase);
// now assert that case still matters: resume < Resume
TokenStream tsLower = factory.create(
new KeywordTokenizer(new StringReader(withoutAccents)));
TokenStream tsUpper = factory.create(
new KeywordTokenizer(new StringReader(withoutAccentsUpperCase)));
assertCollation(tsLower, tsUpper, -1);
}
示例8: testUpperCaseFirst
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testUpperCaseFirst() throws Exception {
String lower = "resume";
String upper = "Resume";
TokenFilterFactory factory = tokenFilterFactory("ICUCollationKey",
"locale", "en",
"strength", "tertiary",
"caseFirst", "upper");
TokenStream tsLower = factory.create(
new KeywordTokenizer(new StringReader(lower)));
TokenStream tsUpper = factory.create(
new KeywordTokenizer(new StringReader(upper)));
assertCollation(tsUpper, tsLower, -1);
}
示例9: checkSolrSynonyms
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
/** checks for synonyms of "GB" in synonyms.txt */
private void checkSolrSynonyms(TokenFilterFactory factory) throws Exception {
Reader reader = new StringReader("GB");
TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
stream = factory.create(stream);
assertTrue(stream instanceof SynonymFilter);
assertTokenStreamContents(stream,
new String[] { "GB", "gib", "gigabyte", "gigabytes" },
new int[] { 1, 0, 0, 0 });
}
示例10: checkWordnetSynonyms
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
/** checks for synonyms of "second" in synonyms-wordnet.txt */
private void checkWordnetSynonyms(TokenFilterFactory factory) throws Exception {
Reader reader = new StringReader("second");
TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
stream = factory.create(stream);
assertTrue(stream instanceof SynonymFilter);
assertTokenStreamContents(stream,
new String[] { "second", "2nd", "two" },
new int[] { 1, 0, 0 });
}
示例11: testCreationWithBlackList
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testCreationWithBlackList() throws Exception {
TokenFilterFactory factory = tokenFilterFactory("Type",
"types", "stoptypes-1.txt, stoptypes-2.txt",
"enablePositionIncrements", "true");
NumericTokenStream input = new NumericTokenStream();
input.setIntValue(123);
factory.create(input);
}
示例12: testCreationWithWhiteList
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testCreationWithWhiteList() throws Exception {
TokenFilterFactory factory = tokenFilterFactory("Type",
"types", "stoptypes-1.txt, stoptypes-2.txt",
"enablePositionIncrements", "true",
"useWhitelist", "true");
NumericTokenStream input = new NumericTokenStream();
input.setIntValue(123);
factory.create(input);
}
示例13: testBasicUsage
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testBasicUsage() throws Exception {
String turkishUpperCase = "I WİLL USE TURKİSH CASING";
String turkishLowerCase = "ı will use turkish casıng";
TokenFilterFactory factory = tokenFilterFactory("CollationKey",
"language", "tr",
"strength", "primary");
TokenStream tsUpper = factory.create(
new MockTokenizer(new StringReader(turkishUpperCase), MockTokenizer.KEYWORD, false));
TokenStream tsLower = factory.create(
new MockTokenizer(new StringReader(turkishLowerCase), MockTokenizer.KEYWORD, false));
assertCollatesToSame(tsUpper, tsLower);
}
示例14: testNormalization
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testNormalization() throws Exception {
String turkishUpperCase = "I W\u0049\u0307LL USE TURKİSH CASING";
String turkishLowerCase = "ı will use turkish casıng";
TokenFilterFactory factory = tokenFilterFactory("CollationKey",
"language", "tr",
"strength", "primary",
"decomposition", "canonical");
TokenStream tsUpper = factory.create(
new MockTokenizer(new StringReader(turkishUpperCase), MockTokenizer.KEYWORD, false));
TokenStream tsLower = factory.create(
new MockTokenizer(new StringReader(turkishLowerCase), MockTokenizer.KEYWORD, false));
assertCollatesToSame(tsUpper, tsLower);
}
示例15: testFullDecomposition
import org.apache.lucene.analysis.util.TokenFilterFactory; //導入方法依賴的package包/類
public void testFullDecomposition() throws Exception {
String fullWidth = "Testing";
String halfWidth = "Testing";
TokenFilterFactory factory = tokenFilterFactory("CollationKey",
"language", "zh",
"strength", "identical",
"decomposition", "full");
TokenStream tsFull = factory.create(
new MockTokenizer(new StringReader(fullWidth), MockTokenizer.KEYWORD, false));
TokenStream tsHalf = factory.create(
new MockTokenizer(new StringReader(halfWidth), MockTokenizer.KEYWORD, false));
assertCollatesToSame(tsFull, tsHalf);
}