generateWord method
generateWord is a class for making HTTP requests to the ZEMBEREK API using the sample
and morphemes
parameter.
Implementation
Future<List<dynamic>> generateWord(String sample, String morphemes) async {
try {
var url = (Uri.parse('$ipAdresi:$port/generate_word'));
var res =
await http.post(url, body: {'word': sample, 'morphemes': morphemes});
var body = res.body;
var decoded = jsonDecode(body);
var json = decoded[0];
var cevap = json["surface"];
return cevap;
} catch (e) {
var hata = e.toString();
if (hata.contains('NoSuchMethodError')) {
var sozlukanlam = "Probably System Error. Open an issue on GitHub.";
print(sozlukanlam);
return [];
} else {
var sozlukanlam = e.toString();
print(sozlukanlam);
return [];
}
}
}