Package ivory.smrf.model

Examples of ivory.smrf.model.Clique$MaxScoreComparator


    String potentialType = XMLTools.getAttributeValueOrThrowException(domNode, "potential",
        "A potential attribute must be specified in order to generate a clique set!");

    // If there is more than one term, then add appropriate cliques.
    ArrayList<GraphNode> cliqueNodes = null;
    Clique c = null;

    for (int i = 1; i < Math.pow(2, queryTerms.length); i++) {
      String binary = Integer.toBinaryString(i);
      int padding = queryTerms.length - binary.length();
      for (int j = 0; j < padding; j++) {
        binary = "0" + binary;
      }

      boolean singleTerm = false;
      boolean contiguous = true;

      int firstOne = binary.indexOf('1');
      int lastOne = binary.lastIndexOf('1');
      if (lastOne == firstOne) {
        singleTerm = true;
      }

      for (int j = binary.indexOf('1') + 1; j <= binary.lastIndexOf('1') - 1; j++) {
        if (binary.charAt(j) == '0') {
          contiguous = false;
          break;
        }
      }

      if (ordered && !singleTerm && contiguous) {
        cliqueNodes = Lists.newArrayList();
        if (docDependent) {
          cliqueNodes.add(docNode);
        }
        for (int j = firstOne; j <= lastOne; j++) {
          TermNode termNode = new TermNode(queryTerms[j]);
          cliqueNodes.add(termNode);
        }

        // Get the potential function.
        PotentialFunction potential = PotentialFunction.create(env, potentialType, domNode);

        c = new Clique(cliqueNodes, potential, parameter);
        cliques.add(c);
      } else if (!ordered && !singleTerm && !contiguous) {
        cliqueNodes = Lists.newArrayList();
        if (docDependent) {
          cliqueNodes.add(docNode);
        }
        for (int j = 0; j < binary.length(); j++) {
          if (binary.charAt(j) == '1') {
            TermNode termNode = new TermNode(queryTerms[j]);
            cliqueNodes.add(termNode);
          }
        }

        // Get the potential function.
        PotentialFunction potential = PotentialFunction.create(env, potentialType, domNode);

        c = new Clique(cliqueNodes, potential, parameter);
        cliques.add(c);
      }
    }

    return cliques;
View Full Code Here


      cliqueNodes.add(termNode);

      // Get the potential function.
      PotentialFunction potential = PotentialFunction.create(env, potentialType, domNode);

      Clique c = new Clique(cliqueNodes, potential, termParameter);
      addClique(c);
    }
  }
View Full Code Here

    String potentialType = XMLTools.getAttributeValueOrThrowException(domNode, "potential",
        "Error: A potential type must be specified!");

    PotentialFunction potential = PotentialFunction.create(env, potentialType, domNode);

    Clique c = new Clique(cliqueNodes, potential, parameter, 1.0f, getType(), true);
    addClique(c);
  }
View Full Code Here

      throw new ConfigurationException("A potential attribute must be specified in order to generate a clique set!");
    }

    // If there is more than one term, then add appropriate cliques.
    List<GraphNode> cliqueNodes = null;
    Clique c = null;
    TermNode lastTermNode = null;

    for (String element : queryTerms) {
      // Term node.
      TermNode termNode = new TermNode(element);
View Full Code Here

    if (potentialType == null) {
      throw new ConfigurationException("A potential attribute must be specified in order to generate a clique set!");
    }
    // If there is more than one term, then add appropriate cliques.
    ArrayList<GraphNode> cliqueNodes = null;
    Clique c = null;

    for (int i = 1; i < Math.pow(2, queryTerms.length); i++) {
      String binary = Integer.toBinaryString(i);
      int padding = queryTerms.length - binary.length();
      for (int j = 0; j < padding; j++) {
View Full Code Here

      cliqueNodes.add(termNode);

      // Get the potential function.
      PotentialFunction potential = PotentialFunction.create(env, potentialType, domNode);

      Clique c = new CascadeClique(cliqueNodes, potential, termParameter, cascadeStage, pruner_and_params);
      addClique(c);
    }
  }
View Full Code Here

      // Document-at-a-time scoring.
      float docMaxScore = mrfMaxScore;
      boolean skipped = false;
      for (int i = 0; i < cliques.size(); i++) {
        // Current clique that we're scoring.
        Clique c = cliques.get(i);

        // If there's no way that this document can enter the result set
        // then exit.
        if (score + docMaxScore <= scoreThreshold) {
          // Advance postings readers (but don't score).
          for (int j = i; j < cliques.size(); j++) {
            cliques.get(j).setNextCandidate(docno + 1);
          }
          skipped = true;
          break;
        }

        // Document independent cliques do not affect the ranking.
        if (!c.isDocDependent()) {
          continue;
        }

        // Update document score.
        score += c.getWeight() * c.getPotential();

        // Update the max score for the rest of the cliques.
        docMaxScore -= c.getMaxScore();
      }

      // Keep track of mNumResults best accumulators.
      if (!skipped && score > scoreThreshold) {
        a.docno = docno;
View Full Code Here

        TermNode termNode = new TermNode(concept);
        cliqueNodes.add(termNode);

        PotentialFunction potential = new QueryPotential(env, generator, fn);

        Clique c = new Clique(cliqueNodes, potential, parameter);
        c.setType(Clique.Type.Term);

        // Scale importance values by LCE likelihood.
        float normalizedScore = expanderWeight * (a.score / totalWt);
        if (importanceModel != null) {
          c.setImportance(normalizedScore * importanceModel.getCliqueWeight(c));
        } else {
          c.setImportance(normalizedScore);
        }

        expandedMRF.addClique(c);
      }
    }
View Full Code Here

TOP

Related Classes of ivory.smrf.model.Clique$MaxScoreComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.