Looks for a statement in the operation's list that matches the specified
        end token. Returns the index of the statement in the operation that matches.
558382
def _find_end_token(self, end_token, operation):
        
        ibuffer, icache = operation.state
        length = operation.buffered[ibuffer][2]
        result = None

        for i in range(len(operation.buffered) - ibuffer - 1):
            linenum, statement, charlength = operation.buffered[i + ibuffer + 1]
            length += charlength
            
            if end_token in statement.lower():
                #We already have the absolute char index for the start of the
                #instance; we just need to update the end.
                result = (i + ibuffer + 1, length)
                break        

        #If we didn't find a terminating statement, the full length of the operation
        #is a good estimate for the extent of the instance.
        if result is None:
            result = (None, length)

        return result
22396
private void getLastToken(StreamTokenizer tokenizer, boolean endOfFileOk) throws IOException, ParseException {
        if ((tokenizer.nextToken() != StreamTokenizer.TT_EOL) && ((tokenizer.ttype != StreamTokenizer.TT_EOF) || !endOfFileOk)) {
            throw new ParseException("end of line expected", tokenizer.lineno());
        }
    }
805211
protected static String getRemainingPath(List<String> tokens, int i, int end) {
        if (tokens == null) {
            throw MESSAGES.nullArgument("tokens");
        }
        if (i < 0 || i >= end) { throw new IllegalArgumentException("i is not in the range of tokens: 0-" + (end - 1)); }
        if (i == end - 1) { return tokens.get(end - 1); }
        StringBuilder buffer = new StringBuilder();
        for (; i < end - 1; ++i) {
            buffer.append(tokens.get(i));
            buffer.append("/");
        }
        buffer.append(tokens.get(end - 1));
        return buffer.toString();
    }
1050147
public String getPosFromMatchResult(int tokBegin, int tokEnd, Sentence s, JCas jcas) {
		// get all tokens in sentence
		HashMap<Integer, Token> hmTokens = new HashMap<Integer, Token>();
		FSIterator iterTok = jcas.getAnnotationIndex(Token.type).subiterator(s);
		while (iterTok.hasNext()) {
			Token token = (Token) iterTok.next();
			hmTokens.put(token.getBegin(), token);
		}
		// get correct token
		String pos = "";
		if (hmTokens.containsKey(tokBegin)) {
			Token tokenToCheck = hmTokens.get(tokBegin);
			pos = tokenToCheck.getPos();
		}
		return pos;
	}
840850
public long indexOf(Token token,
                        Transaction transaction)
                    throws ObjectManagerException
    {
        long index = 0;
        try {
            for (Iterator iterator = iterator(); index < Long.MAX_VALUE; index++) {
                if (iterator.next(transaction) == token) {
                    break;
                }
            }
        } catch (java.util.NoSuchElementException exception) {
            // No FFDC code needed.
            index = -1;
        } // try.
        return index;
    }
1140589
def ending(self, end, predicate=None, index=None):
        
        return filter_index(_BaseMatches._base(self._end_dict[end]), predicate, index)
1205314
def _get_end_index(self):
        """"""
        return max(self.index + self.source_window,
                   self._get_target_index() + self.target_window)
115062
def _get_start_end(parts, index=7):
    
    start = parts[1]
    end = [x.split("=")[-1] for x in parts[index].split(";") if x.startswith("END=")]
    if end:
        end = end[0]
        return start, end
    return None, None
789813
private int endCheckBlock()
    {
        Node n;
        int rv = END_DROPS_OFF;

        // check each statment and if the statement can continue onto the next
        // one, then check the next statement
        for (n=first; ((rv & END_DROPS_OFF) != 0) && n != null; n = n.next)
        {
            rv &= ~END_DROPS_OFF;
            rv |= n.endCheck();
        }
        return rv;
    }
538148
def indexMatch(L, func):
    ''
    for i, x in enumerate(L):
        if func(x):
            return i
144853
public static IndexOperator getIndexOperator(String operator)
    {
        if (operator.equals("="))
        {
            return IndexOperator.EQ;
        }
        else if (operator.equals(">="))
        {
            return IndexOperator.GTE;
        }
        else if (operator.equals(">"))
        {
            return IndexOperator.GT;
        }
        else if (operator.equals("<"))
        {
            return IndexOperator.LT;
        }
        else if (operator.equals("<="))
        {
            return IndexOperator.LTE;
        }

        return null;
    }
611828
public static int findWordEnd(String line, int pos, String noWordSep) {
        return findWordEnd(line, pos, noWordSep, true);
    }
609804
def _fetch(self, statement, commit, max_attempts=5):
        
        if self._auto_reconnect:
            attempts = 0
            while attempts < max_attempts:
                try:
                    # Execute statement
                    self._cursor.execute(statement)
                    fetch = self._cursor.fetchall()
                    rows = self._fetch_rows(fetch)
                    if commit:
                        self._commit()

                    # Return a single item if the list only has one item
                    return rows[0] if len(rows) == 1 else rows
                except Exception as e:
                    if attempts >= max_attempts:
                        raise e
                    else:
                        attempts += 1
                        self.reconnect()
                        continue
        else:
            # Execute statement
            self._cursor.execute(statement)
            fetch = self._cursor.fetchall()
            rows = self._fetch_rows(fetch)
            if commit:
                self._commit()

            # Return a single item if the list only has one item
            return rows[0] if len(rows) == 1 else rows
1252262
public static String parseExplainViewCall(String statement)
    {
        Matcher matcher = ExplainViewCallPreamble.matcher(statement);
        if ( ! matcher.lookingAt()) {
            return null;
        }
        // This all could probably be done more elegantly via a group extracted
        // from a more comprehensive regexp.
        // Clean up any extra spaces around the remainder of the line,
        // which should be a view name.
        return statement.substring(matcher.end()).trim();
    }
638458
def find_next_matching_line(self, match_func, count=1):
        
        result = None

        for index, line in enumerate(self.lines[self.cursor_position_row + 1:]):
            if match_func(line):
                result = 1 + index
                count -= 1

            if count == 0:
                break

        return result
466613
def find_rep_end(self, text):
        ''''''
        return self.find_end(text, self.start_rep_token, self.end_rep_token, ignore_end_token=self.end_var_token)
811530
public int lookup(double minScore,String toFind)
    {
        if (!frozen) freeze();
        long start = System.currentTimeMillis();

        final Map upperBoundOnWeight = new HashMap();
        // find all tokens that could be potentially useful for
        // retrieving similar strings
        tfidfDistance.prepare( toFind );
        Token[] tokens = tfidfDistance.getTokens();
        List usefulTokens = new ArrayList(tokens.length);
        for (int i=0; i<tokens.length; i++) {
            Token tok = tokens[i];
            if (DEBUG) System.out.println("upper-bounding token "+i+"="+tok);
            // getIndex()<maxTFIDFScore then tok is somewhere in the dictionary
            if (tok.getIndex() < maxTFIDFScore.length) { 
                // token should be in allTokens and similar tokens should be pre-computed
                storeUpperBound( tok, tok, usefulTokens, upperBoundOnWeight, 1.0 );
                for (int j=0; j<similarTokens[tok.getIndex()].length; j++) {
                    Token simTok = similarTokens[tok.getIndex()][j];
                    double sim = jaroWinklerDistance.score(tok.getValue(), simTok.getValue());
                    storeUpperBound( tok, simTok, usefulTokens, upperBoundOnWeight, sim );
                }
            } else {
                // token should NOT be in allTokens, so we need to computed similarTokens on-the-fly
                int indexInAllTokens = Arrays.binarySearch( allTokens, tok, LEXICAL_ORDER_FOR_TOKENS );
                if (indexInAllTokens<0) indexInAllTokens = -(indexInAllTokens+1);
                Set likeTokI = findSimilarTokens( tok.getValue(), indexInAllTokens );   
                if (DEBUG) System.out.println("just found "+likeTokI.size()+" tokens similar to the novel token "+tok);
                for (Iterator j=likeTokI.iterator(); j.hasNext(); ) {
                    Token simTok = (Token)j.next();
                    double sim = jaroWinklerDistance.score(tok.getValue(), simTok.getValue());
                    storeUpperBound( tok, simTok, usefulTokens, upperBoundOnWeight, sim );
                }
            }
        }
        if (DEBUG) System.out.println("tokens and upper bounds: "+upperBoundOnWeight);

        // collect all candidates, but skip the lowest-scoring
        // "usefulTokens" - scores that add up to 1-minScore
        Set candidates = new HashSet();
        Collections.sort(usefulTokens, new Comparator() {
                public int compare(Object a,Object b) {
                    Double da = (Double)upperBoundOnWeight.get(a);
                    Double db = (Double)upperBoundOnWeight.get(b);
                    //if (da==null) da = new Double(0); if (db==null) db = new Double(0);
                    double diff = da.doubleValue()-db.doubleValue();
                    return diff>0 ? +1 : (diff<0? -1 : 0);
                }
            });
        double totScore = 0;
        for (Iterator i=usefulTokens.iterator(); i.hasNext(); ) {
            Token tok = (Token)i.next();
            Double ub = (Double)upperBoundOnWeight.get(tok); 
            if (ub!=null) totScore += ub.doubleValue();
            if (totScore >= minScore) {
                Set ii = invertedIndex[tok.getIndex()];
                if (maxInvertedIndexSize<=0 || ii.size()<maxInvertedIndexSize) {
                    candidates.addAll( ii  );
                }
            } else {
                if (DEBUG) System.out.println("skip tok "+tok+" upper bound "+ub+" totScore = "+totScore);
            }
            if (DEBUG) System.out.println("after "+tok+" with upper bound "+ub+": "+candidates.size()+" candidates");
        }
        
        // finally collect and score the candidates        
        result = new ArrayList( candidates.size() );
        StringWrapper wa = softTFIDFDistance.prepare( toFind );
        for (Iterator i=candidates.iterator(); i.hasNext(); ) {
            String found = (String)i.next();
            StringWrapper wb = softTFIDFDistance.prepare( found );
            double d = softTFIDFDistance.score( wa, wb );
            //if (DEBUG) System.out.println("candidate "+found+" score "+d+" minscore "+minScore);
            if (d>=minScore) {
                Set valset = (Set)valueMap.get(found);
                for (Iterator j=valset.iterator(); j.hasNext(); ) {
                    String valj=(String)j.next();
                    result.add(new LookupResult(found,valj,d));
                }
            }
        }
        if (DEBUG) System.out.println("result="+result);
        Collections.sort( result );
        lookupTime = (System.currentTimeMillis()-start) / 1000.0;        
        return result.size();
    }