This commit is contained in:
Chen Li
2025-08-12 13:36:42 +08:00
parent 8191bef32e
commit 130755f9e1
47 changed files with 3728 additions and 761 deletions

View File

@@ -0,0 +1,27 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
class TextClassificationService {
Future<int> classifyText(String text) async {
try {
final uri = Uri.parse('http://143.64.185.20:18606/classify');
final response = await http.post(
uri,
headers: {'Content-Type': 'application/json'},
body: json.encode({'text': text}),
);
if (response.statusCode == 200) {
return json.decode(response.body)['category'];
} else {
print(
'Classification failed: ${response.statusCode}, ${response.body}');
return -1;
}
} catch (e) {
print('Error during text classification: $e');
return -1;
}
}
}