Helper method to calculate entropy from a list of matches.

@param matches the list of matches
@return the sum of the entropy in the list passed in
500359
private double calcEntropy(final List<Match> matches, final boolean include_brute_force)
    {
        double entropy = 0;
        for (Match match : matches)
        {
            if (include_brute_force || !(match instanceof BruteForceMatch))
            {
                entropy += match.calculateEntropy();
            }
        }
        return entropy;
    }
306646
private void matchX509CRLs(CRLSelector selector, Collection<CRL> matches) {
        for (Object obj : crlIssuers.values()) {
            if (obj instanceof X509CRL) {
                X509CRL crl = (X509CRL)obj;
                if (selector.match(crl)) {
                    matches.add(crl);
                }
            } else {
                // See crlIssuers javadoc.
                @SuppressWarnings("unchecked")
                List<X509CRL> list = (List<X509CRL>)obj;
                for (X509CRL crl : list) {
                    if (selector.match(crl)) {
                        matches.add(crl);
                    }
                }
            }
        }
    }
711547
@Override
	public boolean satisfies(Match match, int... ind)
	{
		return match.get(ind[selfIndex]) == match.get(ind[ind.length-1]) ||
			super.satisfies(match, ind);
	}
864681
public static Matcher<MultiResult> sequence(final Matcher<?>... matchers) {
        checkNotEmpty(matchers);
        return new Matcher<MultiResult>() {
            @Override
            public MultiResult matches(String input, boolean isEof) {
                int matchCount = 0;
                Result[] results = new Result[matchers.length];
                Arrays.fill(results, failure(input, false));
                int beginIndex = 0;
                for (int i = 0; i < matchers.length; i++) {
                    Result result = matchers[i].matches(input.substring(beginIndex), isEof);
                    if (result.isSuccessful()) {
                        beginIndex += result.end();
                        results[i] = result;
                        if (++matchCount == matchers.length) {
                            String group = result.group();
                            Result finalResult = new SimpleResult(
                                    true,
                                    input,
                                    input.substring(0, beginIndex - group.length()),
                                    group,
                                    result.canStopMatching());
                            return new MultiResultImpl(finalResult, Arrays.asList(results));
                        }
                    } else {
                        break;
                    }
                }
                final List<Result> resultList = Arrays.asList(results);
                boolean canStopMatching = MultiResultImpl.canStopMatching(resultList);
                return new MultiResultImpl(failure(input, canStopMatching), resultList);
            }

            @Override
            public String toString() {
                return String.format("sequence(%s)", MultiMatcher.matchersToString(matchers));
            }
        };
    }
316683
function matches(str, match) {
    if (Array.isArray(match)) return match.indexOf(str) > -1;
    return match.test(str);
}
137744
public Matrix applyEntropyTransformations(Matrix mat) {
        int n = mat.columns();
        int m = mat.rows();
        for (int col_num = 0; col_num < n; col_num++) {
            double col_total = 0.0;
            for (int row_num = 0; row_num < m; row_num++) {
                col_total += mat.get(row_num,col_num);
            }
            //System.err.println("coltotal: " + col_total);
            if (col_total == 0.0) 
                continue;

            double entropy = 0.0;
            for (int row_num = 0; row_num < m; row_num++) {
                double p = mat.get(row_num,col_num)/col_total;
                //System.err.print(p + " ");
                if (p==0.0)
                    continue;
                entropy += p * Math.log10(p);
            }
            //System.err.println("entropy: " + entropy);
            entropy *= -1;
            double w = 1 - entropy/Math.log10(m);
            //System.err.println("w: " + w);
            for (int row_num = 0; row_num < m; row_num++) {
                mat.set(row_num, col_num, w*Math.log10(mat.get(row_num, col_num) + 1.0));
            }
        }
        return mat;
    }
1161116
private void findMatches(Match match, int n) throws IOException {
    if (n > 0) {
      int largestMatchingEndPosition = match.endPosition();
      Set<Integer> list = ignoreItem.getFullEndPositionList(spans.docID(),
          match.endPosition());
      // try to find matches with existing queue
      if (!queueSpans.isEmpty()) {
        Match span;
        for (int i = 0; i < queueSpans.size(); i++) {
          span = queueSpans.get(i);
          if (match.endPosition() == span.startPosition()
              || (list != null && list.contains(span.startPosition()))) {
            findMatches(new Match(match.startPosition(), span.endPosition()),
                (n - 1));
            largestMatchingEndPosition = Math.max(largestMatchingEndPosition,
                span.endPosition());
          }
        }
      }
      // extend queue if necessary and possible
      while (!lastSpan && (largestMatchingEndPosition >= lastStartPosition)) {
        if (spans.nextStartPosition() == NO_MORE_POSITIONS) {
          lastSpan = true;
        } else {
          Match span = new Match(spans.startPosition(), spans.endPosition());
          queueSpans.add(span);
          lastStartPosition = spans.startPosition();
          // check if this provides new match
          if (match.endPosition() == span.startPosition()
              || (list != null && list.contains(span.startPosition()))) {
            findMatches(new Match(match.startPosition(), span.endPosition()),
                (n - 1));
            largestMatchingEndPosition = Math.max(largestMatchingEndPosition,
                span.endPosition());
          }
        }
      }
    } else {
      // only unique spans
      if (!queueMatches.contains(match)) {
        queueMatches.add(match);
      }
    }
  }
738046
@Override
	public boolean satisfies(Match match, int... ind)
	{
		assert ind.length == 1;

		return clazz.isAssignableFrom(match.get(ind[0]).getModelInterface());
	}
859302
private function calculateSubKeys(array $matches = [], $amount, $times = 2)
    {
        if (empty($matches)) {
            return;
        }

        $j = $times;

        for ($i = 0; $i < $amount; $i++) {
            $var[] = "[\"{$matches[$j]}\"]";

            $j += $times;
        }

        return "\${$matches[1]}" . join(null, $var);
    }
965919
public void setXssMatchSets(java.util.Collection<XssMatchSetSummary> xssMatchSets) {
        if (xssMatchSets == null) {
            this.xssMatchSets = null;
            return;
        }

        this.xssMatchSets = new java.util.ArrayList<XssMatchSetSummary>(xssMatchSets);
    }
1160620
public Map<String, List<V>> materializeMatch(Map<String, List<EventId>> match) {
		Map<String, List<V>> materializedMatch = new LinkedHashMap<>(match.size());

		for (Map.Entry<String, List<EventId>> pattern : match.entrySet()) {
			List<V> events = new ArrayList<>(pattern.getValue().size());
			for (EventId eventId : pattern.getValue()) {
				try {
					V event = sharedBuffer.getEvent(eventId).getElement();
					events.add(event);
				} catch (Exception ex) {
					throw new WrappingRuntimeException(ex);
				}
			}
			materializedMatch.put(pattern.getKey(), events);
		}

		return materializedMatch;
	}
702393
public List<Match> matches(List<String> desired) {
    return matchesImpl(parse(desired), DEFAULT_THRESHOLD);
  }
865628
public boolean matches(Evidence evidence) {
        return sourceMatches(evidence)
                && confidenceMatches(evidence)
                && name.equalsIgnoreCase(evidence.getName())
                && valueMatches(evidence);
    }
192980
public double entropy(final String source) {
    double output = 0;
    for (int i = 1; i < source.length(); i++) {
      TrieNode node = this.inner.matchEnd(source.substring(0, i));
      Optional<? extends TrieNode> child = node.getChild(source.charAt(i));
      while (!child.isPresent()) {
        output += Math.log(1.0 / node.getCursorCount());
        node = node.godparent();
        child = node.getChild(source.charAt(i));
      }
      output += Math.log(child.get().getCursorCount() * 1.0 / node.getCursorCount());
    }
    return -output / Math.log(2);
  }
277258
public static int getMatchNo(String[] strings, String s) {
        for (int i = 0; i < strings.length; i++) {
            if (s.equals(strings[i])) {
                return i;
            }
        }
        return -1;
    }
1270400
def _build_matches(matches, uuids, no_filtered, fastmode=False):
    """"""

    result = []

    for m in matches:
        mk = m[0].uuid if not fastmode else m[0]
        subset = [uuids[mk]]

        for id_ in m[1:]:
            uk = id_.uuid if not fastmode else id_
            u = uuids[uk]

            if u not in subset:
                subset.append(u)

        result.append(subset)

    result += no_filtered
    result.sort(key=len, reverse=True)

    sresult = []
    for r in result:
        r.sort(key=lambda id_: id_.uuid)
        sresult.append(r)

    return sresult
78336
@Override
	public boolean satisfies(Match match, int... ind)
	{
		int x = -1;
		for (MappedConst mc : con)
		{
			if (mc.satisfies(match, ind)) x *= -1;
		}
		return x == 1;
	}