Changeset eb2904 in git for machine_learning/common/keyword_vector.py
- Timestamp:
- Jul 29, 2019, 2:57:21 PM (5 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 9f0f63787f503527775273cff2d354bd558c9cda
- Parents:
- 91d4aef86185a730eb9b18bef092b9b2a784f0fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
machine_learning/common/keyword_vector.py
r91d4ae reb2904 37 37 if not os.path.isfile(filename): 38 38 print("Please provide a valid input file as argument") 39 return {}39 return [] 40 40 if dictionary == []: 41 41 print("Please provide a valid dictionary as argument") 42 return {}42 return [] 43 43 if dictionary is None: 44 44 print("Please provide a valid dictionary as argument") 45 return {}45 return [] 46 46 vector = create_vector_dictionary(dictionary) 47 47 with open(filename, "r+") as file: … … 85 85 Create a zero vector for a given dictionary 86 86 """ 87 assert not dictionary == None, "Please give a dictionary" 88 assert not len(dictionary) == 0, "Please give a dictionary" 87 89 vector = {} 88 90 for word in dictionary: … … 99 101 return -1 100 102 101 diff_vec = vec1 - vec2 102 dist = np.linalg.norm(diff_vec) 103 dist = np.linalg.norm(vec1 - vec2) 103 104 104 105 return dist
Note: See TracChangeset
for help on using the changeset viewer.