Returns a specific morpheme, the n'th morpheme (given the particular set if specified).
556709
def morpheme(self,index, set=None):
        """"""
        for layer in self.select(MorphologyLayer):
            for i, m in enumerate(layer.select(Morpheme, set)):
                if index == i:
                    return m
        raise NoSuchAnnotation
1227701
public String getLemma() {
      if (isInstance(Types.TOKEN)) {
         if (contains(Types.SPELLING_CORRECTION)) {
            return get(Types.SPELLING_CORRECTION).asString();
         }
         if (contains(Types.LEMMA)) {
            return get(Types.LEMMA).asString();
         }
         return toLowerCase();
      }
      return tokens()
                .stream()
                .map(HString::getLemma)
                .collect(Collectors.joining(
                   getLanguage().usesWhitespace() ? " " : ""
                                           ));
   }
345765
def get_representation(self, prefix="", suffix="\n"):
        """"""
        res = prefix + "Section " + self.get_section_name().upper() + suffix
        return res
259112
private String morphColor(String str) {
		if (str.equals("")) {
			return "#000000";
		}
		if (str.equals("white")) {
			return "#ffffff";
		}
		if (str.equals("black")) {
			return "#000000";
		}
		
		return str;
	}
770272
def shape(self):
        ""
        keys = self.keys()
        if self.ndims == 1:
            return (len(keys), 1)
        return len(set(k[0] for k in keys)), len(set(k[1] for k in keys))
14355
public final List<Morpheme> getMorphemes(final String[] tokens, final String[] posTags) {
    final List<String> lemmas = lemmatize(tokens, posTags);
    final List<Morpheme> morphemes = getMorphemesFromStrings(tokens, posTags, lemmas);
    return morphemes;
  }
1200416
def get_bound_form(self, noun, gender):
        """"""
        syllables = self.syllabifier.syllabify(noun)
        stem = self.stemmer.get_stem(noun, gender)
        cv_pattern = self.cv_patterner.get_cv_pattern(stem)
        # Based on Huehnergard Appendix 6.C.1: base in -VC
        if [letter[0] for letter in cv_pattern[-2:]] == ['V', 'C'] or stem in ['nakr']:
            # a. 2-syllable
            if len(syllables) > 2:
                # awīlum > awīl, nakrum > naker
                if stem in ['nakr']:
                    return 'naker'
                else:
                    return stem
            # b. 1-syllable
            elif len(syllables) > 1:
                # bēlum > bēl
                return stem
            # c. abum, aḫum
            if stem in ['ab', 'aḫ']:
                return stem + 'i'
        # Appendix 6.C.2: base in -C₁C₁
        if cv_pattern[-1][:2] == cv_pattern[-2][:2]:
            # a. 1-syllable
            if 3 > len(syllables) > 1:
                return stem + 'i'
            # b. 2-syllable, -tt
            if len(syllables) > 2 and cv_pattern[-1][2] + cv_pattern[-2][2] == 'tt':
                return stem + 'i'
            # c. 2-syllable, other
            if len(syllables) > 2:
                return stem[:-1]
        # Appendix 6.C.3: base in -C₁C₂, C₂ ≠ t, i.e. pVrs
        if cv_pattern[-1][0] == cv_pattern[-2][0] and cv_pattern[-1][1] != cv_pattern[-2][1]:
            return stem[:-1] + stem[1] + stem[-1]
        # Appendix 6.C.4: base in -Ct (fem.)
        if cv_pattern[-1][2] == 't' and cv_pattern[-2][0] == 'C':
            if len(syllables) > 2:
                return stem + 'i'
            # Need to deal with fem. Ptcpl. māḫirtum -> māḫirat
            if len(syllables) > 1:
                # These are case by case
                if stem in ['qīšt']:
                    return stem + 'i'
                if stem in ['mārt']:
                    return stem[:-1] + stem[1] + stem[-1]
1200910
def getPattern(self, word):
        
        if word in self.patterns:
            return self.patterns[word]
        else:
            raise ValueError('Unknown pattern in getPattern().', word)
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
1092839
def literalize(self):
        
        expr = self.demorgan()
        if isinstance(expr, self.__class__):
            return expr
        return expr.literalize()
1185424
private static CharArraySet getStopwords(String stopwords) {
        List<String> stopwordsList = new ArrayList<>();
        for (String stop : stopwords.split(",")) {
            stopwordsList.add(stop.trim());
        }
        return new CharArraySet(stopwordsList, true);
    }
921481
public boolean isNormalWord(@NotNull String word, @NotNull Language language) {
        Timer timer = MetricsFactory.getMetrics().getTimer(MetricsType.TEXT_UTILS_IS_NORMAL_WORD.name());

        if (StringUtils.isEmpty(word)) {
            return false;
        }

        try {
            Timer morphTimer = MetricsFactory.getMetrics().getTimer(MetricsType.TEXT_UTILS_GET_MORPH_INFO.name());
            List<String> morphInfo = MorphologyFactory.getMorphology(language).getMorphInfo(word);
            morphTimer.stop();

            return morphInfo.stream()
                            .allMatch(new MorphRulesPredicate());

        } catch (Exception e) {
            LOGGER.warn("Can't get morph info: {" + word + "} ", e);
        } finally {
            timer.stop();
        }

        return false;
    }
843250
def getCharacterSet(self):
        '''

        '''
        
        chars = u''
        c = None
        cnt = 1
        start = 0

        while True:
            escaped_slash = False
            c = self.next()
            # print "pattern   : ", self.pattern
            # print "C         : ", c
            # print "Slash     : ", c == u'\\'
            # print 'chars     : ', chars
            # print 'index     : ', self.index
            # print 'last      : ', self.last()
            # print 'lookahead : ', self.lookahead()
            if self.lookahead() == u'-' and not c == u'\\':
                f = c
                self.next()  # skip hyphen
                c = self.next()  # get far range
                if not c or (c in self.meta_chars):
                    raise StringGenerator.SyntaxError(u"unexpected end of class range")
                chars += self.getCharacterRange(f, c)
            elif c == u'\\':
                if self.lookahead() in self.meta_chars:
                    c = self.next()
                    chars += c
                    continue
                elif self.lookahead() in self.string_code:
                    c = self.next()
                    chars += self.string_code[c]
            elif c and c not in self.meta_chars:
                chars += c
            if c == u']': 
                if self.lookahead() == u'{':
                    [start, cnt] = self.getQuantifier()
                else:
                    start = -1
                    cnt = 1
                break
            if c and c in self.meta_chars and not self.last() == u"\\":
                raise StringGenerator.SyntaxError(u"Un-escaped character in class definition: %s" % c)
            if not c:
                break

        return StringGenerator.CharacterSet(chars, start, cnt)
446678
@NotNull
    public Set<String> getNormalForms(@NotNull String word, @NotNull Language language) {
        com.fnklabs.metrics.Timer timer = MetricsFactory.getMetrics().getTimer(MetricsType.TEXT_UTILS_GET_NORMAL_FORMS.name());

        Set<String> normalForms = new HashSet<>();

        try {
            Morphology morphology = MorphologyFactory.getMorphology(language);
            List<String> normalForms1 = morphology.getNormalForms(word);
            normalForms.addAll(normalForms1);
        } catch (WrongCharaterException e) {
            LOGGER.warn("Can't get normal form of word", e);
        }

        timer.stop();

        return normalForms;
    }
1058707
public static CharArraySet getStopWords() {
        final CharArraySet words = StopFilter.makeStopSet(ADDITIONAL_STOP_WORDS, true);
        words.addAll(EnglishAnalyzer.ENGLISH_STOP_WORDS_SET);
        return words;
    }
863281
private Set<String> getSet(boolean isInflected) {
    Set<String> set = new HashSet<>();
    for (PatternToken patternToken : patternTokens) {
      boolean acceptInflectionValue = isInflected ? patternToken.isInflected() : !patternToken.isInflected();
      if (acceptInflectionValue && !patternToken.getNegation() && !patternToken.isRegularExpression()
              && !patternToken.isReferenceElement() && patternToken.getMinOccurrence() > 0) {
        String str = patternToken.getString();
        if (!StringTools.isEmpty(str)) {
          set.add(str.toLowerCase());
        }
      }
    }
    return Collections.unmodifiableSet(set);
  }
445868
def exttype(suffix):
    """"""
    def inner(s):
        if s == '':
            return s
        first, last = os.path.splitext(s)
        return first + suffix
    return inner