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


Java Term.text方法代码示例

本文整理汇总了Java中org.apache.lucene.index.Term.text方法的典型用法代码示例。如果您正苦于以下问题:Java Term.text方法的具体用法?Java Term.text怎么用?Java Term.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.index.Term的用法示例。


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

示例1: convert

import org.apache.lucene.index.Term; //导入方法依赖的package包/类
@CheckForNull
@Override
@SuppressWarnings("StringEquality")
public Void convert(@NonNull final Index.WithTermFrequencies.TermFreq param) throws Stop {
    final Term term = param.getTerm();
    if (fieldName != term.field()) {
        throw new Stop();
    }
    final int docCount = param.getFreq();
    final String encBinName = term.text();
    final String binName = encBinName.substring(
        0,
        encBinName.length() - postfixLen);
    final int dotIndex = binName.lastIndexOf('.');  //NOI18N
    final String pkgName = dotIndex == -1 ? "" : binName.substring(0, dotIndex);    //NOI18N
    final Integer typeCount = typeFreq.get(binName);
    final Integer pkgCount = pkgFreq.get(pkgName);
    typeFreq.put(binName, typeCount == null ? docCount : docCount + typeCount);
    pkgFreq.put(pkgName, pkgCount == null ? docCount : docCount + pkgCount);
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:PersistentClassIndex.java

示例2: convert

import org.apache.lucene.index.Term; //导入方法依赖的package包/类
@Override
public String convert(Term currentTerm) throws Stop {
    if (fieldName != currentTerm.field()) {
        throw STOP;
    }
    String currentText = currentTerm.text();
    if (all || currentText.startsWith(value)) {
        if (directOnly) {
            int index = currentText.indexOf('.', value.length());    //NOI18N
            if (index>0) {
                currentText = currentText.substring(0,index);
            }
        }
        return currentText;
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:QueryUtil.java

示例3: UnionDocsAndPositionsEnum

import org.apache.lucene.index.Term; //导入方法依赖的package包/类
public UnionDocsAndPositionsEnum(Bits liveDocs, AtomicReaderContext context, Term[] terms, Map<Term,TermContext> termContexts, TermsEnum termsEnum) throws IOException {
  List<DocsAndPositionsEnum> docsEnums = new LinkedList<>();
  for (int i = 0; i < terms.length; i++) {
    final Term term = terms[i];
    TermState termState = termContexts.get(term).get(context.ord);
    if (termState == null) {
      // Term doesn't exist in reader
      continue;
    }
    termsEnum.seekExact(term.bytes(), termState);
    DocsAndPositionsEnum postings = termsEnum.docsAndPositions(liveDocs, null, DocsEnum.FLAG_NONE);
    if (postings == null) {
      // term does exist, but has no positions
      throw new IllegalStateException("field \"" + term.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + term.text() + ")");
    }
    cost += postings.cost();
    docsEnums.add(postings);
  }

  _queue = new DocsQueue(docsEnums);
  _posList = new IntQueue();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:MultiPhraseQuery.java

示例4: termCompare

import org.apache.lucene.index.Term; //导入方法依赖的package包/类
@Override
protected boolean termCompare(Term term) {
    if (fieldName == term.field()) {
        String searchText = term.text();
        if (searchText.startsWith(startPrefix)) {
            return pattern.matcher(term.text()).matches();
        }
    }
    endEnum = true;
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:Queries.java

示例5: newFuzzyQuery

import org.apache.lucene.index.Term; //导入方法依赖的package包/类
@Override
protected Query newFuzzyQuery(Term term, float minimumSimilarity, int prefixLength) {
    String text = term.text();
    int numEdits = FuzzyQuery.floatToEdits(minimumSimilarity, text.codePointCount(0, text.length()));
    FuzzyQuery query = new FuzzyQuery(term, numEdits, prefixLength,
        settings.fuzzyMaxExpansions(), FuzzyQuery.defaultTranspositions);
    QueryParsers.setRewriteMethod(query, settings.fuzzyRewriteMethod());
    return query;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:MapperQueryParser.java

示例6: recurseTerms

import org.apache.lucene.index.Term; //导入方法依赖的package包/类
private void recurseTerms(List<List<TermBitSet>> bitSets, int index, String[] curValues, OpenBitSet curBits,
	MatrixResults results, IndexReader reader, boolean countOnly)
{
	List<TermBitSet> termBitSetList = bitSets.get(index);
	boolean last = index == curValues.length - 1;
	for( TermBitSet termBitSet : termBitSetList )
	{
		OpenBitSet termBits = termBitSet.bitSet;
		Term term = termBitSet.term;
		// if we don't intersect there's no point in recursing further in
		if( curBits.intersects(termBits) )
		{
			// Collect current term's value into the value array
			curValues[index] = term.text();
			OpenBitSet docBits = (OpenBitSet) curBits.clone();
			docBits.and(termBits);
			if( last )
			{
				int count;
				List<ItemIdKey> ids = null;
				ArrayList<String> vals = new ArrayList<String>(Arrays.asList(curValues));
				if( !countOnly )
				{
					ids = getIdsForBitset(docBits, reader);
					count = ids.size();
				}
				else
				{
					count = (int) docBits.cardinality();
				}
				results.addEntry(new MatrixResults.MatrixEntry(vals, ids, count));
			}
			else
			{
				recurseTerms(bitSets, index + 1, curValues, docBits, results, reader, countOnly);
			}
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:40,代码来源:ItemIndex.java

示例7: newFuzzyQuery

import org.apache.lucene.index.Term; //导入方法依赖的package包/类
/**
 * Builds a new FuzzyQuery instance
 * @param term Term
 * @param minimumSimilarity minimum similarity
 * @param prefixLength prefix length
 * @return new FuzzyQuery Instance
 */
protected Query newFuzzyQuery(Term term, float minimumSimilarity, int prefixLength) {
  // FuzzyQuery doesn't yet allow constant score rewrite
  String text = term.text();
  int numEdits = FuzzyQuery.floatToEdits(minimumSimilarity, 
      text.codePointCount(0, text.length()));
  return new FuzzyQuery(term,numEdits,prefixLength);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:QueryParserBase.java

示例8: newFuzzyQuery

import org.apache.lucene.index.Term; //导入方法依赖的package包/类
@Override
protected Query newFuzzyQuery(Term term, float minimumSimilarity, int prefixLength) {
    String text = term.text();
    int numEdits = FuzzyQuery.floatToEdits(minimumSimilarity, text.codePointCount(0, text.length()));
    FuzzyQuery query = new FuzzyQuery(term, numEdits, prefixLength, settings.fuzzyMaxExpansions(), FuzzyQuery.defaultTranspositions);
    QueryParsers.setRewriteMethod(query, settings.fuzzyRewriteMethod());
    return query;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:MapperQueryParser.java

示例9: PackageFilter

import org.apache.lucene.index.Term; //导入方法依赖的package包/类
PackageFilter(final @NonNull Term startTerm, final boolean directOnly) {
    this.fieldName = startTerm.field();
    this.value = startTerm.text();
    this.directOnly = directOnly;
    this.all = value.length() == 0;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:QueryUtil.java

示例10: FuzzyTermsEnum

import org.apache.lucene.index.Term; //导入方法依赖的package包/类
/**
 * Constructor for enumeration of all terms from specified <code>reader</code> which share a prefix of
 * length <code>prefixLength</code> with <code>term</code> and which have a fuzzy similarity &gt;
 * <code>minSimilarity</code>.
 * <p>
 * After calling the constructor the enumeration is already pointing to the first 
 * valid term if such a term exists. 
 * 
 * @param terms Delivers terms.
 * @param atts {@link AttributeSource} created by the rewrite method of {@link MultiTermQuery}
 * thats contains information about competitive boosts during rewrite. It is also used
 * to cache DFAs between segment transitions.
 * @param term Pattern term.
 * @param minSimilarity Minimum required similarity for terms from the reader. Pass an integer value
 *        representing edit distance. Passing a fraction is deprecated.
 * @param prefixLength Length of required common prefix. Default value is 0.
 * @throws IOException if there is a low-level IO error
 */
public FuzzyTermsEnum(Terms terms, AttributeSource atts, Term term, 
    final float minSimilarity, final int prefixLength, boolean transpositions) throws IOException {
  if (minSimilarity >= 1.0f && minSimilarity != (int)minSimilarity)
    throw new IllegalArgumentException("fractional edit distances are not allowed");
  if (minSimilarity < 0.0f)
    throw new IllegalArgumentException("minimumSimilarity cannot be less than 0");
  if(prefixLength < 0)
    throw new IllegalArgumentException("prefixLength cannot be less than 0");
  this.terms = terms;
  this.term = term;

  // convert the string into a utf32 int[] representation for fast comparisons
  final String utf16 = term.text();
  this.termText = new int[utf16.codePointCount(0, utf16.length())];
  for (int cp, i = 0, j = 0; i < utf16.length(); i += Character.charCount(cp))
         termText[j++] = cp = utf16.codePointAt(i);
  this.termLength = termText.length;
  this.dfaAtt = atts.addAttribute(LevenshteinAutomataAttribute.class);

  //The prefix could be longer than the word.
  //It's kind of silly though.  It means we must match the entire word.
  this.realPrefixLength = prefixLength > termLength ? termLength : prefixLength;
  // if minSimilarity >= 1, we treat it as number of edits
  if (minSimilarity >= 1f) {
    this.minSimilarity = 0; // just driven by number of edits
    maxEdits = (int) minSimilarity;
    raw = true;
  } else {
    this.minSimilarity = minSimilarity;
    // calculate the maximum k edits for this similarity
    maxEdits = initialMaxDistance(this.minSimilarity, termLength);
    raw = false;
  }
  if (transpositions && maxEdits > LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE) {
    throw new UnsupportedOperationException("with transpositions enabled, distances > " 
      + LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE + " are not supported ");
  }
  this.transpositions = transpositions;
  this.scale_factor = 1.0f / (1.0f - this.minSimilarity);

  this.maxBoostAtt = atts.addAttribute(MaxNonCompetitiveBoostAttribute.class);
  bottom = maxBoostAtt.getMaxNonCompetitiveBoost();
  bottomTerm = maxBoostAtt.getCompetitiveTerm();
  bottomChanged(null, true);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:64,代码来源:FuzzyTermsEnum.java


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