当前位置: 首页>>代码示例>>Java>>正文


Java CharArrayMap类代码示例

本文整理汇总了Java中org.apache.lucene.analysis.CharArrayMap的典型用法代码示例。如果您正苦于以下问题:Java CharArrayMap类的具体用法?Java CharArrayMap怎么用?Java CharArrayMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CharArrayMap类属于org.apache.lucene.analysis包,在下文中一共展示了CharArrayMap类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: turkish_match_pattern

import org.apache.lucene.analysis.CharArrayMap; //导入依赖的package包/类
private static boolean turkish_match_pattern(CharArrayMap<Integer> dlist, int point, char[] turkish_string, int length) {
    final int turkish_context_size = 10;
    int rank = dlist.size() * 2;
    char[] str = turkish_get_context(turkish_context_size, point, turkish_string, length);

    //System.out.println("length = " + str.length);
    int start = 0;
    int end;
    int _len = str.length;

    while (start <= turkish_context_size) {
        end = turkish_context_size + 1;
        while (end <= _len) {

            Integer r = dlist.get(str, start, end - start);

            if (r != null && Math.abs(r) < Math.abs(rank)) {
                rank = r;
            }
            end++;
        }
        start++;
    }
    return rank > 0;
}
 
开发者ID:iorixxx,项目名称:lucene-solr-analysis-turkish,代码行数:26,代码来源:TurkishDeASCIIfyFilter.java

示例2: getMap

import org.apache.lucene.analysis.CharArrayMap; //导入依赖的package包/类
public static CharArrayMap<Integer> getMap(char c) {
    switch (c) {
        case 'c':
            return MapC.map;
        case 'g':
            return MapG.map;
        case 'i':
            return MapI.map;
        case 'o':
            return MapO.map;
        case 's':
            return MapS.map;
        case 'u':
            return MapU.map;
        default:
            return null;
    }
}
 
开发者ID:iorixxx,项目名称:lucene-solr-analysis-turkish,代码行数:19,代码来源:PatternTableFactory.java

示例3: initializeDictHash

import org.apache.lucene.analysis.CharArrayMap; //导入依赖的package包/类
private static CharArrayMap<char[]> initializeDictHash() {
	CharArrayMap<char[]> charMap = new CharArrayMap<>(2000, false);

	try {
		URL url = Resources.getResource(BritishUSFilter.class, "british.txt");
		String text = Resources.toString(url, Charsets.UTF8_CHARSET);
		String[] lines = text.split("\n");
		for (String line : lines) {
			if (!line.startsWith("UK\tUS")) {
				String[] parts = line.split("\t");
				if (parts.length == 2) {
					charMap.put(parts[0].toCharArray(), parts[1].toCharArray());
				}
			}
		}

	}
	catch (Exception e) {
		throw new RuntimeException(e);
	}
	return charMap;

}
 
开发者ID:lumongo,项目名称:lumongo,代码行数:24,代码来源:BritishUSFilter.java

示例4: turkish_need_correction

import org.apache.lucene.analysis.CharArrayMap; //导入依赖的package包/类
/**
 * Determine if char at cursor needs correction.
 */
private static boolean turkish_need_correction(char c, int point, char[] turkish_string, int length) {

    final Character tr;

    if (turkish_asciify_table.containsKey(c))
        tr = turkish_asciify_table.get(c);
    else
        tr = c;

    CharArrayMap<Integer> pl = PatternTableFactory.getMap(Character.toLowerCase(tr));

    boolean m = false;
    if (pl != null) {
        m = turkish_match_pattern(pl, point, turkish_string, length);
    }

    if (tr.equals('I')) {
        if (c == tr) {
            return !m;
        } else {
            return m;
        }
    } else {
        if (c == tr) {
            return m;
        } else {
            return !m;
        }
    }
}
 
开发者ID:iorixxx,项目名称:lucene-solr-analysis-turkish,代码行数:34,代码来源:TurkishDeASCIIfyFilter.java

示例5: getResults

import org.apache.lucene.analysis.CharArrayMap; //导入依赖的package包/类
private List<TermIDF> getResults(String fieldName,
                                   CharArrayMap<MutableValueInt> map, int numResults) {
    TFIDFPriorityQueue queue = new TFIDFPriorityQueue(numResults);
    IDFIndexCalc idfCalc = new IDFIndexCalc(searcher.getIndexReader());
    int tf = -1;
    double idf = -1.0;
    int minTf = minTermFreq;
    String text = null;
    //make more efficient
//    Term reusableTerm = new Term(fieldName, "");
    for (Map.Entry<Object, MutableValueInt> entry : map.entrySet()) {

      tf = entry.getValue().value;
      if (tf < minTf)
        continue;

      text = new String((char[]) entry.getKey());
      // calculate idf for potential phrase
      try {
        idf = idfCalc.singleTermIDF(new Term(fieldName, text));
      } catch (IOException e) {
        throw new RuntimeException("Error trying to calculate IDF: " + e.getMessage());
      }
      int estimatedDF = (int) Math.max(1, Math.round(idfCalc.unIDF(idf)));

      TermIDF r = new TermIDF(text, estimatedDF, tf, idf);

      queue.insertWithOverflow(r);
    }
    List<TermIDF> results = new LinkedList<>();

    while (queue.size() > 0) {
      results.add(0, queue.pop());
    }
    return results;
  }
 
开发者ID:tballison,项目名称:lucene-addons,代码行数:37,代码来源:QueryToCorpusContraster.java


注:本文中的org.apache.lucene.analysis.CharArrayMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。