コード例 #1
0
 def run(self, edit):
     set_replacements(
         self.view, edit,
         map(
             lambda selection: Replacement(
                 selection,
                 inflection.transliterate(self.view.substr(selection))),
             self.view.sel()))
コード例 #2
0
def sanitized_string(text):
    """
    Ensures strings are properly sanitized
    and no special characters are present.
    """

    r = inflection.transliterate(text)
    r = r.replace(' ', '-')
    return inflection.underscore(r).lower()
コード例 #3
0
def clean_sent(sent):
	sent=re.sub(r"http\S+", "", sent.lower()).decode('utf-8')
	sent=re.sub(r"@\S+", "", sent.lower()).decode('utf-8')
	sent=TextBlob(sent)
	sent = sent.correct()
	#words=sent.split(" ")
	words=tokenizer.tokenize(sent)
	words_refined=[lemmatizer.lemmatize(inflection.singularize(word)) for word in words]
	words=[inflection.transliterate(word.decode('utf-8')) for word in words_refined if not word.isdigit() and len(word)>2]
	p_stemmer = PorterStemmer()
	_digits = re.compile('\d')
	words_refined=[str(word) for word in words if not bool(_digits.search(word)) and word not in stop]
	return words_refined
コード例 #4
0
 def is_profane(self, string):
     ascii = inflection.transliterate(string.translate(self.tx))
     return self.regex.search(ascii)
コード例 #5
0
 def censor(self, string):
     ascii = inflection.transliterate(string.translate(self.tx))
     return self.regex.sub('*', ascii)
コード例 #6
0
def transliterate(string):
    __doc__ = inflection.transliterate.__doc__
    return inflection.transliterate(str(string))
コード例 #7
0
ファイル: api_gen.py プロジェクト: flavluc/python-scripts
current_dir_path = os.path.dirname(os.path.abspath(__file__))

api_name_plural = input('API name com acento e plural: ')
api_name_singular = input('API name com acento e singular: ')
masculino = input('A palavra eh masculina? ')

if masculino[0] == 'n' or masculino == 'f':
    masc = False
else:
    masc = True

api_name_plural = api_name_plural.replace(" ", "_")
api_name_singular = api_name_singular.replace(" ", "_")
print(api_name_plural, api_name_singular)
dir_name = inflection.dasherize(
    inflection.transliterate(api_name_plural)),  #contas-cartao
abs_api_path = str(current_dir_path) + '/' + str(dir_name)

if masc is True:
    new = 'novo'
    one = 'um'
    the = 'o'
else:
    new = 'nova'
    one = 'uma'
    the = 'a'

api_dict = dict(
    new=new,
    one=one,
    the=the,