evaluates matching score
331771
function evaluate(score, at, mt) {
    var automaticThreshold = at || 17.73;
    var manualThreshold = mt || 15.957;

    var result = "no match";

    if (score >= automaticThreshold) {
        result = "automatic";
    } else if (score >= manualThreshold) {
        result = "manual";
    }

    return result;
}
656956
def evaluate_similarity(args, token_embedding, ctx, logfile=None,
                        global_step=0):
    """"""

    results = []
    for similarity_function in args.similarity_functions:
        evaluator = nlp.embedding.evaluation.WordEmbeddingSimilarity(
            idx_to_vec=token_embedding.idx_to_vec,
            similarity_function=similarity_function)
        evaluator.initialize(ctx=ctx)
        if not args.no_hybridize:
            evaluator.hybridize()

        # Evaluate all datasets
        for (dataset_name, dataset_kwargs,
             dataset) in iterate_similarity_datasets(args):
            initial_length = len(dataset)
            dataset_coded = [[
                token_embedding.token_to_idx[d[0]],
                token_embedding.token_to_idx[d[1]], d[2]
            ] for d in dataset if d[0] in token_embedding.token_to_idx
                             and d[1] in token_embedding.token_to_idx]
            num_dropped = initial_length - len(dataset_coded)

            # All words are unknown
            if not len(dataset_coded):
                correlation = 0
            else:
                words1, words2, scores = zip(*dataset_coded)
                pred_similarity = evaluator(
                    mx.nd.array(words1, ctx=ctx), mx.nd.array(words2, ctx=ctx))
                sr = stats.spearmanr(pred_similarity.asnumpy(),
                                     np.array(scores))
                correlation = sr.correlation

            logging.info(
                'Spearman rank correlation on %s (%s pairs) %s with %s:\t%s',
                dataset.__class__.__name__, len(dataset_coded),
                str(dataset_kwargs), similarity_function, correlation)

            result = dict(
                task='similarity',
                dataset_name=dataset_name,
                dataset_kwargs=dataset_kwargs,
                similarity_function=similarity_function,
                spearmanr=correlation,
                num_dropped=num_dropped,
                global_step=global_step,
            )
            log_similarity_result(logfile, result)
            results.append(result)

    return results
729716
def _match_show(self, show):
        """"""
        if self.show:
            return match_list(self.show, show)
        else:
            return True
300510
def _load_score(self):
        """"""
        score = int(self.score_file.read())
        self.score_file.seek(0, os.SEEK_SET)
        return score
1070240
public Match match(List<String> desired, int threshold) {
    return matchImpl(parse(desired), threshold);
  }
1263664
double evaluateBy(ScoreEvaluation eval) {
    return eval.evaluate(new DBIDsTest(DBIDUtil.ensureSet(scores.getDBIDs())), new OutlierScoreAdapter(this));
  }
429792
def matches(s, t, i, j, k):
    """"""
    for d in range(k):
        if s[i + d] != t[j + d]:
            return False
    return True
539321
private synchronized void pessimisticGet(
    Object key,
    MatchSpaceKey msg,
    EvalCache cache,
    Object rootContext,
    SearchResults result)
    throws MatchingException, BadMessageFormatMatchingException
  {

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.entry(
        this,cclass,
        "pessimisticGet", new Object[] {key,msg,cache,result});

    // Everything must execute under the MatchSpace lock
    // Obtain the cache entry and determine if its otherMatchers and results entries are
    // usable, invalidating them if not.
    CacheEntry e = getCacheEntry(key, true);
    if (e.matchTreeGeneration != matchTreeGeneration)
    {
      e.cachedResults = null;
      e.otherMatchers = null;
    }
    // Look in the cache for a usable cachedResults, using them to satisfy the request
    // iff the results object is willing to accept them.
    if (e.cachedResults != null && result.acceptCacheable(e.cachedResults))
    {
      resultCacheHitGets++;
      pessimisticGets++;

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        tc.exit(this,cclass, "pessimisticGet");
      return;
    }
    // Prepare the EvalCache, since we will be passing the msg through at least some
    // matchers.
    cache.prepareCache(subExpr.evalCacheSize());
    // Next, look in cache for reusable otherMatchers, to avoid searching
    // the full matchTree.
    if (e.otherMatchers != null)
    {
      // Have a cache hit that covers other matchers, so just run them.
      for (int i = 0; i < e.otherMatchers.length; i++)
      {
        try
        {
          e.otherMatchers[i].get(null, msg, cache, rootContext, result);
        }
        catch (RuntimeException exc)
        {
          // No FFDC Code Needed.
          // FFDC driven by wrapper class.
          FFDC.processException(this,
              cclass,
              "com.ibm.ws.sib.matchspace.impl.MatchSpaceImpl.pessimisticGet",
              exc,
              "1:677:1.44");      
//TODO:          tc.exception(tc, exc);
           
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            tc.exit(this,cclass, "pessimisticGet", exc);
          throw new MatchingException(exc);
        }
      }
      wildCacheHitGets++;
    }
    else
      // Have to do wildcards the slow way
      if (matchTree != null)
      {
        CacheingSearchResults csr = new CacheingSearchResults(result);
        try
        {
          matchTree.get(key, msg, cache, rootContext, csr);
        }
        catch (RuntimeException exc)
        {
          // No FFDC Code Needed.
          // FFDC driven by wrapper class.
          FFDC.processException(this,
              cclass,
              "com.ibm.ws.sib.matchspace.impl.MatchSpaceImpl.pessimisticGet",
              exc,
              "1:704:1.44");               
//TODO:          tc.exception(tc, exc);
            
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            tc.exit(this,cclass, "pessimisticGet", exc);
          throw new MatchingException(exc);
        }
        e.otherMatchers = csr.getMatchers();
        e.matchTreeGeneration = matchTreeGeneration;
        e.noResultCache |= csr.hasContent;
        wildCacheMissGets++;
      }
    // Now do exact match (if any)
    if (e.exactMatcher != null)
    {
      try
      {
        e.exactMatcher.get(null, msg, cache, rootContext, result);
      }
      catch (RuntimeException exc)
      {
        // No FFDC Code Needed.
        // FFDC driven by wrapper class.
        FFDC.processException(this,
            cclass,
            "com.ibm.ws.sib.matchspace.impl.MatchSpaceImpl.pessimisticGet",
            exc,
            "1:731:1.44");            
//TODO:        tc.exception(tc, exc);
          
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(this,cclass, "pessimisticGet", exc);
        throw new MatchingException(exc);
      }
      exactMatches++;
    }
    // If we are able, place something in the cache for next time
    if (!e.noResultCache)
    {
      e.cachedResults = result.provideCacheable(key);
      if (e.cachedResults != null)
        resultsCached++;
    }
    // And we are done
    pessimisticGets++;

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.exit(this,cclass, "pessimisticGet");
    return;
  }
537538
def evaluation_metrics(predicted, actual, bow=True):
    
    if bow:
        p = set(predicted)
        a = set(actual)

        true_positive = 0
        for token in p:
            if token in a:
                true_positive += 1
    else:
        # shove actual into a hash, count up the unique occurances of each token
        # iterate through predicted, check which occur in actual
        from collections import defaultdict
        act = defaultdict(lambda: 0)
        for token in actual:
            act[token] += 1

        true_positive = 0
        for token in predicted:
            if act[token] > 0:
                true_positive += 1
                act[token] -= 1

        # for shared logic below
        p = predicted
        a = actual

    try:
        precision = true_positive / len(p)
    except ZeroDivisionError:
        precision = 0.0
    try:
        recall = true_positive / len(a)
    except ZeroDivisionError:
        recall = 0.0
    try:
        f1 = 2.0 * (precision * recall) / (precision + recall)
    except ZeroDivisionError:
        f1 = 0.0

    # return (precision, recall, f1, dameraulevenshtein(predicted, actual))
    return (precision, recall, f1)
1109970
protected boolean evaluate(String value) {
        if (ValidationMatcherUtils.isValidationMatcherExpression(matchingValue)) {
            try {
                ValidationMatcherUtils.resolveValidationMatcher(selectKey, value, matchingValue, context);
                return true;
            } catch (ValidationException e) {
                return false;
            }
        } else {
            return value.equals(matchingValue);
        }
    }
532927
def match_percentage(self):
        
        return int(self._percentages_and_ratings_xpb.
                   div.with_class('matchgraph--match').
                   div.with_class('matchgraph-graph').
                   canvas.select_attribute_('data-pct').
                   one_(self.profile_tree))
960952
def score(self, i):
        """"""
        if self.minimize:
            return self.data[i][0]
        else:
            return self.data[(-1 * i) - 1][0]
1178730
public double score(List<L> guesses, List<L> trueLabels, Index<L> dataLabelIndex) {
    setLabelIndex(dataLabelIndex);
    return score(guesses, trueLabels);
  }
964199
def match(self, fsys_view):
        '''
        
        '''
        evalue_dict = fsys_view[1]
        for key, value in six.viewitems(self.criteria):
            if key in evalue_dict:
                if evalue_dict[key] != value:
                    return False
            else:
                return False
        return True
1313588
def score(self, testing_features, testing_labels):
        """"""
        # print("test features shape:",testing_features.shape)
        # print("testing labels shape:",testing_labels.shape)
        yhat = self.predict(testing_features)
        return self.scoring_function(testing_labels,yhat)
774450
function isMatching(result, expectation) {
  if (result.length !== expectation.length) {
    return false;
  }

  // convert results and expectations to strings for easier comparison
  result = result.map(item => item.toString());
  expectation = expectation.map(item => getBox(item).toString());

  const reduce_callback = function (previous_result, current_item) {
    return previous_result === true && result.indexOf(current_item) > -1;
  };

  return expectation.reduce(reduce_callback, true);
}
904330
private void processDestination(FastQueue<AssociatedIndex> matches, int numDestination,
									FastQueue<AssociatedIndex> output ) {
		//set up data structures
		scores.resize(numDestination);
		solutions.resize(numDestination);
		for( int i =0; i < numDestination; i++ ) {
			solutions.data[i] = -1;
		}

		// select best matches
		for( int i = 0; i < matches.size(); i++ ) {
			AssociatedIndex a = matches.get(i);
			int found = solutions.data[a.dst];
			if( found != -1 ) {
				if( found == -2 ) {
					// the best solution is invalid because two or more had the same score, see if this is better
					double bestScore = scores.data[a.dst];
					int result = type.compareTo(bestScore,a.fitScore);
					if( result < 0 ) {
						// found a better one, use this now
						solutions.data[a.dst] = i;
						scores.data[a.dst] = a.fitScore;
					}
				} else {
					// see if this new score is better than the current best
					AssociatedIndex currentBest = matches.get( found );
					int result = type.compareTo(currentBest.fitScore,a.fitScore);
					if( result < 0 ) {
						// found a better one, use this now
						solutions.data[a.dst] = i;
						scores.data[a.dst] = a.fitScore;
					} else if( result == 0 ) {
						// two solutions have the same score
						solutions.data[a.dst] = -2;
					}
				}
			} else {
				// no previous match found
				solutions.data[a.dst] = i;
				scores.data[a.dst] = i;
			}
		}

		output.reset();
		for( int i =0; i < numDestination; i++ ) {
			int index = solutions.data[i];
			if( index >= 0 ) {
				output.add( matches.get(index) );
			}
		}
	}