germanetpy.longest_shortest_path¶
Functions
|
Iterate trough the synsets of a given word category. |
set a maxdistcounter = 0 for each synset: get the corresponding longest shortest distance. if this plus the overall longest shortest distance is smaller than maxdistance: continue with the next synset if it is larger: go trough each synset and get the corresponding longest shortest distance. if this plus the longest shortest distance of the synset of interest is smaller than maxdistance: continue else: compute the actual path distance and update the maxdistance if it is larger. |
|
Iterate trough the synsets of a given wordcategory. |
|
|
Computes and prints the longest shortest distances for the given word category. |
|
Computes and prints the maximum depth for the given word_category. |
- germanetpy.longest_shortest_path.get_overall_longest_shortest_distance(germanet, category) -> (<class 'dict'>, <class 'int'>)[source]¶
Iterate trough the synsets of a given wordcategory. For each synset, extract all possible hypernyms and compute the shortest possible distance to each hypernym. From these distances, also store the longest possible shortest distance.
- Parameters:
germanet (Germanet) – the germanet graph
category (WordCategory) – the wordcategory
- Returns:
a dictionary with each synset and its longest shortest distance, the overall longest shortest distance
- germanetpy.longest_shortest_path.get_greatest_depth(germanet, category) int[source]¶
Iterate trough the synsets of a given word category. For each synset check the depth and return the greatest depth that has been seen.
- Parameters:
germanet (Germanet) – the germanet graph
category (WordCategory) – the wordcategory
- Returns:
the greatest depth for a given word category. The depth of a synset is defined by the shortest path length between the synset and the root node
- germanetpy.longest_shortest_path.get_longest_possible_shortest_distance(germanet, wordcategory)[source]¶
set a maxdistcounter = 0 for each synset: get the corresponding longest shortest distance. if this plus the overall longest shortest distance is smaller than maxdistance:
continue with the next synset
- if it is larger:
go trough each synset and get the corresponding longest shortest distance. if this plus the longest shortest distance of the synset of interest is smaller than maxdistance:
continue
- else:
compute the actual path distance and update the maxdistance if it is larger
- Return type:
- Parameters:
wordcategory (WordCategory) – the wordcategory for which this maxlen should be computed
germanet (Germanet) – the germanet graph
- Returns:
the longest possible shortest distance between two synsets of a specified wordcategory, the maximum depth
of any synset (lenght to the root) and a Tuple with two synsets that have the longest shortest distance