Java 类org.neo4j.graphdb.traversal.Evaluation 实例源码

项目:WhiteLab2.0-Neo4J-Plugin    文件:QueryBenchmark.java   
private Traverser getPatternMatch(Node startNode, final List<String> patterns, final List<NodeLabel> nodeLabels, final List<LinkLabel> linkLabels) {
    TraversalDescription td = database.traversalDescription()
        .depthFirst()
        .evaluator( new Evaluator() {
            public Evaluation evaluate( final org.neo4j.graphdb.Path path ) {
                if ( path.length() == 0 ) {
                    return Evaluation.EXCLUDE_AND_CONTINUE;
                }
                boolean isToken = path.endNode().hasLabel(NodeLabel.WordToken);
                boolean included = isToken && (path.length() == 1 || nodeHasAnnotation(path.endNode(), linkLabels.get(path.length() - 1), patterns.get(path.length() - 1)));
                boolean continued = path.length() < patterns.size();
                return Evaluation.of( included, continued );
            }
        } )
        .relationships(LinkLabel.NEXT, Direction.OUTGOING)
        .relationships(LinkLabel.HAS_TYPE, Direction.INCOMING)
        .relationships(LinkLabel.HAS_LEMMA, Direction.INCOMING)
        .relationships(LinkLabel.HAS_POS_TAG, Direction.INCOMING)
        .relationships(LinkLabel.HAS_HEAD, Direction.INCOMING);
    return td.traverse(startNode);
}
项目:dnainator    文件:ClusterEvaluator.java   
/**
 * Evaluates a node and determines whether to include and / or continue.
 * Continues on and returns exactly those nodes that:
 * <ul>
 *   <li>haven't been visited yet and</li>
 *   <li>are the start node
 *   <ul>
 *     <li>have a sequence &lt; threshold (and thus belong to the same cluster)</li>
 *   </ul>
 * </ul>
 */
@Override
public Evaluation evaluate(Path path) {
    Node end = path.endNode();
    int score = is.compute(new Neo4jScoreContainer(end));
    end.setProperty(SequenceProperties.INTERESTINGNESS.name(), score);
    String id = (String) end.getProperty(ID.name());

    if (!visited.contains(id)
            && (path.startNode().getId() == path.endNode().getId()
            || score < threshold)) {
        visited.add(id);
        return Evaluation.INCLUDE_AND_CONTINUE;
    }
    return Evaluation.EXCLUDE_AND_PRUNE;
}
项目:neo4j-mobile-android    文件:MultiEvaluator.java   
public Evaluation evaluate( Path position )
{
    boolean includes = true;
    boolean continues = true;
    for ( Evaluator evaluator : this.evaluators )
    {
        Evaluation bla = evaluator.evaluate( position );
        if ( !bla.includes() )
        {
            includes = false;
        }
        if ( !bla.continues() )
        {
            continues = false;
        }
        if ( !continues && !includes )
        {
            return Evaluation.EXCLUDE_AND_PRUNE;
        }
    }
    return Evaluation.of( includes, continues );
}
项目:cypher_hip_hop    文件:HipHopEvaluator.java   
@Override
public Evaluation evaluate(Path path, BranchState branchState) {
    if (path.endNode().hasLabel(stopLabel)) {
        return Evaluation.EXCLUDE_AND_PRUNE;
    } else {
        return Evaluation.INCLUDE_AND_CONTINUE;
    }
}
项目:power_grid    文件:EnergizationEvaluator.java   
@Override
public Evaluation evaluate(Path path, BranchState<Double> branchState) {
    // Path with just the single node, ignore it and continue
    if (path.length() == 0 ) {
        return Evaluation.INCLUDE_AND_CONTINUE;
    }
    // Make sure last Equipment voltage is equal to or lower than previous voltage
    Double voltage = (Double) path.endNode().getProperty("voltage", 999.0);
    if (voltage <= branchState.getState()) {
        return Evaluation.INCLUDE_AND_CONTINUE;
    } else {
        return Evaluation.EXCLUDE_AND_PRUNE;
    }
}
项目:neo_airlines    文件:ReachedDestinationEvaluator.java   
@Override
public Evaluation evaluate(Path path) {
    Node lastNode = path.endNode();
    if (!lastNode.hasLabel(Labels.AirportDay)){
        return Evaluation.EXCLUDE_AND_CONTINUE;
    } else if (destinations.contains( ((String)lastNode.getProperty("key")).substring(0,3) )) {
        return Evaluation.INCLUDE_AND_PRUNE;
    }
    return Evaluation.EXCLUDE_AND_CONTINUE;
}
项目:neo_airlines    文件:ReachedDestinationAtEvaluator.java   
@Override
public Evaluation evaluate(Path path) {
    if (path.length() < length) {
        return Evaluation.EXCLUDE_AND_CONTINUE;
    }

    Node lastNode = path.endNode();
    if (!lastNode.hasLabel(Labels.AirportDay)){
        return Evaluation.EXCLUDE_AND_CONTINUE;
    } else if (destinations.contains( ((String)lastNode.getProperty("key")).substring(0,3) )) {
        return Evaluation.INCLUDE_AND_PRUNE;
    }
    return Evaluation.EXCLUDE_AND_PRUNE;
}
项目:welshare    文件:ViralLinkDaoNeo4j.java   
@Override
public Evaluation evaluate(Path path) {
    if (!path.endNode().hasRelationship(Direction.OUTGOING)) {
        leaves++;
        depthSum += path.length();
    }

    return Evaluation.EXCLUDE_AND_CONTINUE;
}
项目:SciGraph    文件:ReachabilityEvaluator.java   
@Override
public Evaluation evaluate(Path path) {
  long currentId = path.endNode().getId();
  if (!nodePredicate.apply(path.endNode())) {
    inMemoryIndex.get(currentId);
    return Evaluation.EXCLUDE_AND_PRUNE;
  }

  long startId = path.startNode().getId(); // Vi
  InOutList listPair = inMemoryIndex.get(currentId);

  if (0 == path.length()) {
    // first node in the traverse - add itself to the in-out list
    listPair.getInList().add(currentId);
    listPair.getOutList().add(currentId);
    return Evaluation.INCLUDE_AND_CONTINUE;
  }
  else if (direction == Direction.INCOMING ) {
    // doing reverse BFS
    if (nodesAreConnected(currentId, startId)) {
      return Evaluation.EXCLUDE_AND_PRUNE;
    } else {
      listPair.getOutList().add(startId);
      return Evaluation.INCLUDE_AND_CONTINUE;
    }
  } else {
    //doing BFS
    if (nodesAreConnected(startId, currentId)) { // cur is w
      return Evaluation.EXCLUDE_AND_PRUNE;
    } else {
      listPair.getInList().add(startId);
      return Evaluation.INCLUDE_AND_CONTINUE;
    }
  }
}
项目:neo4j-mobile-android    文件:TraversalDescriptionImpl.java   
public Evaluation evaluate( Path path )
{
    // Before the Evaluator, when PruneEvaluator was used individually a PruneEvaluator
    // was never called with the start node as argument. This condition mimics that behaviour.
    if ( path.length() == 0 )
    {
        return Evaluation.INCLUDE_AND_CONTINUE;
    }
    return pruning.pruneAfter( path ) ? Evaluation.INCLUDE_AND_PRUNE : Evaluation.INCLUDE_AND_CONTINUE;
}
项目:checklistbank    文件:ChunkingEvaluator.java   
@Override
public Evaluation evaluate(Path path) {
  Node n = path.endNode();
  UsageFacts facts = dao.readFacts(n.getId());
  int size = facts == null ? -1 : facts.metrics.getNumDescendants() + facts.metrics.getNumSynonyms();
  if (size > minChunkSize && (size < chunkSize || size - facts.metrics.getNumChildren() < minChunkSize)) {
    chunkIds.add(n.getId());
    return Evaluation.INCLUDE_AND_PRUNE;
  } else {
    return Evaluation.INCLUDE_AND_CONTINUE;
  }
}
项目:cypher_hip_hop    文件:HipHopEvaluator.java   
@Override
public Evaluation evaluate(Path path) {
    return null;
}
项目:power_grid    文件:EnergizationEvaluator.java   
@Override
public Evaluation evaluate(Path path) {
    return null;
}
项目:unmanaged-extension    文件:TraversalPrinter.java   
private Evaluation printResult( Evaluation evaluation )
{
    System.out.print( String.format( " %s\n", evaluation.name() ) );
    return evaluation;
}
项目:unmanaged-extension    文件:TraversalPrinter.java   
public Evaluation evaluate( Path path )
{
    printPath( path );
    return printResult( innerEvaluator.evaluate( path ) );
}
项目:steps    文件:StepsEvaluator.java   
@Override
public Evaluation evaluate( Path path )
{
    // TODO deal with this in better way
    throw new UnsupportedOperationException();
}
项目:steps    文件:StepsEvaluator.java   
@Override
public Evaluation evaluate( Path path, BranchState<StepState> state )
{
    int currentStep = state.getState().step();
    int stepStateState = state.getState().state();
    while ( true )
    {
        StepEvaluationResult result = stepEvaluators[currentStep].evaluate( path, stepStateState );
        switch ( result.stepEvaluation() )
        {
        case REJECT_STAY_EXCLUDE_PRUNE:
            /*
             * evaluator failed fatally
             */
            return Evaluation.EXCLUDE_AND_PRUNE;
        case REJECT_ADVANCE_EXCLUDE_CONTINUE:
            /*
             * evaluator failed & exhausted
             * advance evaluator immediately (current step) & retry
             */
            currentStep++;
            stepStateState = result.stepState();
            continue;
        case ACCEPT_ADVANCE_EXCLUDE_CONTINUE:
            /*
             * evaluator succeeded & exhausted
             * advance evaluator for next step
             */
            currentStep++;
            state.setState( new StepState( currentStep, result.stepState() ) );
            return Evaluation.EXCLUDE_AND_CONTINUE;
        case ACCEPT_STAY_EXCLUDE_CONTINUE:
            /*
             * evaluator succeeded but not exhausted
             * reuse evaluator @ next step
             */
            state.setState( new StepState( currentStep, result.stepState() ) );
            return Evaluation.EXCLUDE_AND_CONTINUE;
        case ACCEPT_STAY_INCLUDE_CONTINUE:
            /*
             * final evaluator succeeded but not exhausted
             * return path & reuse evaluator @ next step
             */
            state.setState( new StepState( currentStep, result.stepState() ) );
            return Evaluation.INCLUDE_AND_CONTINUE;
        case ACCEPT_ADVANCE_INCLUDE_PRUNE:
            /*
             * final evaluator succeeded & exhausted
             * return path
             */
            return Evaluation.INCLUDE_AND_PRUNE;
        }
    }
}
项目:neo4j-mobile-android    文件:TraversalBranchImpl.java   
public Evaluation evaluation()
{
    return evaluation;
}
项目:neo4j-mobile-android    文件:FinalTraversalBranch.java   
public Evaluation evaluation()
{
    return null;
}
项目:neo4j-mobile-android    文件:TraversalDescriptionImpl.java   
public Evaluation evaluate( Path path )
{
    return filter.accept( path ) ? Evaluation.INCLUDE_AND_CONTINUE : Evaluation.EXCLUDE_AND_CONTINUE;
}
项目:checklistbank    文件:LinneanRankEvaluator.java   
@Override
public Evaluation evaluate(Path path) {
  Node end = path.endNode();
  Rank r = Rank.values()[(int) end.getProperty(NeoProperties.RANK, Rank.UNRANKED.ordinal())];
  return r.isLinnean() ? Evaluation.INCLUDE_AND_CONTINUE : Evaluation.EXCLUDE_AND_CONTINUE;
}
项目:checklistbank    文件:AcceptedOnlyEvaluator.java   
@Override
public Evaluation evaluate(Path path) {
  Node end = path.endNode();
  return end.hasLabel(Labels.SYNONYM) ? Evaluation.EXCLUDE_AND_CONTINUE : Evaluation.INCLUDE_AND_CONTINUE;
}
项目:checklistbank    文件:RankEvaluator.java   
@Override
public Evaluation evaluate(Path path) {
  return evaluateNode(path.endNode()) ? Evaluation.INCLUDE_AND_CONTINUE : Evaluation.EXCLUDE_AND_CONTINUE;
}
项目:dswarm-graph-neo4j    文件:StatementEvaluator.java   
/**
 * note: we maybe can also utilise the qualified attribute __LITERAL__ here or the __LITERAL__ node label;
 *
 * @param path
 * @return
 */
@Override
public Evaluation evaluate(final Path path) {

    if(path.length() < 1) {

        return Evaluation.EXCLUDE_AND_CONTINUE;
    }

    if(path.lastRelationship().getStartNode().getId() != subjectNodeId) {

        return Evaluation.EXCLUDE_AND_CONTINUE;
    }

    if(path.endNode().hasRelationship(Direction.OUTGOING)) {

        return Evaluation.EXCLUDE_AND_PRUNE;
    }

    if(path.lastRelationship().hasProperty(DeltaStatics.MATCHED_PROPERTY) && Boolean.TRUE.equals(path.lastRelationship().getProperty(DeltaStatics.MATCHED_PROPERTY, null))) {

        // only non-matched statements
        return Evaluation.EXCLUDE_AND_PRUNE;
    }

    return Evaluation.INCLUDE_AND_PRUNE;
}
项目:dswarm-graph-neo4j    文件:EntityEvaluator.java   
@Override
public Evaluation evaluate(final Path path) {

    if (path.length() > relativeAttributePathSizeAttributePathSize) {

        return Evaluation.EXCLUDE_AND_PRUNE;
    }

    if (path.length() > currentHierarchy) {

        currentHierarchy++;
    }

    if (path.length() < currentHierarchy) {

        return Evaluation.EXCLUDE_AND_CONTINUE;
    }

    final Relationship lastRelationship = path.lastRelationship();
    final String attributeURI = relativeAttributePathAttributes.get(currentHierarchy - 1).getUri();

    // TODO: this was for debugging, or?
    //lastRelationship.getType().name();
    //Paths.pathToString(path, new PathPrinter());

    if (!lastRelationship.isType(DynamicRelationshipType.withName(attributeURI))) {

        return Evaluation.EXCLUDE_AND_PRUNE;
    }

    if (currentHierarchy < relativeAttributePathSizeAttributePathSize) {

        return Evaluation.EXCLUDE_AND_CONTINUE;
    }

    return Evaluation.INCLUDE_AND_PRUNE;
}