(f)
return word2nums, num2words
Parses the WordNet wn_s.pl prolog file and returns two dictionaries:
    word2nums and num2words.
Parses the WordNet wn_s.pl prolog file and returns two dictionaries:
    word2nums and num2words.
Parses the WordNet wn_s . pl prolog file and returns two dictionaries : word2nums and num2words .
def parse_file(f):
    """Parses the WordNet wn_s.pl prolog file and returns two dictionaries:
    word2nums and num2words.
    """

    word2nums = defaultdict(list)
    num2words = defaultdict(list)

    for line in f:
        if not line.startswith("s("):
            continue

        line = line[2:]
        num = int(line[:line.find(",")])
        qt = line.find("'")
        line = line[qt + 1:]
        qt = line.find("'")
        word = line[:qt].lower()

        if not word.isalpha():
            continue

        word2nums[word].append(num)
        num2words[num].append(word)

    return word2nums, num2words
def parse_file ( f ) : word2nums = defaultdict ( list ) num2words = defaultdict ( list ) for line in f : if not line . startswith ( "s(" ) : continue line = line [ 2 : ] num = int ( line [ : line . find ( "," ) ] ) qt = line . find ( "'" ) line = line [ qt + 1 : ] qt = line . find ( "'" ) word = line [ : qt ] . lower ( ) if not word . isalpha ( ) : continue word2nums [ word ] . append ( num ) num2words [ num ] . append ( word ) return word2nums , num2words