<p>
gatherVariables.
</p>

@param tokens a {@link java.util.Collection} object.
@return a {@link java.util.Set} object.
774128
static public Set<String> gatherVariables(final List<EquPart> tokens)
    {
        final Set<String> vars = new HashSet<>();
        for (final EquPart token : tokens)
            if (token instanceof TokVariable)
                vars.add(((TokVariable) token).getValue().toString());
        return vars;
    }
518262
@Override
  public List<VariableMatch> matchVariables(VariableNumMap inputVariables) {
    // All of the fixed variables must be matched in order to return anything.
    if (!inputVariables.containsAll(fixedVariables)) {
      return Collections.emptyList();
    }
    // Special case: if there aren't any templates, then only the fixed
    // variables should be returned.
    if (plateStarts.length == 0) {
      return Arrays.asList(VariableMatch.identity(fixedVariables));
    }

    int maxPlateReplication = -1;
    int[] inputVarNums = inputVariables.getVariableNumsArray();
    int numVars = inputVarNums.length;
    int numMatchers = plateStarts.length;
    for (int i = 0; i < numMatchers; i++) {
      for (int j = 0; j < numVars; j++) {
        if (inputVarNums[j] >= plateStarts[i] && inputVarNums[j] < plateEnds[i]) {
          int withinPlateIndex = inputVarNums[j] - plateStarts[i];
          int plateReplicationNum = withinPlateIndex / plateReplicationSizes[i];
          int replicationIndex = plateReplicationNum - plateMatchIndexOffsets[i];
          maxPlateReplication = Math.max(replicationIndex, maxPlateReplication);
        }
      }
    }

    // Aggregate pattern matches for each variable.
    int[] templateVarNums = templateVariables.getVariableNumsArray();
    int[][] variableMatches = new int[maxPlateReplication + 1][];
    for (int i = 0; i < numMatchers; i++) {      
      for (int j = 0; j < numVars; j++) {
        if (inputVarNums[j] >= plateStarts[i] && inputVarNums[j] < plateEnds[i]) {
          // The variable is within the plate we're matching.
          int withinPlateIndex = inputVarNums[j] - plateStarts[i];
          int plateReplicationNum = withinPlateIndex / plateReplicationSizes[i];
          int varOffset = withinPlateIndex % plateReplicationSizes[i];
          if (varOffset == plateVarOffsets[i]) {
            // The variable matches the pattern.
            int replicationIndex = plateReplicationNum - plateMatchIndexOffsets[i];
            if (variableMatches[replicationIndex] == null) {
              variableMatches[replicationIndex] = new int[templateVarNums.length];
              Arrays.fill(variableMatches[replicationIndex], -1);
            }
            variableMatches[replicationIndex][i] = inputVarNums[j];
          }
        }
      }
    }

    // Eliminate any partial matches which do not contain a match for every
    // variable prefix.
    List<VariableMatch> validMatches = Lists.newArrayList();
    int numMatches = variableMatches.length;
    for (int i = 0; i < numMatches; i++) {
      int[] matchBuilder = variableMatches[i];
      if (matchBuilder != null && Ints.indexOf(matchBuilder, -1) == -1) {
        VariableNumMap matchedVariables = inputVariables.intersection(matchBuilder);
        VariableRelabeling fixedVariableRelabeling = VariableRelabeling.identity(fixedVariables);

        int[] templateCopy = Arrays.copyOf(templateVarNums, templateVarNums.length);

        IntBiMap mapping = IntBiMap.fromUnsortedKeyValues(matchBuilder, templateCopy);
        VariableRelabeling matchedRelabeling = new VariableRelabeling(matchedVariables,
            templateVariables, mapping);
        VariableMatch match = new VariableMatch(matchedVariables.union(fixedVariables),
          templateVariables.union(fixedVariables), fixedVariableRelabeling.union(matchedRelabeling));

        validMatches.add(match);
      }
    }
    return validMatches;
  }
1167657
public final List<SequenceLabel> getSequencesFromSpans(final String[] tokens,
      final Span[] seqSpans) {
    final List<SequenceLabel> sequences = new ArrayList<SequenceLabel>();
    for (final Span seqSpan : seqSpans) {
      final String seqString = seqSpan.getCoveredText(tokens);
      final String seqType = seqSpan.getType();
      final SequenceLabel sequence = this.sequenceFactory
          .createSequence(seqString, seqType, seqSpan);
      sequences.add(sequence);
    }
    return sequences;
  }
1356453
public static List<Token> getPrecedingTokens(JCas jCas, Token token)
    {
        List<Token> result = new ArrayList<Token>();

        for (Token t : JCasUtil.select(getInitialView(jCas), Token.class)) {
            if (t.getBegin() < token.getBegin()) {
                result.add(t);
            }
        }

        return result;
    }
418240
Map<String,Long> getContext(String... tokens) throws IOException {
    Objects.requireNonNull(tokens);
    TermsEnum iterator = getIterator();
    Map<String,Long> result = new HashMap<>();
    BytesRef byteRef;
    int i = 0;
    while ((byteRef = iterator.next()) != null) {
      String term = new String(byteRef.bytes, byteRef.offset, byteRef.length);
      for (String token : tokens) {
        if (term.contains(" " + token + " ")) {
          String[] split = term.split(" ");
          if (split.length == 3) {
            long count = getCount(Arrays.asList(split[0], split[1], split[2]));
            result.put(term, count);
          }
        }
      }
      /*if (i++ > 1_000_000) { // comment in for faster testing with subsets of the data
        break;
      }*/
    }
    return result;
  }
359816
public void setSyntaxTokens(java.util.Collection<SyntaxToken> syntaxTokens) {
        if (syntaxTokens == null) {
            this.syntaxTokens = null;
            return;
        }

        this.syntaxTokens = new java.util.ArrayList<SyntaxToken>(syntaxTokens);
    }
366331
public Set<AuthorisationData> convertIdentifyingTokenList(Set<IdentifyingToken> tokens) {
        Set<AuthorisationData> resultList = new HashSet<>();

        for (IdentifyingToken token : tokens) {
            resultList.add(convertIdentifyingToken(token));
        }

        return resultList;
    }
600276
public Set tokens() {
        if (tokenSet == null) {
            tokenSet = new AbstractSetView() {

                public long size() throws ObjectManagerException {
                    return directory.size();
                } // size().

                public Iterator iterator() throws ObjectManagerException {

                    final Iterator storeAreaIterator = directory.entrySet().iterator();
                    return new Iterator() {

                        public boolean hasNext() throws ObjectManagerException
                        {
                            return storeAreaIterator.hasNext();
                        } // hasNext().

                        public Object next() throws ObjectManagerException
                        {
                            Directory.StoreArea storeArea = (Directory.StoreArea) storeAreaIterator.next();
                            Token token = new Token(AbstractSingleFileObjectStore.this, storeArea.identifier);
                            return like(token);
                        } // next().   

                        public boolean hasNext(Transaction transaction)
                                        throws ObjectManagerException
                        {
                            throw new UnsupportedOperationException();
                        } // hasNext().

                        public Object next(Transaction transaction)
                                        throws ObjectManagerException
                        {
                            throw new UnsupportedOperationException();
                        } // next().

                        public Object remove(Transaction transaction)
                                        throws ObjectManagerException
                        {
                            throw new UnsupportedOperationException();
                        } // remove().
                    }; // new Iterator().
                } // iterator().  

            }; // new AbstractSetView().
        } // if (tokenSet == null). 
        return tokenSet;
    }
554000
public RandomVariable[] getValues(double[] times) {
		RandomVariable[] values = new RandomVariable[times.length];

		for(int i=0; i<times.length; i++) {
			values[i] = getValue(null, times[i]);
		}

		return values;
	}
1010459
public Parser<Token> token(String... tokenNames) {
    if (tokenNames.length == 0) return Parsers.never();
    @SuppressWarnings("unchecked")
    Parser<Token>[] ps = new Parser[tokenNames.length];
    for(int i = 0; i < tokenNames.length; i++) {
      ps[i] = Parsers.token(InternalFunctors.tokenWithSameValue(word(tokenNames[i])));
    }
    return Parsers.or(ps);
  }
660594
private static List<Token> createTokens(final Map<String, String> properties) {
		List<Token> tokens = new ArrayList<Token>();
		for (Entry<String, String> entry : properties.entrySet()) {
			if (entry.getKey().toLowerCase(Locale.ROOT).startsWith(FIELD_PREFIX)) {
				tokens.add(FormatPatternParser.parse(entry.getValue()));
			}
		}
		return tokens;
	}
542686
public static List<Variable> getRunTimeVariables(
      final Collection<Variable> variables) {
    final List<Variable> runtimeVariables =
        ReportalUtil.getVariablesByRegex(variables,
            Reportal.REPORTAL_CONFIG_PREFIX_NEGATION_REGEX);

    return runtimeVariables;
  }
579169
def get_tokens(tokens):
    
    tokens = tokens[1:-1]
    ret = []
    start = 0
    stack = 0
    for i in range(len(tokens)):
        if tokens[i] == '(':
            if stack == 0:
                start = i
            stack += 1
        elif tokens[i] == ')':
            stack -= 1
            if stack < 0:
                raise Exception('Bracket mismatch: ' + str(tokens))
            if stack == 0:
                ret.append(get_tokens(tokens[start:i + 1]))
        else:
            if stack == 0:
                ret.append(tokens[i])
    if stack != 0:
        raise Exception('Bracket mismatch: ' + str(tokens))
    return ret
774282
public TemplateVariables concat(Collection<TemplateVariable> variables) {

		List<TemplateVariable> result = new ArrayList<>(this.variables.size() + variables.size());
		result.addAll(this.variables);

		List<TemplateVariable> filtered = variables.stream() //
				.filter(variable -> !containsEquivalentFor(variable)).collect(Collectors.toList());

		result.addAll(filtered);

		return new TemplateVariables(result);
	}
563644
public Set<Integer> getSharedVariables(int factor1, int factor2) {
    Set<Integer> varNums = new HashSet<Integer>(factorVariableMap.get(factor1));
    varNums.retainAll(factorVariableMap.get(factor2));
    return varNums;
  }
230448
public Map<String, Object> validateTokenAndGetClaims(final String token) {
        final CommonProfile profile = validateToken(token);

        final Map<String, Object> claims = new HashMap<>(profile.getAttributes());
        claims.put(JwtClaims.SUBJECT, profile.getId());

        return claims;
    }
222740
public static Variable[] getVariables(NameSpace ns, String[] names) {
        if (null == ns || null == names)
            return new Variable[0];
        return Stream.of(names).map(name->getVariable(ns, name))
            .filter(Objects::nonNull).toArray(Variable[]::new);
    }