Examples of Candidate


Examples of com.yahoo.labs.taxomo.learn.Candidate

 
  public Model getBestModel(int maxOutputStates) {
    logger.info( "Will score candidates by " + outputScorer );
   
    // Sort candidates by output scorer
    Candidate resultsSorted[] = results.keySet().toArray(new Candidate[] {});
    Arrays.sort(resultsSorted, (SearchStrategy)outputScorer);
   
    int minNumStatesReached = Integer.MAX_VALUE;
    for( int i=0; i<resultsSorted.length; i++ ) {
      int numStates = resultsSorted[i].getNumStates();
      if( (numStates>1) && (numStates < minNumStatesReached) ) {
        minNumStatesReached = numStates;
      }
    }
   
    int realisticMaxOutputStates = maxOutputStates;
    if( minNumStatesReached > maxOutputStates ) {
      logger.warn( "Could not find a model with " + maxOutputStates + " states or less" );
      logger.warn( "Apart from the model with one state (which is never returned!), all the other models had " + minNumStatesReached + " states or more" );
      realisticMaxOutputStates = minNumStatesReached;
    }
   
    // Try to find the best one
    Candidate winner = null;
    for( int i=0; i<resultsSorted.length; i++ ) {
      int numStates = resultsSorted[i].getNumStates();
      // The model with only 1 state is never returned
      if( (numStates>1) && (numStates <= realisticMaxOutputStates ) ) {
        winner = resultsSorted[i];
View Full Code Here

Examples of com.yahoo.labs.taxomo.learn.Candidate

    }

    File inputFile = new File(jsapResult.getString("input-file"));
    File taxoFile = new File(jsapResult.getString("taxonomy-file"));
    Taxonomy tree = new Taxonomy(taxoFile);
    Candidate initialCandidate;

    if (jsapResult.userSpecified("init-explicit")) {
      initialCandidate = new Candidate(tree, Util.split(jsapResult.getString("init-explicit")), null, null);

    } else if (jsapResult.userSpecified("init-all-level")) {
      initialCandidate = Candidate.createFixedLevelCandidate(tree, jsapResult.getInt("init-all-level"));
     
    } else if (jsapResult.getBoolean("init-all-leaves")) {
      initialCandidate = Candidate.createLeafCandidate(tree);

    } else {
      throw new IllegalArgumentException("Either --init-explicit, --init-all-leaves, or --init-all-level should be specified. See --help.");
    }
    logger.debug("Initial candidate is " + initialCandidate.toBriefString());
   
    Class<SearchStrategy> strategy = (Class<SearchStrategy>) Class.forName(SearchStrategy.class.getPackage().getName() + "." + jsapResult.getString("search-method"));
    logger.debug("Search strategy is " + strategy );
   
    double weight1 = jsapResult.getDouble("search-method-weight-1");
View Full Code Here

Examples of de.javawi.jstun.test.demo.ice.Candidate

                    e.printStackTrace();
                } catch (UnknownHostException e) {
                    e.printStackTrace();
                }
            }
            Candidate candidate = cc.getSortedCandidates().get(0);
            String temp = "C: " + candidate.getAddress().getInetAddress() + "|" + candidate.getBase().getAddress().getInetAddress()
                    + " p:" + candidate.getPriority();
            if (first.equals(""))
                first = temp;
            assertEquals(first, temp);
            first = temp;
        }
View Full Code Here

Examples of maui.util.Candidate

            // that map to nothing in the vocabulary
            if (!candidateNames.isEmpty()) {

              for (String name : candidateNames) {

                Candidate candidate = candidatesTable.get(name);

                if (candidate == null) {
                  // this is the first occurrence of this
                  // candidate
                  // create a candidate object

                  if (vocabularyName.equals("wikipedia")) {
                    Anchor anchor;
                    try {
                      anchor = new Anchor(form,
                          textProcessor, wikipedia
                          .getDatabase());
                      double probability = anchor.getLinkProbability();
                      if (probability >= minKeyphraseness) {
                        // add this candidate to the
                        // list
                        countCandidates++;
                        totalFrequency++;
                        firstWord = pos - i;
                        candidate = new Candidate(name,
                            form, firstWord, anchor, probability);
                       
                      }

                    } catch (SQLException e) {
                      System.err
                      .println("Error adding ngram "
                          + form);
                      e.printStackTrace();
                    }

                  } else {

                    firstWord = pos - i;
                    candidate = new Candidate(name, form,
                        firstWord);
                    totalFrequency++;
                    // if it's a controlled vocabulary, this
                    // allows
                    // retrieve how this topic is refered to
                    // by a descriptor
                    if (!vocabularyName.equals("none")) {
                      candidate.setTitle(vocabulary
                          .getTerm(name));
                    }

                  }

                } else {

                  // candidate has been observed before
                  // update its values
                  // System.out.println(form);
                  firstWord = pos - i;
                  candidate.recordOccurrence(form, firstWord);
                  countCandidates++;
                  totalFrequency++;

                }
                if (candidate != null) {
                  candidatesTable.put(name, candidate);
                }
              }
            }
          }

        }
      }
    }

    for (Candidate candidate : candidatesTable.values()) {
      candidate.normalize(totalFrequency, pos);
    }

    if (vocabularyName.equals("wikipedia")) {
      candidatesTable = disambiguateCandidates(candidatesTable.values());
    }
View Full Code Here

Examples of maui.util.Candidate

      try {

        // assessing each sense of the candidate
        for (Anchor.Sense sense : candidate.getAnchor().getSenses()) {

          Candidate candidateCopy = candidate.getCopy();

          double senseProbablity = sense.getProbability();

          if (senseProbablity < minSenseProbability)
            break;

          // if unambiguous, add immidiately
          if (senseProbablity == 1.0) {

            id = sense.getId() + "";
            candidateCopy.setName(id);
            candidateCopy.setTitle(sense.getTitle());
            candidateCopy.setArticle(sense);
            if (disambiguatedTopics.containsKey(id)) {
              Candidate previousCandidate = disambiguatedTopics
              .get(id);
              // update the values of the previous candidate by
              // the values of the new one
            //  System.out.println("WAS1 " +
            //   previousCandidate.getInfo());
            //   System.out.println("MRG1 " +
            //   candidateCopy.getInfo());
              candidateCopy.mergeWith(previousCandidate);
            //   System.out.println("NOW1 " +
            //   candidateCopy.getInfo());

            }
            disambiguatedTopics.put(id, candidateCopy);

            // else resolve ambiguity
          } else {

            // to avoid multiplication by 0
            // in cases where an ngram is never an anchor text
            // but appears as a title of Wikipedia page
            if (senseProbablity == 0) {
              senseProbablity = minSenseProbability;
            }

            double semanticRelatedness = 0;
            try {
              // compute the relatedness to context and the
              // commonness of the meaning
              semanticRelatedness = getRelatednessTo(sense,
                  context);
            } catch (Exception e) {
              System.err
              .println("Error computing semantic relatedness for the sense "
                  + sense);
              e.printStackTrace();
            }

            // final score
            double disambiguationScore = senseProbablity
            * semanticRelatedness;

            if (disambiguationScore > 0.01) {
              // this is a valid sense (there may be more than
              // one)

              id = sense.getId() + "";
              candidateCopy.setName(id);
              candidateCopy.setTitle(sense.getTitle());
              candidateCopy.setArticle(sense);
              if (disambiguatedTopics.containsKey(id)) {
                Candidate previousCandidate = disambiguatedTopics
                .get(id);
                // update the values of the previous candidate
                // by the values of the new one
            //     System.out.println("WAS2 " +
            //     previousCandidate.getInfo());
View Full Code Here

Examples of net.sourceforge.argparse4j.internal.ArgumentParserImpl.Candidate

        assertEquals("argparse4j version 7.8.7 (Dreamliner)", ap.formatVersion());
    }

    @Test
    public void testCandidateEquality() {
        Candidate foo = new Candidate(15, "foo");
        Candidate fooCopy = new Candidate(15, "foo");
        Candidate bar = new Candidate(15, "bar");
        Candidate foo2 = new Candidate(16, "foo");
        assertTrue(foo.equals(foo));
        assertTrue(foo.equals(fooCopy));
        assertFalse(foo.equals(bar));
        assertFalse(foo.equals(foo2));
        assertFalse(foo.equals(null));
        assertFalse(foo.equals("foo"));
        Candidate subNull = new Candidate(15, null);
        assertFalse(foo.equals(subNull));
        assertFalse(subNull.equals(foo));

        assertEquals(foo.hashCode(), fooCopy.hashCode());
        assertFalse(foo.hashCode() == foo2.hashCode());
        assertFalse(foo.hashCode() == bar.hashCode());
        assertFalse(foo.hashCode() == subNull.hashCode());
    }
View Full Code Here

Examples of org.elasticsearch.search.suggest.phrase.DirectCandidateGenerator.Candidate

    public BytesRef join(BytesRef separator, BytesRefBuilder result, BytesRef preTag, BytesRef postTag) {
        BytesRef[] toJoin = new BytesRef[this.candidates.length];
        int len = separator.length * this.candidates.length - 1;
        for (int i = 0; i < toJoin.length; i++) {
            Candidate candidate = candidates[i];
            if (preTag == null || candidate.userInput) {
                toJoin[i] = candidate.term;
            } else {
                final int maxLen = preTag.length + postTag.length + candidate.term.length;
                final BytesRefBuilder highlighted = new BytesRefBuilder();// just allocate once
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.