#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from nltk import parse_cfg
from nltk import word_tokenize
from nltk import RecursiveDescentParser

cfg = """
S -> NP VP
NP -> 'Anna'
VP -> 'szeret'
"""

parsed_cfg = parse_cfg(cfg)

parser = RecursiveDescentParser(parsed_cfg)

sentence = word_tokenize('Anna szeret')

print parser.parse(sentence)
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, division
import codecs

from nltk import parse_cfg
from nltk import word_tokenize
from nltk import RecursiveDescentParser


def encode(string, char_type='utf8', errors=''):
    return codecs.encode(string, char_type, errors)

cfg = encode("""
S -> NP VP NP
NP -> 'Péter' | 'Marit'
VP -> 'szereti'
""")

parsed_cfg = parse_cfg(cfg)

parser = RecursiveDescentParser(parsed_cfg)
uni_text = encode('Péter szereti Marit', 'utf8')
sentence = word_tokenize(uni_text)

print parser.parse(sentence)
Add encodeing with Codecs