Exemplo n.º 1
0
def string_camelcase(string):
    """ Convert a word  to its CamelCase version and remove invalid chars

    >>> string_camelcase('lost-pound')
    'LostPound'
    
    >>> string_camelcase('missing_images')
    'MissingImages'
    """
    return CAMELCASE_INVALID_CHARS.sub('', string.title())
Exemplo n.º 2
0
def string_camelcase(string):
    """ Convert a word  to its CamelCase version and remove invalid chars

    >>> string_camelcase('lost-pound')
    'LostPound'
    
    >>> string_camelcase('missing_images')
    'MissingImages'
    """
    return CAMELCASE_INVALID_CHARS.sub('', string.title())
Exemplo n.º 3
0
def isCity(string):
    string = string.lower()
    city = {'bronx', 'brooklyn', 'manhattan', 'queens', 'staten island', 'nyc'}
    if string in city:
        return True
    string = string.title()
    places = GeoText(string)
    if len(places.cities):
        return True
    else:
        return False
Exemplo n.º 4
0
def make_titlecase(string):
    """
    Convert string s to title case(my version).
    Like python's, title() method but keeps small words lower cased.
    """
    string = string.title()

    def lower_case(m):
        return m.group(1).lower()

    string = re.sub(RE_UNCAPITALIZED_WORDS, lower_case, string)
    string = string[0].upper() + string[1:]

    return string
Exemplo n.º 5
0
def cleanchannel(channel):
    string = channel.replace('ENT:', '').replace('MOV:', '').replace(
        'SSS:', '').replace('DOC:', '').replace('KID:', '').replace(
            'UKS:', '').replace('BTS:', '').replace('UK:', '').replace(
                'MUS:', '').replace('UKINT:',
                                    '').replace('NEW:',
                                                '').replace('USA/CA:', '')
    string = string.title()
    string = string.replace('Sd', 'SD').replace('Hd', 'HD').replace(
        'Itv',
        'ITV').replace('Bbc',
                       'BBC').replace('BBC 1',
                                      'BBC One').replace('BBC 2',
                                                         'BBC Two').strip()
    return string
Exemplo n.º 6
0
def ngrams(string, n=3):

    string = fix_text(string) # fix text encoding issues
    string = string.encode("ascii", errors="ignore").decode() #remove non ascii chars
    string = string.lower() #make lower case
    chars_to_remove = [")","(",".","|","[","]","{","}","'"]
    rx = '[' + re.escape(''.join(chars_to_remove)) + ']'
    string = re.sub(rx, '', string) #remove the list of chars defined above
    string = string.replace('&', 'and')
    string = string.replace(',', ' ')
    string = string.replace('-', ' ')
    string = string.title() # normalise case - capital at start of each word
    string = re.sub(' +',' ',string).strip() # get rid of multiple spaces and replace with a single space
    string = ' '+ string +' ' # pad names for ngrams...
    string = re.sub(r'[,-./]|\sBD',r'', string)
    ngrams = zip(*[string[i:] for i in range(n)])
    return [''.join(ngram) for ngram in ngrams]
Exemplo n.º 7
0
def string_camelcase(string):
    """
    .替换变量名中的各种符号并生成驼峰式命令格式
    """
    return CAMELCASE_INVALID_CHARS.sub('', string.title())
def camel_case(string):
    return string.title().replace(" ", "")
Exemplo n.º 9
0
def string_camelcase(string):
    '''Convert a word  to its CamelCase version and remove invalid chars.
    '''
    return _camelcase_invalid_chars_re.sub('', string.title())
Exemplo n.º 10
0
def string_to_boolean(string):
    try:
        return not eval(string.title())
    except NameError:
        return True
Exemplo n.º 11
0
flag = 0
for i in range(len(string)):
    print(len(string))
    if(string[i] == char):
        flag = 1
        break


if(flag == 0):
    print("Sorry! We haven't found the Search Character in this string ")
else:
    print("The first Occurrence of ", char, " is Found at Position " , i + 1)


print(string.title())

def Repeat(x):
    _size = len(x)
    repeated = []
    for i in range(_size):
        k = i + 1
        for j in range(k, _size):
            if x[i] == x[j] and x[i] not in repeated:
                repeated.append(x[i])
    return repeated


list1 = [10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20]
print(Repeat(list1))