當前位置: 首頁>>代碼示例>>Java>>正文


Java TokenFilterFactory.create方法代碼示例

本文整理匯總了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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:22,代碼來源:TestICUCollationKeyFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:13,代碼來源:TestICUCollationKeyFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:14,代碼來源:TestICUCollationKeyFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:14,代碼來源:TestICUCollationKeyFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:14,代碼來源:TestICUCollationKeyFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:13,代碼來源:TestICUCollationKeyFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:29,代碼來源:TestICUCollationKeyFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:14,代碼來源:TestICUCollationKeyFilterFactory.java

示例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 });
}
 
開發者ID:europeana,項目名稱:search,代碼行數:11,代碼來源:TestSynonymFilterFactory.java

示例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 });
}
 
開發者ID:europeana,項目名稱:search,代碼行數:11,代碼來源:TestSynonymFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:9,代碼來源:TestTypeTokenFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:10,代碼來源:TestTypeTokenFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:13,代碼來源:TestCollationKeyFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:14,代碼來源:TestCollationKeyFilterFactory.java

示例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);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:14,代碼來源:TestCollationKeyFilterFactory.java


注:本文中的org.apache.lucene.analysis.util.TokenFilterFactory.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。