Step 1: Standard suffix removal
194697
private function step1()
    {
        // amente
        //      delete if in R1
        //      if preceded by iv, delete if in R2 (and if further preceded by at, delete if in R2), otherwise,
        //      if preceded by os, ic or abil, delete if in R2
        if ( ($position = $this->search(array('amente'))) !== false) {
            if ($this->inR1($position)) {
                $this->word = Utf8::substr($this->word, 0, $position);
            }

            // if preceded by iv, delete if in R2 (and if further preceded by at, delete if in R2), otherwise,
            if ( ($position2 = $this->searchIfInR2(array('iv'))) !== false) {
                $this->word = Utf8::substr($this->word, 0, $position2);
                if ( ($position3 = $this->searchIfInR2(array('at'))) !== false) {
                    $this->word = Utf8::substr($this->word, 0, $position3);
                }

                // if preceded by os, ic or ad, delete if in R2
            } elseif ( ($position4 = $this->searchIfInR2(array('os', 'ic', 'abil'))) != false) {
                $this->word = Utf8::substr($this->word, 0, $position4);
            }
            return true;
        }

        // delete if in R2
        if ( ($position = $this->search(array(
            'ibili', 'atrice', 'abili', 'abile', 'ibile', 'atrici', 'mente',
            'anza', 'anze', 'iche', 'ichi', 'ismo', 'ismi', 'ista', 'iste', 'isti', 'istà', 'istè', 'istì', 'ante', 'anti',
            'ico', 'ici', 'ica', 'ice', 'oso', 'osi', 'osa', 'ose'
        ))) !== false) {

            if ($this->inR2($position)) {
                $this->word = Utf8::substr($this->word, 0, $position);
            }
            return true;
        }

        // azione   azioni   atore   atori
        //      delete if in R2
        //      if preceded by ic, delete if in R2
        if ( ($position = $this->search(array('azione', 'azioni', 'atore', 'atori'))) !== false) {
            if ($this->inR2($position)) {
                $this->word = Utf8::substr($this->word, 0, $position);

                if ( ($position2 = $this->search(array('ic'))) !== false) {
                    if ($this->inR2($position2)) {
                        $this->word = Utf8::substr($this->word, 0, $position2);
                    }
                }
            }
            return true;
        }

        // logia   logie
        //      replace with log if in R2
        if ( ($position = $this->search(array('logia', 'logie'))) !== false) {
            if ($this->inR2($position)) {
                $this->word = preg_replace('#(logia|logie)$#u', 'log', $this->word);
            }
            return true;
        }

        // uzione   uzioni   usione   usioni
        //      replace with u if in R2
        if ( ($position = $this->search(array('uzione', 'uzioni', 'usione', 'usioni'))) !== false) {
            if ($this->inR2($position)) {
                $this->word = preg_replace('#(uzione|uzioni|usione|usioni)$#u', 'u', $this->word);
            }
            return true;
        }

        // enza   enze
        //      replace with ente if in R2
        if ( ($position = $this->search(array('enza', 'enze'))) !== false) {
            if ($this->inR2($position)) {
                $this->word = preg_replace('#(enza|enze)$#u', 'ente', $this->word);
            }
            return true;
        }

        // amento   amenti   imento   imenti
        //      delete if in RV
        if ( ($position = $this->search(array('amento', 'amenti', 'imento', 'imenti'))) !== false) {
            if ($this->inRv($position)) {
                $this->word = Utf8::substr($this->word, 0, $position);
            }
            return true;
        }

        // ità
        //      delete if in R2
        //      if preceded by abil, ic or iv, delete if in R2
        if ( ($position = $this->search(array('ità'))) !== false) {
            if ($this->inR2($position)) {
                $this->word = Utf8::substr($this->word, 0, $position);
            }

            if ( ($position2 = $this->searchIfInR2(array('abil', 'ic', 'iv'))) != false) {
                $this->word = Utf8::substr($this->word, 0, $position2);
            }
            return true;
        }

        // ivo   ivi   iva   ive
        //      delete if in R2
        //      if preceded by at, delete if in R2 (and if further preceded by ic, delete if in R2)
        if ( ($position = $this->search(array('ivo', 'ivi', 'iva', 'ive'))) !== false) {
            if ($this->inR2($position)) {
                $this->word = Utf8::substr($this->word, 0, $position);
            }

            if ( ($position2 = $this->searchIfInR2(array('at'))) !== false) {
                $this->word = Utf8::substr($this->word, 0, $position2);
                if ( ($position3 = $this->searchIfInR2(array('ic'))) !== false) {
                    $this->word = Utf8::substr($this->word, 0, $position3);
                }
            }
            return true;
        }

        return false;
    }
897352
def replace_types(strings, suffix=':')
      if configuration[:solr_fields]
        configuration[:solr_fields].each do |name, options|
          solr_name = (options[:as] || name).to_s
          solr_type = get_solr_field_type(options[:type])
          field = "#{solr_name}_#{solr_type}#{suffix}"
          strings.each_with_index {|s,i| strings[i] = s.gsub(/\b#{solr_name}\b#{suffix}/,field) }
        end
      end
      if configuration[:solr_includes]
        configuration[:solr_includes].each do |association, options|
          solr_name = options[:as] || association.to_s.singularize
          solr_type = get_solr_field_type(options[:type])
          field = "#{solr_name}_#{solr_type}#{suffix}"
          strings.each_with_index {|s,i| strings[i] = s.gsub(/\b#{solr_name}\b#{suffix}/,field) }
        end
      end
      strings
    end
428435
def cull_prefixes(graph, prefixes={k:v for k, v in uPREFIXES.items() if k != 'NIFTTL'},
                  cleanup=lambda ps, graph: None, keep=False):
    
    prefs = ['']
    if keep:
        prefixes.update({p:str(n) for p, n in graph.namespaces()})

    if '' not in prefixes:
        prefixes[''] = null_prefix  # null prefix

    pi = {v:k for k, v in prefixes.items()}
    asdf = {} #{v:k for k, v in ps.items()}
    asdf.update(pi)
    # determine which prefixes we need
    for uri in set((e for t in graph for e in t)):
        if uri.endswith('.owl') or uri.endswith('.ttl') or uri.endswith('$$ID$$'):
            continue  # don't prefix imports or templates
        for rn, rp in sorted(asdf.items(), key=lambda a: -len(a[0])):  # make sure we get longest first
            lrn = len(rn)
            if type(uri) == rdflib.BNode:
                continue
            elif uri.startswith(rn) and '#' not in uri[lrn:] and '/' not in uri[lrn:]:  # prevent prefixing when there is another sep
                prefs.append(rp)
                break

    ps = {p:prefixes[p] for p in prefs}

    cleanup(ps, graph)

    ng = makeGraph('', prefixes=ps)
    [ng.g.add(t) for t in graph]
    return ng
42368
def replace_suffix (name, new_suffix):
    
    assert isinstance(name, basestring)
    assert isinstance(new_suffix, basestring)
    split = os.path.splitext (name)
    return split [0] + new_suffix
1222945
def clean_name(self, suffix=True, prefix=False, middle=False, multi=False):
		""

		name = self.business_name

		# Run it through the string_stripper once more
		name = self.string_stripper(name)
		loname = name.lower()
		
		# return name without suffixed/prefixed/middle type term(s)

		for item in suffix_sort:
			if suffix:
				if loname.endswith(" " + item):
					start = loname.find(item)
					end = len(item)
					name = name[0:-end-1]
					name = self.string_stripper(name)
					if multi==False:
						break
			if prefix:
				if loname.startswith(item+' '):
					name = name[len(item)+1:]
					if multi==False:
						break
			if middle:
				term = ' ' + item + ' '
				if term in loname:
					start = loname.find(term)
					end = start + len(term)
					name = name[:start] + " " + name[end:]
					if multi==False:
						break

		return self.string_stripper(name)
706806
def _clean_name(fname, data):
    
    for to_remove in dd.get_batches(data) + [dd.get_sample_name(data), data["sv"]["variantcaller"]]:
        for ext in ("-", "_"):
            if fname.startswith("%s%s" % (to_remove, ext)):
                fname = fname[len(to_remove) + len(ext):]
        if fname.startswith(to_remove):
            fname = fname[len(to_remove):]
    return fname
245542
def _matchremove_simple_endings(self, word):
        """"""

        was_stemmed = False

        # noun, adjective, and adverb word endings sorted by charlen, then alph
        simple_endings = ['ibus',
                            'ius',
                            'ae',
                            'am',
                            'as',
                            'em',
                            'es',
                            'ia',
                            'is',
                            'nt',
                            'os',
                            'ud',
                            'um',
                            'us',
                            'a',
                            'e',
                            'i',
                            'o',
                            'u']

        for ending in simple_endings:
            if word.endswith(ending):
                word = re.sub(r'{0}$'.format(ending), '', word)
                was_stemmed = True
                break

        return word, was_stemmed
556505
def eliminate_repeats(text):
    ''''''
    
    bannedwords = read_file('stopwords.txt')
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    words = text.split()
    standardwords = []
    for word in words:
        newstr = ''
        for char in word:
            if char in alphabet or char in alphabet.upper():
               newstr += char
        if newstr not in standardwords and newstr != '' and newstr not in bannedwords:
            standardwords.append(newstr)
        
    return map(lambda x: x.lower(),standardwords)
663692
function unwrapAst (ast, prefix, suffix) {
  let fake_code = `${prefix}\nlet ${LONG_AND_WEIRED_STRING}\n${suffix}`
  let fake_ast = babylon.parse(fake_code, {
    sourceType: 'module'
  })

  let selected_node
  let selected_index
  traverse(fake_ast, {
    enter: function (node, parent) {
      // removes the loc info of fake ast
      if (node.loc) {
        node.loc = null
      }

      if (node.type !== 'BlockStatement') {
        return
      }

      // find the index of LONG_AND_WEIRED_STRING
      let index = node.body.findIndex(n => {
        if (node.type !== 'VariableDeclaration') {
          return
        }

        if (
          access(n, [
            'declarations', 0,
            'id',
            'name'
          ]) === LONG_AND_WEIRED_STRING
        ) {
          return true
        }
      })

      if (!~index) {
        return
      }

      selected_node = node
      selected_index = index
    }
  })

  if (selected_node) {
    selected_node.body.splice(selected_index, 1)
    selected_node.body.push(...ast.program.body)
  }

  return fake_ast
}
375832
def trim_common_prefixes(strs, min_len=0):
    """"""

    trimmed = 0

    if len(strs) > 1:
        s1 = min(strs)
        s2 = max(strs)

        for i in range(len(s1) - min_len):
            if s1[i] != s2[i]:
                break
            trimmed = i + 1

    if trimmed > 0:
        strs = [s[trimmed:] for s in strs]

    return trimmed, strs
191006
private static List<String> normalizePackagePrefixes(List<String> packages)
    {
        if (packages == null)
            return null;

        List<String> result = new ArrayList<>(packages.size());
        for (String pkg : packages)
        {
            if(pkg.endsWith(".*")){
                System.out.println("Warning: removing the .* suffix from the package prefix: " + pkg);
            }
            result.add(StringUtils.removeEndIgnoreCase(pkg, ".*"));
        }

        return packages;
    }
483485
def prune_urls(url_set, start_url, allowed_list, ignored_list):
    """"""
    result = set()

    for url in url_set:
        allowed = False
        for allow_url in allowed_list:
            if url.startswith(allow_url):
                allowed = True
                break

        if not allowed:
            continue

        ignored = False
        for ignore_url in ignored_list:
            if url.startswith(ignore_url):
                ignored = True
                break

        if ignored:
            continue

        prefix, suffix = (url.rsplit('.', 1) + [''])[:2]
        if suffix.lower() in IGNORE_SUFFIXES:
            continue

        result.add(url)

    return result
934553
def __remove_prefix(self, step):
        
        step_length = len(step)
        for k in KEYWORDS:
            step = step.lstrip(k)
            if len(step) < step_length:
                break
        return step
1182986
private String stripPrefixes(String word) {
        String[] prefixes = {"kilo", "micro", "milli", "intra", "ultra", "mega",
            "nano", "pico", "pseudo"};

        int last = prefixes.length;
        for (int i = 0; i < last; i++) {
            if ((word.startsWith(prefixes[i])) && (word.length() > prefixes[i].length())) {
                word = word.substring(prefixes[i].length());
                return word;
            }
        }

        return word;
    }
418765
function unPrefix(s, prefix) {
  s = str(s);
  if (!prefix) return s;
  if (s.slice(0, prefix.length) === prefix) return s.slice(prefix.length);
  return s;
}
874461
private String cleanTags(String s) {
    int idx = s.indexOf("#");
    if (idx != -1) {
      s = s.substring(0, idx);
    }
    return s.trim();
  }
1075021
def _clean_name(self, prefix, obj):
        """"""
        return '{}{}_{}'.format(prefix, self._uid(), ''.join(c for c in obj.name if c.isalnum()))