'Sentence translation with NLTK
I'm trying to translate an English sentence into a Filipino dialect, how do I go about it? I already constructed two grammars for the English and Filipino dialect.
# Text sentence I want to translate into the Filipino dialect
text = nltk.word_tokenize("hello my name is aurora what is your name")
# English grammar
eng_grammar = nltk.CFG.fromstring("""
S -> NP DC VP AS DC
AS -> IN VR
NP -> N
DC -> PRP N
VP -> VR N
PRP -> "my" | "your"
VR -> "is"
N -> "hello" | "name" | "aurora"
IN -> "what"
""")
# Filipino dialect grammar
ilo_grammar = nltk.CFG.fromstring("""
S -> NP DC VP AS DC
AS -> IN VR
NP -> N
DC -> N PRP | PRP N
VP -> VR N
CD -> N PRP
PRP -> "ko" | "mo"
VR -> "ti" | "ket"
N -> "kablaaw" | "nagan" | "aurora"
IN -> "anya"
""")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
