<jupyter_start><jupyter_text>19 > Write a list comprehension that sorts a list of WordNet synsets for proximity to a given synset. For example, given the synsets `minke_whale.n.01`, `orca.n.01`, `novel.n.01`, and `tortoise.n.01`, sort them according to their `path_distance()` from `right_whale.n.01`.<jupyter_code>import nltk
from nltk.corpus import wordnet as wn
synsets = [wn.synset('minke_whale.n.01'), wn.synset('orca.n.01'),
          wn.synset('novel.n.01'), wn.synset('tortoise.n.01')]
[_ for _ in sorted(synsets, key=lambda x: wn.synset('right_whale.n.01').path_similarity(x), reverse=True)]<jupyter_output><empty_output><jupyter_text>20 > Write a function that takes a list of words (containing duplicates) and returns a list of words (with no duplicates) sorted by decreasing frequency. E.g., if the input list contained 10 instances of the word `table` and 9 instances of the word `chair`, then `table` would appear before `chair` in the output list.<jupyter_code>def unique_words(words):
    fd = nltk.FreqDist(words)
    return [sorted(fd, key=lambda x: fd[x], reverse=True)]
unique_words(['table'] * 10 + ['chair'] * 9)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1323024054982818, 'fraction_numerical': 0.02577319587628866, 'mean_word_length': 5.4010989010989015, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '191142', 'license': 'MIT', 'n_tokens_mistral': 431, 'n_tokens_neox': 400, 'n_words': 121, 'path': 'Exercises/ch04.ipynb', 'repo_name': 'MrWolffy/Natural-Language-Processing-with-Python', 'size': '1164'}