• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Arc类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
/**
 * Returns the value mapped to the given key or <code>null</code> if the key is not in the FST dictionary.
 */
public BytesRef get(char[] buffer, int bufferLen, Arc<BytesRef> scratchArc, BytesReader fstReader) throws IOException {
  BytesRef pendingOutput = fst.outputs.getNoOutput();
  BytesRef matchOutput = null;
  int bufUpto = 0;
  fst.getFirstArc(scratchArc);
  while (bufUpto < bufferLen) {
    final int codePoint = Character.codePointAt(buffer, bufUpto, bufferLen);
    if (fst.findTargetArc(ignoreCase ? Character.toLowerCase(codePoint) : codePoint, scratchArc, scratchArc, fstReader) == null) {
      return null;
    }
    pendingOutput = fst.outputs.add(pendingOutput, scratchArc.output);
    bufUpto += Character.charCount(codePoint);
  }
  if (scratchArc.isFinal()) {
    matchOutput = fst.outputs.add(pendingOutput, scratchArc.nextFinalOutput);
  }
  return matchOutput;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:StemmerOverrideFilter.java


示例2: get

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
/** Looks up the output for this input, or null if the
 *  input is not accepted. */
public static<T> T get(FST<T> fst, IntsRef input) throws IOException {

  // TODO: would be nice not to alloc this on every lookup
  final FST.Arc<T> arc = fst.getFirstArc(new FST.Arc<T>());

  final BytesReader fstReader = fst.getBytesReader();

  // Accumulate output as we go
  T output = fst.outputs.getNoOutput();
  for(int i=0;i<input.length;i++) {
    if (fst.findTargetArc(input.ints[input.offset + i], arc, arc, fstReader) == null) {
      return null;
    }
    output = fst.outputs.add(output, arc.output);
  }

  if (arc.isFinal()) {
    return fst.outputs.add(output, arc.nextFinalOutput);
  } else {
    return null;
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Util.java


示例3: addStartPaths

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
/** Adds all leaving arcs, including 'finished' arc, if
 *  the node is final, from this node into the queue.  */
public void addStartPaths(FST.Arc<T> node, T startOutput, boolean allowEmptyString, IntsRefBuilder input) throws IOException {

  // De-dup NO_OUTPUT since it must be a singleton:
  if (startOutput.equals(fst.outputs.getNoOutput())) {
    startOutput = fst.outputs.getNoOutput();
  }

  FSTPath<T> path = new FSTPath<>(startOutput, node, input);
  fst.readFirstTargetArc(node, path.arc, bytesReader);

  //System.out.println("add start paths");

  // Bootstrap: find the min starting arc
  while (true) {
    if (allowEmptyString || path.arc.label != FST.END_LABEL) {
      addIfCompetitive(path);
    }
    if (path.arc.isLast()) {
      break;
    }
    fst.readNextArc(path.arc, bytesReader);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:Util.java


示例4: lookupPrefix

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
private Long lookupPrefix(FST<Long> fst, FST.BytesReader bytesReader,
                          BytesRef scratch, Arc<Long> arc) throws /*Bogus*/IOException {

  Long output = fst.outputs.getNoOutput();
  
  fst.getFirstArc(arc);
  
  byte[] bytes = scratch.bytes;
  int pos = scratch.offset;
  int end = pos + scratch.length;
  while (pos < end) {
    if (fst.findTargetArc(bytes[pos++] & 0xff, arc, arc, bytesReader) == null) {
      return null;
    } else {
      output = fst.outputs.add(output, arc.output);
    }
  }
  
  return output;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:FreeTextSuggester.java


示例5: lookupPrefix

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
private Long lookupPrefix(BytesRef scratch, Arc<Long> arc) throws /*Bogus*/IOException {
  assert 0 == fst.outputs.getNoOutput().longValue();
  long output = 0;
  BytesReader bytesReader = fst.getBytesReader();
  
  fst.getFirstArc(arc);
  
  byte[] bytes = scratch.bytes;
  int pos = scratch.offset;
  int end = pos + scratch.length;
  while (pos < end) {
    if (fst.findTargetArc(bytes[pos++] & 0xff, arc, arc, bytesReader) == null) {
      return null;
    } else {
      output += arc.output.longValue();
    }
  }
  
  return output;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:WFSTCompletionLookup.java


示例6: get

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
/**
 * Returns the weight associated with an input string,
 * or null if it does not exist.
 */
public Object get(CharSequence key) {
  if (fst == null) {
    return null;
  }
  Arc<Long> arc = new Arc<>();
  Long result = null;
  try {
    result = lookupPrefix(new BytesRef(key), arc);
  } catch (IOException bogus) { throw new RuntimeException(bogus); }
  if (result == null || !arc.isFinal()) {
    return null;
  } else {
    return Integer.valueOf(decodeWeight(result + arc.nextFinalOutput));
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:WFSTCompletionLookup.java


示例7: cacheRootArcs

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
/**
 * Cache the root node's output arcs starting with completions with the
 * highest weights.
 */
@SuppressWarnings({"unchecked","rawtypes"})
private static Arc<Object>[] cacheRootArcs(FST<Object> automaton) {
  try {
    List<Arc<Object>> rootArcs = new ArrayList<>();
    Arc<Object> arc = automaton.getFirstArc(new Arc<>());
    FST.BytesReader fstReader = automaton.getBytesReader();
    automaton.readFirstTargetArc(arc, arc, fstReader);
    while (true) {
      rootArcs.add(new Arc<>().copyFrom(arc));
      if (arc.isLast()) break;
      automaton.readNextArc(arc, fstReader);
    }
    
    Collections.reverse(rootArcs); // we want highest weights first.
    return rootArcs.toArray(new Arc[rootArcs.size()]);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:FSTCompletion.java


示例8: checkStopNodes

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
private void checkStopNodes(FST<Long> fst, PositiveIntOutputs outputs) throws Exception {
  final Long nothing = outputs.getNoOutput();
  FST.Arc<Long> startArc = fst.getFirstArc(new FST.Arc<Long>());
  assertEquals(nothing, startArc.output);
  assertEquals(nothing, startArc.nextFinalOutput);

  FST.Arc<Long> arc = fst.readFirstTargetArc(startArc, new FST.Arc<Long>(),
                                             fst.getBytesReader());
  assertEquals('a', arc.label);
  assertEquals(17, arc.nextFinalOutput.longValue());
  assertTrue(arc.isFinal());

  arc = fst.readNextArc(arc, fst.getBytesReader());
  assertEquals('b', arc.label);
  assertFalse(arc.isFinal());
  assertEquals(42, arc.output.longValue());
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:TestFSTs.java


示例9: CcWordsFilter

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
protected CcWordsFilter(TokenStream input, CcArgs args) {
	super(input);
	this.args = args;
	//
	this.fst = args.wordSet.fst;
	this.fstReader = args.wordSet.fst.getBytesReader();
	this.fstWords = args.wordSet.words;
	this.fstFirstArc = new FST.Arc<>();
	this.fst.getFirstArc(fstFirstArc);
	this.scratchWordBytesRef = new BytesRef();
	this.scratchArc = new FST.Arc<>();
	this.scratchArcOfSep = new FST.Arc<>();
	this.scatchArcOfEnd = new FST.Arc<>();
	//
	this.pendingOutputs = new LinkedList<>();
}
 
开发者ID:thihy,项目名称:cc-analysis,代码行数:17,代码来源:CcWordsFilter.java


示例10: get

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
/**
 * Returns the weight associated with an input string,
 * or null if it does not exist.
 */
public Object get(CharSequence key) {
  if (fst == null) {
    return null;
  }
  Arc<Long> arc = new Arc<Long>();
  Long result = null;
  try {
    result = lookupPrefix(new BytesRef(key), arc);
  } catch (IOException bogus) { throw new RuntimeException(bogus); }
  if (result == null || !arc.isFinal()) {
    return null;
  } else {
    return Integer.valueOf(decodeWeight(result + arc.nextFinalOutput));
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:20,代码来源:WFSTCompletionLookup.java


示例11: cacheRootArcs

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
/**
 * Cache the root node's output arcs starting with completions with the
 * highest weights.
 */
@SuppressWarnings({"unchecked","rawtypes"})
private static Arc<Object>[] cacheRootArcs(FST<Object> automaton) {
  try {
    List<Arc<Object>> rootArcs = new ArrayList<Arc<Object>>();
    Arc<Object> arc = automaton.getFirstArc(new Arc<Object>());
    FST.BytesReader fstReader = automaton.getBytesReader();
    automaton.readFirstTargetArc(arc, arc, fstReader);
    while (true) {
      rootArcs.add(new Arc<Object>().copyFrom(arc));
      if (arc.isLast()) break;
      automaton.readNextArc(arc, fstReader);
    }
    
    Collections.reverse(rootArcs); // we want highest weights first.
    return rootArcs.toArray(new Arc[rootArcs.size()]);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:24,代码来源:FSTCompletion.java


示例12: addStartPaths

import org.apache.lucene.util.fst.FST.Arc; //导入依赖的package包/类
/** Adds all leaving arcs, including 'finished' arc, if
 *  the node is final, from this node into the queue.  */
public void addStartPaths(FST.Arc<T> node, T startOutput, boolean allowEmptyString, IntsRef input) throws IOException {

  // De-dup NO_OUTPUT since it must be a singleton:
  if (startOutput.equals(fst.outputs.getNoOutput())) {
    startOutput = fst.outputs.getNoOutput();
  }

  FSTPath<T> path = new FSTPath<T>(startOutput, node, input);
  fst.readFirstTargetArc(node, path.arc, bytesReader);

  //System.out.println("add start paths");

  // Bootstrap: find the min starting arc
  while (true) {
    if (allowEmptyString || path.arc.label != FST.END_LABEL) {
      addIfCompetitive(path);
    }
    if (path.arc.isLast()) {
      break;
    }
    fst.readNextArc(path.arc, bytesReader);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:26,代码来源:Util.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Compartment类代码示例发布时间:2022-05-23
下一篇:
Java IParser类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap