Get normalized term
551915
def get_normalized_term(term_id: str, equivalents: list, namespace_targets: dict) -> str:
    """"""

    if equivalents and len(equivalents) > 0:
        for start_ns in namespace_targets:
            if re.match(start_ns, term_id):
                for target_ns in namespace_targets[start_ns]:
                    for e in equivalents:
                        if e and target_ns in e["namespace"] and e["primary"]:
                            normalized_term = e["term_id"]
                            return normalized_term

    return term_id
1298495
def normalize_value(text):
    
    result = text.replace('\n', ' ')
    result = re.subn('[ ]{2,}', ' ', result)[0]
    return result
686849
def classify(self, term, **kwargs):
        
        term = self._normalize(term)
        if dict.__contains__(self, term):
            return self[term][0].keys()[-1]
        # If the term is not in the dictionary, check the classifiers.
        # Returns the first term in the list returned by a classifier.
        for classifier in self.classifiers:
            # **kwargs are useful if the classifier requests extra information,
            # for example the part-of-speech tag.
            v = classifier.parents(term, **kwargs)
            if v:
                return v[0]
892411
def normalize(self):
        
        corefs = []
        types = []
        avms = []
        for term in self._terms:
            if isinstance(term, TypeTerm):
                types.append(term)
            elif isinstance(term, AVM):
                term.normalize()
                avms.append(term)
            elif isinstance(term, Coreference):
                corefs.append(term)
            else:
                raise TdlError('unexpected term {}'.format(term))
        self._terms = corefs + types + avms
1126236
function(term, any) {
                    var max = Math.max.apply(null, term.terms),
                        count = 0, idx;

                    if(!any) {
                        for(var i=0; i<term.terms.length; i++) {
                            if(term.terms[i].equals(max)) {
                                idx = i; count++;
                            }
                            if(count > 1) return;
                        }
                    }
                    if(any) {
                        for(i=0; i<term.terms.length; i++) 
                            if(term.terms[i].equals(max)) {
                                idx = i; break;
                            }
                    }
                    return [max, idx, term];
                }
18698
def split_term(cls, term):
        

        if '.' in term:
            parent_term, record_term = term.split('.')
            parent_term, record_term = parent_term.strip(), record_term.strip()

            if parent_term == '':
                parent_term = ELIDED_TERM

        else:
            parent_term, record_term = ROOT_TERM, term.strip()

        return parent_term, record_term
83833
def _normalize(self, tokens):
        """"""
        if self.case_sensitive:
            return ' '.join(self.lexicon[t].normalized for t in tokens)
        else:
            return ' '.join(self.lexicon[t].lower for t in tokens)
1268664
def _normalize(self, string):
		'''  '''

		string = super(VerbixDe, self)._normalize(string)
		string = string.replace('sie; Sie', 'sie')
		string = string.strip()
		return string
597776
def _get_normal_name(orig_enc):
    """"""
    # Only care about the first 12 characters.
    enc = orig_enc[:12].lower().replace("_", "-")
    if enc == "utf-8" or enc.startswith("utf-8-"):
        return "utf-8"
    if enc in ("latin-1", "iso-8859-1", "iso-latin-1") or \
       enc.startswith(("latin-1-", "iso-8859-1-", "iso-latin-1-")):
        return "iso-8859-1"
    return orig_enc
997839
def normalize(data):
    
    data = data.astype(float)
    data -= data.mean()
    
    return data / data.std()
230685
def value(self, term, **kwargs):
        
        term = self._normalize(term)
        if term in self._values:
            return self._values[term]
        for classifier in self.classifiers:
            v = classifier.value(term, **kwargs)
            if v is not None:
                return v
362627
def normalize(pw):
    
    pw_lower = pw.lower()
    return ''.join(helper.L33T.get(c, c) for c in pw_lower)
164618
def simplify(self):
        """"""
        d = defaultdict(float)
        for term in self.terms:
            term = term.simplify()
            d[term.ops] += term.coeff
        return Expr.from_terms_iter(
            Term.from_ops_iter(k, d[k]) for k in sorted(d, key=repr) if d[k])
494911
def _normalize(self, string):
		'''  '''

		string = super(VerbixFr, self)._normalize(string)
		string = string.replace('il; elle', 'il/elle')
		string = string.replace('ils; elles', 'ils/elles')
		string = string.strip()
		return string
855600
def normalize(self):
        """"""
        vlength = self.length()

        # Make sure the length isn't 0
        if vlength > 0:
            self.x /= vlength
            self.y /= vlength
            self.z /= vlength
            self.w /= vlength
        else:
            return Vector4(0, 0, 0, 0)
1008793
def normalize_query(query_string,
                    findterms=re.compile(r'"([^"]+)"|(\S+)').findall,
                    normspace=re.compile(r'\s{2,}').sub):
    

    return [normspace(' ', (t[0] or t[1]).strip()) for t in findterms(query_string)]
1348308
def _normalize_words(words, acronyms):
    """"""
    for i, _ in enumerate(words):
        # if detect_acronyms:
        if words[i].upper() in acronyms:
            # Convert known acronyms to upper-case.
            words[i] = words[i].upper()
        else:
            # Fallback behavior: Preserve case on upper-case words.
            if not words[i].isupper():
                words[i] = words[i].capitalize()
    return words