Find stems for a given text.
358868
def parse(self, output):
        
        output = self._get_lines_with_stems(output)
        words = self._make_unique(output)
        return self._parse_for_simple_stems(words)
817799
@Override
	public String stem(String token) {
		if (token != null && token.length() > 3 && token.endsWith("s")) {
			return token.substring(0, token.length() - 1);
		}
		return token;
	}
575034
def get_edu_text(text_subtree):
    """"""
    assert text_subtree.label() == SubtreeType.text
    return u' '.join(word.decode('utf-8') for word in text_subtree.leaves())
1304116
def find_input_documents(self):
        
        paths = []
        itr = chain(texutils.input_pattern.finditer(self.text),
                    texutils.input_ifexists_pattern.finditer(self.text))
        for match in itr:
            fname = match.group(1)
            if not fname.endswith('.tex'):
                full_fname = ".".join((fname, 'tex'))
            else:
                full_fname = fname
            paths.append(full_fname)
        return paths
1112623
def find_args(self, text, start=None):
        """"""
        if start is None:
            start = 0
        first_occurance = text.find(self.__begin, start)
        if first_occurance == -1:
            return self.NOT_FOUND
        previous_found, found = first_occurance + 1, 0
        while True:
            found = self.__find_args_separator(text, previous_found)
            if found == -1:
                return self.NOT_FOUND
            elif text[found] == self.__end:
                return first_occurance, found
            else:
                previous_found = found + 1
917337
public static String stem(String s) {
    String stem = s;

     // Handle irregular ones
     String irreg=irregular.get(s);
     if(irreg!=null) return(stem=irreg);

     // -on to -a
     if(categoryON_A.contains(s)) return(stem=cut(s,"a")+"on");

     // -um to -a
     if(categoryUM_A.contains(s)) return(stem=cut(s,"a")+"um");

     // -x to -ices
     if(categoryIX_ICES.contains(s)) return(stem=cut(s,"ices")+"ix");

     // -o to -i
     if(categoryO_I.contains(s)) return(stem=cut(s,"i")+"o");

     // -se to ses
     if(categorySE_SES.contains(s)) return(stem=cut(s,"s"));

     // -is to -es
     if(categoryIS_ES.contains(s) || s.endsWith("theses")) return(stem=cut(s,"es")+"is");

     // -us to -i
     if(categoryUS_I.contains(s)) return(stem=cut(s,"i")+"us");
     //Wrong plural
     if(s.endsWith("uses") && (categoryUS_I.contains(cut(s,"uses")+"i") ||
                               s.equals("genuses") || s.equals("corpuses"))) return(stem=cut(s,"es"));

     // -ex to -ices
     if(categoryEX_ICES.contains(s)) return(stem=cut(s,"ices")+"ex");

     // Words that do not inflect in the plural
     if(s.endsWith("ois") || s.endsWith("itis") || category00.contains(s) || categoryICS.contains(s)) return(stem=s);

     // -en to -ina
     // No other common words end in -ina
     if(s.endsWith("ina")) return(stem=cut(s,"en"));

     // -a to -ae
     // No other common words end in -ae
     if(s.endsWith("ae")) return(stem=cut(s,"e"));

     // -a to -ata
     // No other common words end in -ata
     if(s.endsWith("ata")) return(stem=cut(s,"ta"));

     // trix to -trices
     // No common word ends with -trice(s)
     if(s.endsWith("trices")) return(stem=cut(s,"trices")+"trix");

     // -us to -us
     //No other common word ends in -us, except for false plurals of French words
     //Catch words that are not latin or known to end in -u
     if(s.endsWith("us") && !s.endsWith("eaus") && !s.endsWith("ieus") && !noLatin(s)
        && !categoryU_US.contains(s)) return(stem=s);

     // -tooth to -teeth
     // -goose to -geese
     // -foot to -feet
     // -zoon to -zoa
     //No other common words end with the indicated suffixes
     if(s.endsWith("teeth")) return(stem=cut(s,"teeth")+"tooth");
     if(s.endsWith("geese")) return(stem=cut(s,"geese")+"goose");
     if(s.endsWith("feet")) return(stem=cut(s,"feet")+"foot");
     if(s.endsWith("zoa")) return(stem=cut(s,"zoa")+"zoon");

     // -eau to -eaux
     //No other common words end in eaux
     if(s.endsWith("eaux")) return(stem=cut(s,"x"));

     // -ieu to -ieux
     //No other common words end in ieux
     if(s.endsWith("ieux")) return(stem=cut(s,"x"));

     // -nx to -nges
     // Pay attention not to kill words ending in -nge with plural -nges
     // Take only Greek words (works fine, only a handfull of exceptions)
     if(s.endsWith("nges") && greek(s)) return(stem=cut(s,"nges")+"nx");

     // -[sc]h to -[sc]hes
     //No other common word ends with "shes", "ches" or "she(s)"
     //Quite a lot end with "che(s)", filter them out
     if(s.endsWith("shes") || s.endsWith("ches") && !categoryCHE_CHES.contains(s)) return(stem=cut(s,"es"));

     // -ss to -sses
     // No other common singular word ends with "sses"
     // Filter out those ending in "sse(s)"
     if(s.endsWith("sses") && !categorySSE_SSES.contains(s) && !s.endsWith("mousses")) return(stem=cut(s,"es"));

     // -x to -xes
     // No other common word ends with "xe(s)" except for "axe"
     if(s.endsWith("xes") && !s.equals("axes")) return(stem=cut(s,"es"));

     // -[nlw]ife to -[nlw]ives
     //No other common word ends with "[nlw]ive(s)" except for olive
     if(s.endsWith("nives") || s.endsWith("lives") && !s.endsWith("olives") ||
        s.endsWith("wives")) return(stem=cut(s,"ves")+"fe");

     // -[aeo]lf to -ves  exceptions: valve, solve
     // -[^d]eaf to -ves  exceptions: heave, weave
     // -arf to -ves      no exception
     if(s.endsWith("alves") && !s.endsWith("valves") ||
        s.endsWith("olves") && !s.endsWith("solves") ||
        s.endsWith("eaves") && !s.endsWith("heaves") && !s.endsWith("weaves") ||
        s.endsWith("arves") ) return(stem=cut(s,"ves")+"f");

     // -y to -ies
     // -ies is very uncommon as a singular suffix
     // but -ie is quite common, filter them out
     if(s.endsWith("ies") && !categoryIE_IES.contains(s)) return(stem=cut(s,"ies")+"y");

     // -o to -oes
     // Some words end with -oe, so don't kill the "e"
     if(s.endsWith("oes") && !categoryOE_OES.contains(s)) return(stem=cut(s,"es"));

     // -s to -ses
     // -z to -zes
     // no words end with "-ses" or "-zes" in singular
     if(s.endsWith("ses") || s.endsWith("zes") ) return(stem=cut(s,"es"));

     // - to -s
     if(s.endsWith("s") && !s.endsWith("ss") && !s.endsWith("is")) return(stem=cut(s,"s"));

     return stem;
  }
1073895
def find_matches(self, text):
        """"""
        if self.use_main_ns:
            self.namespace = __main__.__dict__

        if "." in text:
            return self.attr_matches(text)
        else:
            return self.global_matches(text)
371554
def findAllByBiSearch(self, strSeq) :
		""""""
		arr = self.encode(strSeq)
		lst = []
		self._dichFind(arr[0], self, 0, lst)
		return lst
481376
def segment(text: str, custom_dict: Trie = None) -> List[str]:
    """"""
    if not text or not isinstance(text, str):
        return []

    if not custom_dict:
        custom_dict = DEFAULT_DICT_TRIE

    return LongestMatchTokenizer(custom_dict).tokenize(text)
916127
def get_stem(self, noun, gender, mimation=True):
        """"""
        stem = ''
        if mimation and noun[-1:] == 'm':
            # noun = noun[:-1]
            pass
        # Take off ending
        if gender == 'm':
            if noun[-2:] in list(self.endings['m']['singular'].values()) + \
                    list(self.endings['m']['dual'].values()):
                stem = noun[:-2]
            elif noun[-1] in list(self.endings['m']['plural'].values()):
                stem = noun[:-1]
            else:
                print("Unknown masculine noun: {}".format(noun))
        elif gender == 'f':
            if noun[-4:] in self.endings['f']['plural']['nominative'] + \
                    self.endings['f']['plural']['oblique']:
                stem = noun[:-4] + 't'
            elif noun[-3:] in list(self.endings['f']['singular'].values()) + \
                    list(self.endings['f']['dual'].values()):
                stem = noun[:-3] + 't'
            elif noun[-2:] in list(self.endings['m']['singular'].values()) + \
                    list(self.endings['m']['dual'].values()):
                stem = noun[:-2]
            else:
                print("Unknown feminine noun: {}".format(noun))
        else:
            print("Unknown noun: {}".format(noun))
        return stem
1157732
def _vowelinstem(self, stem):
        """"""
        for i in range(len(stem)):
            if not self._cons(stem, i):
                return True
        return False
432106
def getcoordinates(self, tree, location):
        """"""
        return tuple(float(x) for x in tree.xpath('.//%s/*/text()' % location))
194273
public Stream<HString> findAll(@NonNull String text) {
      return Streams.asStream(new Iterator<HString>() {
         Integer pos = null;
         int start = 0;

         private boolean advance() {
            if (pos == null) {
               pos = indexOf(text, start);
            }
            return pos != -1;
         }

         @Override
         public boolean hasNext() {
            return advance();
         }

         @Override
         public HString next() {
            if (!advance()) {
               throw new NoSuchElementException();
            }
            int n = pos;
            pos = null;
            start = n + 1;
            //If we have tokens expand the match to the overlaping tokens.
            if (document() != null && document().isCompleted(Types.TOKEN)) {
               return union(substring(n, n + text.length()).tokens());
            }
            return substring(n, n + text.length());
         }
      });
   }
284019
def stems_for(words)
      stemmer = Lingua::Stemmer.new(language: 'en')
      words.map! { |word| stemmer.stem(word) }
    end
1328583
def _complete_cases(self, text, line, istart, iend):
        """"""
        if text == "":
            return list(self.live.keys())
        else:
            return [c for c in self.live if c.startswith(text)]
1081199
def parse_body(self, text):
        """"""
        re_raise = re.findall(r'[ \t]raise ([a-zA-Z0-9_]*)', text)
        if len(re_raise) > 0:
            self.raise_list = [x.strip() for x in re_raise]
            # remove duplicates from list while keeping it in the order
            # in python 2.7
            # stackoverflow.com/questions/7961363/removing-duplicates-in-lists
            self.raise_list = list(OrderedDict.fromkeys(self.raise_list))

        re_yield = re.search(r'[ \t]yield ', text)
        if re_yield:
            self.has_yield = True

        # get return value
        pattern_return = r'return |yield '
        line_list = text.split('\n')
        is_found_return = False
        line_return_tmp = ''

        for line in line_list:
            line = line.strip()

            if is_found_return is False:
                if re.match(pattern_return, line):
                    is_found_return = True

            if is_found_return:
                line_return_tmp += line
                # check the integrity of line
                try:
                    pos_quote = self._find_quote_position(line_return_tmp)

                    if line_return_tmp[-1] == '\\':
                        line_return_tmp = line_return_tmp[:-1]
                        continue

                    self._find_bracket_position(line_return_tmp, '(', ')',
                                                pos_quote)
                    self._find_bracket_position(line_return_tmp, '{', '}',
                                                pos_quote)
                    self._find_bracket_position(line_return_tmp, '[', ']',
                                                pos_quote)
                except IndexError:
                    continue

                return_value = re.sub(pattern_return, '', line_return_tmp)
                self.return_value_in_body.append(return_value)

                is_found_return = False
                line_return_tmp = ''
1250218
def __ensure_suffix_stem(t, suffix):
    
    tpath = str(t)
    if not tpath.endswith(suffix):
        stem = tpath
        tpath += suffix
        
        return tpath, stem
    else:
        stem, ext = os.path.splitext(tpath)
    
    return t, stem