extractor module¶
-
interpreter.extractor.
is_direction
(word)[source]¶ Checks if a
word
represents a direction.The word is checked against a hard-coded list of directional words. If there is a match, then the
word
is determined to be a directional word. This function is present to provide a space to make this operation more robust in the future.Parameters: word (str) – The word to be checked Returns: True
if theword
represents a directional word,False
if notReturn type: bool
-
interpreter.extractor.
is_noun
(tag)[source]¶ Checks if a part of speech tag represents a noun. The tags
"PRP"
and those that begin with"NN"
are considered nouns.Parameters: tag (str) – The part of speech tag to be checked Returns: True
if the tag represents a noun,False
if notReturn type: bool
-
interpreter.extractor.
is_preposition
(tag)[source]¶ Checks if a part of speech tag represents a preposition. The tags
"TO"
and"IN"
considered to be prepositions.Parameters: tag (str) – The part of speech tag to be checked Returns: True
if the tag represents a preposition,False
if notReturn type: bool
-
interpreter.extractor.
object_dict_follow
(sent)[source]¶ Extracts objects out of a sentence that contains follow as its action
Rules:
- The first noun encountered is always the person
- The second noun (if included) is always the place
Objects:
- person - The person who will be followed
- place - The location that the person will be followed to
Parameters: sent (list) – A part of speech tagged list of tokens representing a sentence Returns: An object dictionary for the command Return type: dict
-
interpreter.extractor.
object_dict_move
(sent)[source]¶ Extracts objects out of a sentence that contains move as its action
Rules:
- Only the first noun is detected as an object
- If the first noun is preced by a preposition, then it is the place
- If the first noun is not preceded by a preposition, then it is the direction
Objects:
- place - A location to move to
- direction - A direction to move in
Parameters: sent (list) – A part of speech tagged list of tokens representing a sentence Returns: An object dictionary for the command Return type: dict
-
interpreter.extractor.
object_dict_show
(sent)[source]¶ Extracts objects out of a sentence that contains show as its action
Rules:
- The verb preceded by a to is the shown_action
- The noun that is not preceded by a determiner or to is the person
- The noun that is preceded either by a determiner or the shown_action is the object
Objects:
- shown_action - The action that will be shown in a video
- person - The person who will be shown the action or object
- object - The object that is acted on in the video or a static object to be shown as a picture
- video_title - The title of the video to be played; it is currently generated by concatentating the shown_action with the object
Parameters: sent (list) – A part of speech tagged list of tokens representing a sentence Returns: An object dictionary for the command Return type: dict
-
interpreter.extractor.
object_dict_stop
(sent)[source]¶ Extracts objects out of a sentence that contains stop as its action
Currently returns an empty dictionary.
Parameters: sent (list) – A part of speech tagged list of tokens representing a sentence Returns: An object dictionary for the command - currently returns an empty dictionary under all inputs Return type: dict
-
interpreter.extractor.
object_dict_talk
(sent)[source]¶ Extracts objects out of a sentence that contains talk as its action
Rules:
- The noun to come after the word about is the topic
- The noun to come after any preposition that is not about is the person
- Other nouns will be tagged as unknown
Objects:
- person - The person to talk to
- topic - The subject to talk about
- unknown - The role of this noun is not known
Parameters: sent (list) – A part of speech tagged list of tokens representing a sentence Returns: An object dictionary for the command Return type: dict
-
interpreter.extractor.
object_dict_turn
(sent)[source]¶ Extracts objects out of a sentence that contains turn as its action.
Currently uses the same rules as
object_dict_move()
Parameters: sent (list) – A part of speech tagged list of tokens representing a sentence Returns: An object dictionary for the command Return type: dict