Skip to content

Instantly share code, notes, and snippets.

@language-engineering
Last active December 27, 2015 16:19
Show Gist options
  • Save language-engineering/7354649 to your computer and use it in GitHub Desktop.
Save language-engineering/7354649 to your computer and use it in GitHub Desktop.
def opinion_extractor(aspect_token, parsed_sentence):
# Your function will have 3 steps:
# i. Initialise a list of opinions
opinions = []
# ii. Find opinions (as an example we get all the dependants of the aspect token that have the relation "det")
opinions += [dependant.form for dependant in parsed_sentence.get_dependants(aspect_token) if dependant.deprel == "det"]
# You can continue to add to "opinions". Remember you can get the head of a token, and filter by PoS tag or Deprel too!
# iii. Return the (possibly empty) list of opinions
return opinions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment