November 2018
Beginner to intermediate
182 pages
4h 48m
English
Quite often when using linguistics, you will be writing custom rules. Here is one data structure suggestion to help you store these rules: a list of dictionaries. Each dictionary in turn can have elements ranging from simple string lists to lists of strings. Avoid nesting a list of dictionaries inside a dictionary:
ruleset = [ { 'id': 1, 'req_tags': ['NNP', 'VBZ', 'NN'], }, { 'id': 2, 'req_tags': ['NNP', 'VBZ'], } ]
Here, I have written two rules. Each rule is simply a collection of part-of-speech tags that has been stored under the req_tags key. Each rule is comprised of all of the tags that I will look for in a particular sentence.
Depending on id, I will use a hardcoded question template to generate my questions. ...
Read now
Unlock full access