def parse_from_args(synonyms):
    '''
    Parse an array of string from argparser
    to SynonymSet
    '''

    syns_str = ''.join(synonyms)

    syns_str = syns_str.replace(' ', '')
    
    syn_set = SynonymSet()

    # to check if we are parsing inside the parenthesis
    inside_set = False
    current_syn = ''
    current_syn_set = set()

    for char in syns_str:
        if char == '{':
            inside_set = True
            current_syn_set = set()
            continue

        if char == '}':
            inside_set = False
            current_syn_set.add(current_syn)

            syn_set.add_set(current_syn_set)

            current_syn = ''

            continue

        if not inside_set:
            raise Exception("Incorrect synonyms {}".format(syns_str))

        if char == ',':
            if current_syn == '':
                raise Exception("Incorrect synonyms {}".format(syns_str))

            current_syn_set.add(current_syn)
            current_syn = ''

            continue

        current_syn += char

    return syn_set
def parse_from_args ( synonyms ) : syns_str = '' . join ( synonyms ) syns_str = syns_str . replace ( ' ' , '' ) syn_set = SynonymSet ( ) inside_set = False current_syn = '' current_syn_set = set ( ) for char in syns_str : if char == '{' : inside_set = True current_syn_set = set ( ) continue if char == '}' : inside_set = False current_syn_set . add ( current_syn ) syn_set . add_set ( current_syn_set ) current_syn = '' continue if not inside_set : raise Exception ( "Incorrect synonyms {}" . format ( syns_str ) ) if char == ',' : if current_syn == '' : raise Exception ( "Incorrect synonyms {}" . format ( syns_str ) ) current_syn_set . add ( current_syn ) current_syn = '' continue current_syn += char return syn_set
Parse an array of string from argparser
    to SynonymSet