Compute r1, r2, rv regions as required by french porter stemmer algorithm
@param  {String} token Word to compute regions on
@return {Object}       Regions r1, r2, rv as offsets from the begining of the word
972912
function regions(token) {
  var r1, r2, rv, len;
  var i;

  r1 = r2 = rv = len = token.length;

  // R1 is the region after the first non-vowel following a vowel,
  for (var i = 0; i < len - 1 && r1 == len; i++) {
    if (isVowel(token[i]) && !isVowel(token[i + 1])) {
      r1 = i + 2;
    }
  }
  // Or is the null region at the end of the word if there is no such non-vowel.

  // R2 is the region after the first non-vowel following a vowel in R1
  for (i = r1; i < len - 1 && r2 == len; i++) {
    if (isVowel(token[i]) && !isVowel(token[i + 1])) {
      r2 = i + 2;
    }
  }
  // Or is the null region at the end of the word if there is no such non-vowel.

  // RV region
  var three = token.slice(0, 3);
  if (isVowel(token[0]) && isVowel(token[1])) {
    rv = 3;
  }
  if (three === 'par' || three == 'col' || three === 'tap')
    rv = 3;
  // the region after the first vowel not at the beginning of the word or null
  else {
    for (i = 1; i < len - 1 && rv == len; i++) {
      if (isVowel(token[i])) {
        rv = i + 1;
      }
    }
  }

  return {
    r1: r1,
    r2: r2,
    rv: rv
  };
}
934422
function step1c$1(token) {
                var r1 = getR1(token);

                if (!r1) {
                    return token;
                }

                if (r1.match(/(erte|ert)$/)) {
                    return token.replace(/(erte|ert)$/, 'er');
                }

                return token;
            }
44632
def edges(word: str, lang: str = "th"):
    

    obj = requests.get(f"http://api.conceptnet.io/c/{lang}/{word}").json()
    return obj["edges"]
332987
function step1b(token) {
    var r1 = getR1(token);

    if (!r1) {
        return token;
    }

    if (token.match(/(b|c|d|f|g|h|j|l|m|n|o|p|r|t|v|y|z)s$/)) {
        return token.slice(0, -1);
    }

    if (token.match(/([^aeiouyæåø]k)s$/)) {
        return token.slice(0, -1);
    }

    return token;
}
1192213
function endsinArr(token, suffixes) {
  var i, longest = '';
  for (i = 0; i < suffixes.length; i++) {
    if (endsin(token, suffixes[i]) && suffixes[i].length > longest.length)
      longest = suffixes[i];
  }

  return longest;
}
619735
def stem(self, word):
        
        word = word.lower()

        word = word.replace("\xDF", "ss")

        # Every occurrence of 'u' and 'y'
        # between vowels is put into upper case.
        for i in range(1, len(word)-1):
            if word[i-1] in self.__vowels and word[i+1] in self.__vowels:
                if word[i] == "u":
                    word = "".join((word[:i], "U", word[i+1:]))

                elif word[i] == "y":
                    word = "".join((word[:i], "Y", word[i+1:]))

        r1, r2 = self._r1r2_standard(word, self.__vowels)

        # R1 is adjusted so that the region before it
        # contains at least 3 letters.
        for i in range(1, len(word)):
            if word[i] not in self.__vowels and word[i-1] in self.__vowels:
                if len(word[:i+1]) < 3 and len(word[:i+1]) > 0:
                    r1 = word[3:]
                elif len(word[:i+1]) == 0:
                    return word
                break

        # STEP 1
        for suffix in self.__step1_suffixes:
            if r1.endswith(suffix):
                if (suffix in ("en", "es", "e") and
                    word[-len(suffix)-4:-len(suffix)] == "niss"):
                    word = word[:-len(suffix)-1]
                    r1 = r1[:-len(suffix)-1]
                    r2 = r2[:-len(suffix)-1]

                elif suffix == "s":
                    if word[-2] in self.__s_ending:
                        word = word[:-1]
                        r1 = r1[:-1]
                        r2 = r2[:-1]
                else:
                    word = word[:-len(suffix)]
                    r1 = r1[:-len(suffix)]
                    r2 = r2[:-len(suffix)]
                break

        # STEP 2
        for suffix in self.__step2_suffixes:
            if r1.endswith(suffix):
                if suffix == "st":
                    if word[-3] in self.__st_ending and len(word[:-3]) >= 3:
                        word = word[:-2]
                        r1 = r1[:-2]
                        r2 = r2[:-2]
                else:
                    word = word[:-len(suffix)]
                    r1 = r1[:-len(suffix)]
                    r2 = r2[:-len(suffix)]
                break

        # STEP 3: Derivational suffixes
        for suffix in self.__step3_suffixes:
            if r2.endswith(suffix):
                if suffix in ("end", "ung"):
                    if ("ig" in r2[-len(suffix)-2:-len(suffix)] and
                        "e" not in r2[-len(suffix)-3:-len(suffix)-2]):
                        word = word[:-len(suffix)-2]
                    else:
                        word = word[:-len(suffix)]

                elif (suffix in ("ig", "ik", "isch") and
                      "e" not in r2[-len(suffix)-1:-len(suffix)]):
                    word = word[:-len(suffix)]

                elif suffix in ("lich", "heit"):
                    if ("er" in r1[-len(suffix)-2:-len(suffix)] or
                        "en" in r1[-len(suffix)-2:-len(suffix)]):
                        word = word[:-len(suffix)-2]
                    else:
                        word = word[:-len(suffix)]

                elif suffix == "keit":
                    if "lich" in r2[-len(suffix)-4:-len(suffix)]:
                        word = word[:-len(suffix)-4]

                    elif "ig" in r2[-len(suffix)-2:-len(suffix)]:
                        word = word[:-len(suffix)-2]
                    else:
                        word = word[:-len(suffix)]
                break

        # Umlaut accents are removed and
        # 'u' and 'y' are put back into lower case.
        word = (word.replace("\xE4", "a").replace("\xF6", "o")
                    .replace("\xFC", "u").replace("U", "u")
                    .replace("Y", "y"))


        return word
1257924
function findWord(cm, lineNum, pos, dir, regexps) {
    var line = cm.getLine(lineNum);
    while (true) {
      var stop = (dir > 0) ? line.length : -1;
      var wordStart = stop, wordEnd = stop;
      // Find bounds of next word.
      for (; pos != stop; pos += dir) {
        for (var i = 0; i < regexps.length; ++i) {
          if (regexps[i].test(line.charAt(pos))) {
            wordStart = pos;
            // Advance to end of word.
            for (; pos != stop && regexps[i].test(line.charAt(pos)); pos += dir) {}
            wordEnd = (dir > 0) ? pos : pos + 1;
            return {
                from: Math.min(wordStart, wordEnd),
                to: Math.max(wordStart, wordEnd),
                line: lineNum};
          }
        }
      }
      // Advance to next/prev line.
      lineNum += dir;
      if (!isLine(cm, lineNum)) return null;
      line = cm.getLine(lineNum);
      pos = (dir > 0) ? 0 : line.length;
    }
  }
363660
function tokenize(str, wordRegexDelimiters, phraseRegexDelimiters) {
    if (wordRegexDelimiters === void 0) { wordRegexDelimiters = ' '; }
    if (phraseRegexDelimiters === void 0) { phraseRegexDelimiters = ''; }
    /* tslint:enable */
    var regexStr = '(?:[' + phraseRegexDelimiters + '])([^' + phraseRegexDelimiters + ']+)(?:[' + phraseRegexDelimiters + '])|([^' + wordRegexDelimiters + ']+)';
    var preTokenized = str.split(new RegExp(regexStr, 'g'));
    var result = [];
    var preTokenizedLength = preTokenized.length;
    var token;
    var replacePhraseDelimiters = new RegExp('[' + phraseRegexDelimiters + ']+', 'g');
    for (var i = 0; i < preTokenizedLength; i += 1) {
        token = preTokenized[i];
        if (token && token.length && token !== wordRegexDelimiters) {
            result.push(token.replace(replacePhraseDelimiters, ''));
        }
    }
    return result;
}
572480
function getR1(token) {
    var match = token.match(/[aeiouyæåø]{1}[^aeiouyæåø]([A-Za-z0-9_æøåÆØÅäÄöÖüÜ]+)/);

    if (match) {
        var preR1Length = match.index + 2;

        if (preR1Length < 3 && preR1Length > 0) {
            return token.slice(3);
        } else if (preR1Length >= 3) {
            return match[1];
        } else {
            return token;
        }
    }

    return null;
}
1368704
def compute_venn2_regions(centers, radii):
    '''
    
    '''
    A = VennCircleRegion(centers[0], radii[0])
    B = VennCircleRegion(centers[1], radii[1])
    Ab, AB = A.subtract_and_intersect_circle(B.center, B.radius)
    aB, _ = B.subtract_and_intersect_circle(A.center, A.radius)
    return (Ab, aB, AB)
327824
function getImportantWords(node) {
  var words = {}

  visit(node, 'WordNode', visitor)

  return words

  function visitor(word, index, parent) {
    var match
    var stem

    if (isImportant(word)) {
      stem = stemNode(word)
      match = {
        node: word,
        index: index,
        parent: parent
      }

      if (!own.call(words, stem)) {
        words[stem] = {
          matches: [match],
          stem: stem,
          score: 1
        }
      } else {
        words[stem].matches.push(match)
        words[stem].score++
      }
    }
  }
}
1001923
public static Boolean checkTokenBoundaries(MatchResult r, Sentence s, JCas jcas){
		Boolean beginOK = false;
		Boolean endOK = false;
	
		// whole expression is marked as a sentence
		if ((r.end() - r.start()) == (s.getEnd() -s.getBegin())){
			return true;
		}
		
		// Only check Token boundaries if no white-spaces in front of and behind the match-result
		if ((r.start() > 0) 
				&& ((s.getCoveredText().subSequence(r.start()-1, r.start()).equals(" ")))
				&& ((r.end() < s.getCoveredText().length()) && ((s.getCoveredText().subSequence(r.end(), r.end()+1).equals(" "))))) {
			return true;
		}
	
		// other token boundaries than white-spaces
		else {
			FSIterator iterToken = jcas.getAnnotationIndex(Token.type).subiterator(s);
			while (iterToken.hasNext()) {
				Token t = (Token) iterToken.next();
			
				// Check begin
				if ((r.start() + s.getBegin()) == t.getBegin()){
					beginOK = true;
				}
				// Tokenizer does not split number from some symbols (".", "/", "-", "–"),
				// e.g., "...12 August-24 Augsut..."
				else if ((r.start() > 0)
						&& ((s.getCoveredText().subSequence(r.start()-1, r.start()).equals("."))
						|| (s.getCoveredText().subSequence(r.start()-1, r.start()).equals("/")) 
						|| (s.getCoveredText().subSequence(r.start()-1, r.start()).equals("–"))
						|| (s.getCoveredText().subSequence(r.start()-1, r.start()).equals("-")))) {
					beginOK = true;
				}
			
				// Check end
				if ((r.end() + s.getBegin()) == t.getEnd()) {
					endOK = true;
				}
				// Tokenizer does not split number from some symbols (".", "/", "-", "–"),
				// e.g., "... in 1990. New Sentence ..."
				else if ((r.end() < s.getCoveredText().length()) 
						&& ((s.getCoveredText().subSequence(r.end(), r.end()+1).equals("."))
								|| (s.getCoveredText().subSequence(r.end(), r.end()+1).equals("/"))
								|| (s.getCoveredText().subSequence(r.end(), r.end()+1).equals("–")) 
								|| (s.getCoveredText().subSequence(r.end(), r.end()+1).equals("-")))) {
					endOK = true;
				}
			
				if (beginOK && endOK)
					return true;
			}
		}
		return false;
	}
292804
function slice(toToken) {
    if (has(toToken) && !isLast(toToken)) {
        _tokens = _tokens.slice(0, _tokens.lastIndexOf(toToken) + 1);
    }
}
1005475
def find_optimal_allocation(self, tokens):
        
        token_ranges = self.find_tracked_words(tokens)
        token_ranges.sort()

        for offset in range(1, len(token_ranges)):
            to_be_removed = []
            for candidate in token_ranges[offset:]:
                for i in range(offset):
                    if token_ranges[i].overlaps_with(candidate):
                        to_be_removed.append(candidate)
                        break

            token_ranges = [token for token in token_ranges if token not in to_be_removed]

        token_ranges.sort(key=lambda token: token.get_start_index())
        return token_ranges
989352
function(source) {
			// transform tokens
			var tokens = this.lex(source), pos = 0, token;
			for (var i = 0, il = tokens.length; i < il; i++) {
				token = tokens[i];
				token.start = pos;
				token.end = (pos += token.value.length);
			}
			return tokens;
		}
188240
function get(start, end) {
			var result = [],
				i;

			for (i = Math.max(0, start); i < end && i < length; i++) {
				result.push(tokens[i]);
			}

			return result;
		}
395882
function step2(token) {
    var r1 = getR1(token);

    if (!r1) {
        return token;
    }

    if (r1.match(/(d|v)t$/)) {
        return token.slice(0, -1);
    }

    return token;
}