I want to extract words from a string that contain specific character (/IN) until to other specific character (/NNP). My code so far (still not work):
import re
sentence = "Entah/RB kenapa/NN ini/DT bayik/NN suka/VBI banget/JJ :/: )/CP :/: )/CP :/: )/CP berenang/VBI di/IN Jln/NN Terusan/NNP Borobudur/NNP dan/NN di/IN Jalan/NN Perempatan/ADJ Malioboro/NNP"
tes = re.findall(r'((?:\S+/IN\s\w+/NNP\s*)+)', sentence)
print(tes)
So the sentence
contain words di/IN Jln/NN Terusan/NNP Borobudur/NNP
and di/IN Jalan/NN Perempatan/ADJ Malioboro/NNP
that I like to extract. The expected result:
['di/IN Jln/NN Terusan/NNP Borobudur/NNP', 'di/IN Jalan/NN Perempatan/ADJ Malioboro/NNP']
What is the best way to do this task? thanks.