Ignore:
Timestamp:
Jul 29, 2019, 2:57:21 PM (5 years ago)
Author:
Murray Heymann <heymann.murray@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
9f0f63787f503527775273cff2d354bd558c9cda
Parents:
91d4aef86185a730eb9b18bef092b9b2a784f0fa
Message:
Cleanup
File:
1 edited

Legend:

Unmodified
Added
Removed
  • machine_learning/common/keyword_vector.py

    r91d4ae reb2904  
    3737    if not os.path.isfile(filename):
    3838        print("Please provide a valid input file as argument")
    39         return {}
     39        return []
    4040    if dictionary == []:
    4141        print("Please provide a valid dictionary as argument")
    42         return {}
     42        return []
    4343    if dictionary is None:
    4444        print("Please provide a valid dictionary as argument")
    45         return {}
     45        return []
    4646    vector = create_vector_dictionary(dictionary)
    4747    with open(filename, "r+") as file:
     
    8585    Create a zero vector for a given dictionary
    8686    """
     87    assert not dictionary == None, "Please give a dictionary"
     88    assert not len(dictionary) == 0, "Please give a dictionary"
    8789    vector = {}
    8890    for word in dictionary:
     
    99101        return -1
    100102
    101     diff_vec = vec1 - vec2
    102     dist = np.linalg.norm(diff_vec)
     103    dist = np.linalg.norm(vec1 - vec2)
    103104
    104105    return dist
Note: See TracChangeset for help on using the changeset viewer.