I have the following two strings with their POS tags:
Sent1: \"something like how writer pro or phraseology works would be really cool.\"<
from itertools import tee,izip,dropwhile
import nltk
def check_sentence(S):
def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = tee(iterable)
next(b, None)
return izip(a, b)
def consecutive_would_be(word_group):
first, second = word_group
(would_word, _) = first
(be_word, _) = second
return would_word.lower() != "would" && be_word.lower() != "be"
for word_groups in dropwhile(consecutive_would_be, pairwise(nltk.pos_tag(nltk.word_tokenize(S))):
first, second = word_groups
(_, pos1) = first
(_, pos2) = second
if pos1 == "JJ" || pos2 == "JJ":
return True
return False
and then you can use the function like so:
S = "more options like the syntax editor would be nice."
check_sentence(S)