Skip to content

Instantly share code, notes, and snippets.

@jiansoo
Created February 27, 2019 13:56

Revisions

  1. jiansoo created this gist Feb 27, 2019.
    36 changes: 36 additions & 0 deletions SnowboyModelAthenav3
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    def imperative_pos_tag(sent):
    return [(word, tag[:2]) if tag.startswith('VB') else (word,tag) for word, tag in nltk.pos_tag(['He']+sent)[1:]]

    def find_verb(inp):
    inp_token = nltk.word_tokenize(inp)
    inp_tagged = imperative_pos_tag(inp_token)
    print(inp_tagged)
    for i in range(len(inp_tagged)):
    if inp_tagged[i][1] == 'VB':
    return(inp_tagged[i][0], inp, i)

    def interpret_meaning(inp_v, inp, i):
    global playing
    span_generator = WhitespaceTokenizer().span_tokenize(inp)
    spans = [span for span in span_generator]
    verb_span = spans[i]

    if inp_v == 'play':
    rest_of_str = inp[(verb_span[1]+1):]
    if rest_of_str == 'music' or rest_of_str == '':
    spot.play()
    playing = True
    start_detection()
    elif 'playlist' in rest_of_str:
    ros_p = rest_of_str.replace('playlist ', '')
    print(ros_p)
    spot.search(ros_p, 'p')
    start_detection()
    else:
    spot.search(rest_of_str, 't')
    start_detection()
    elif inp_v == 'stop' or inp_v == 'pause':
    spot.pause()
    playing = False
    else:
    pass