/** * */ public void endDocument() { documentMarkers.push(input.size()); }
/** * Convert a list of documents to sparse document-count representation. */ public static int [] toSparseEncoding(IntStack documents) { if (documents.size() == 0) return EMPTY_INT_ARRAY; // For smaller arrays, count using sorting. if (documents.size() < 1000) { return toSparseEncodingBySort(documents); } else { return toSparseEncodingByHash(documents); } }
public void newState(int state, int position) { while (stateOriginDocument.size() < state) stateOriginDocument.push(-1); stateOriginDocument.push(currentDocument); } }
/** * Collect all words from a phrase. */ private void appendWords(IntStack words, IntStack offsets, PhraseCandidate p) { final int start = words.size(); final int [] phraseIndices = p.cluster.phrases.get(0); final short [] tokenTypes = context.allWords.type; for (int i = 0; i < phraseIndices.length; i += 2) { for (int j = phraseIndices[i]; j <= phraseIndices[i + 1]; j++) { final int termIndex = sb.input.get(j); if (!TokenTypeUtils.isCommon(tokenTypes[termIndex])) { words.push(termIndex); } } } offsets.push(start, words.size() - start); }
/** * Convert to sparse encoding using a hash map. */ public static int [] toSparseEncodingByHash(IntStack documents) { final IntIntHashMap map = new IntIntHashMap(); final int toIndex = documents.size(); final int [] buffer = documents.buffer; for (int i = 0; i < toIndex; i++) { map.putOrAdd(buffer[i], 1, 1); } return hashToKeyValuePairs(map); }
for (int i = 0; i < path.size(); i += 2)
private void visit(int nodeId) { final int stackSize = stack.size(); index[nodeId] = stackSize; stack.push(nodeId); boundaries.push(stackSize); push(Action.POSTVISIT, nodeId); graph.forEachRelationship(nodeId, Direction.OUTGOING, (sourceNodeId, targetNodeId, relationId) -> { push(Action.VISITEDGE, targetNodeId); return true; }); }
private void visit(int nodeId) { final int stackSize = stack.size(); index[nodeId] = stackSize; stack.push(nodeId); boundaries.push(stackSize); push(Action.POSTVISIT, nodeId); graph.forEachRelationship(nodeId, Direction.OUTGOING, (sourceNodeId, targetNodeId, relationId) -> { push(Action.VISITEDGE, targetNodeId); return true; }); }
final int size = flipStack.popStack().size(); final int batchSize = Math.floorDiv(size, concurrency);
final int size = flipStack.popStack().size(); final int batchSize = Math.floorDiv(size, concurrency);