import nltk

'''
groucho_grammar = nltk.CFG.fromstring("""
S -> NP VP
PP -> P NP
NP -> Det N | Det N PP | 'I'
VP -> V NP | VP PP
Det -> 'an' | 'my'
N -> 'elephant' | 'pajamas'
V -> 'shot'
P -> 'in'
""")'''

sent = ['I', 'shot', 'an', 'elephant', 'in', 'my', 'pajamas']

"""parser = nltk.ChartParser(groucho_grammar)
for tree in parser.parse(sent):
    print(tree)"""




aleman_grammar = nltk.CFG.fromstring("""
S -> NP VP
NP -> det N
NP -> det Adj N
NP -> PN
VP -> VM NP V
PN -> 'Ich'
VM ->  'will'
det -> 'deisen'
det -> 'einen'
Adj -> 'anderen'
N -> 'satz'
V -> 'ubersetzen'
""")

sent2 = ['Ich' , 'will', 'satz', 'ubersetzen']


parser = nltk.ChartParser(aleman_grammar)
for tree in parser.parse(sent2):
    print(tree)
