Skip to content

Commit

Permalink
feature:#194-중국어 학식 추가, 발음 평가 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmj12 committed May 15, 2024
1 parent 9599764 commit 7c6781f
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 40 deletions.
113 changes: 97 additions & 16 deletions front/capstone_front/lib/models/cafeteria_menu_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ class CafeteriaMenuModel {
"Dormitory Cafeteria (Dormitory A, 1st floor)",
"Dormitory Cafeteria (Dormitory Building A, 1st floor)",
];
List<String> cafeteriaZh = [
"Hanwool 餐厅(法律大厦 B1F)",
"学生餐厅(福利大楼 1F)",
"员工餐厅(福利大楼 1F)",
"清香韩国餐厅(法律大厦 5 楼)",
"呈祥中厅(法律大厦 5 楼)",
"宿舍餐厅(宿舍楼 A 座 1 楼)",
];

void addFunc(
var data, List<List<String>> targetList, String type, String addName) {
Expand All @@ -29,6 +37,17 @@ class CafeteriaMenuModel {
int tmp1 = 0;
// []가 2번 이상 나오면 줄바꿈
int tmp2 = 0;
tmpMenu = tmpMenu.replaceAll(\'˜)', '');
tmpMenu = tmpMenu.replaceAll('ï', '');
tmpMenu = tmpMenu.replaceAll('ë', '');
tmpMenu = tmpMenu.replaceAll('\'', '');
tmpMenu = tmpMenu.replaceAll('˜', '');
tmpMenu = tmpMenu.replaceAll('ì', '');
tmpMenu = tmpMenu.replaceAll('š', '');
tmpMenu = tmpMenu.replaceAll('¿', '');
tmpMenu = tmpMenu.replaceAll('¦', '');
tmpMenu = tmpMenu.replaceAll('´', '');
tmpMenu = tmpMenu.replaceAll('¬', '');
for (int i = 0; i < tmpMenu.length; i++) {
if (tmpMenu[i] == '※') {
tmp1 += 1;
Expand All @@ -42,9 +61,6 @@ class CafeteriaMenuModel {
tmpMenu = '${tmpMenu.substring(0, i)}\n${tmpMenu.substring(i)}';
i += 2;
}
} else if (tmpMenu[i] == 'ï') {
tmpMenu = '${tmpMenu.substring(0, i)}${tmpMenu.substring(i + 3)}';
i += 2;
}
if (tmp1 == 2) {
tmp1 = 0;
Expand Down Expand Up @@ -102,14 +118,14 @@ class CafeteriaMenuModel {
void addDataEn(int cafeteriaIndex, var data) {
List<List<String>> tmpList = [];
if (cafeteriaIndex == 0) {
addFunc(data, tmpList, "1Corner\u003Cbr\u003ESNACK1", "Corner1 SNACK1");
addFunc(data, tmpList, "1Corner\u003Cbr\u003ESNACK2", "Corner1 SNACK2");
addFunc(data, tmpList, "2Corner\u003CBR\u003ENOODLE", "Corner2 NOODLE");
addFunc(data, tmpList, "3Corner\u003Cbr\u003ECUTLET", "Corner3 CUTLET");
addFunc(
data, tmpList, "4Corner\u003Cbr\u003ERICE.Oven", "Corner4 RICE.Oven");
addFunc(data, tmpList, "1Corner\u003Cbr\u003ESNACK1", "Corner 1 SNACK1");
addFunc(data, tmpList, "1Corner\u003Cbr\u003ESNACK2", "Corner 1 SNACK2");
addFunc(data, tmpList, "2Corner\u003CBR\u003ENOODLE", "Corner 2 NOODLE");
addFunc(data, tmpList, "3Corner\u003Cbr\u003ECUTLET", "Corner 3 CUTLET");
addFunc(data, tmpList, "4Corner\u003Cbr\u003ERICE.Oven",
"Corner 4 RICE.Oven");
addFunc(data, tmpList, "5Corner\u003Cbr\u003EGUKBAP.Chef",
"Corner5 GUKBAP.Chef");
"Corner 5 GUKBAP.Chef");
} else if (cafeteriaIndex == 1) {
addFunc(data, tmpList, "Good Morning", "Good Morning");
addFunc(data, tmpList, "Breakfast for a Thousand",
Expand All @@ -125,15 +141,15 @@ class CafeteriaMenuModel {
addFunc(data, tmpList, "Dinner I", "Dinner Ⅰ");
addFunc(data, tmpList, "Dinner II", "Dinner Ⅱ");
} else if (cafeteriaIndex == 2) {
addFunc(data, tmpList, "Kitchen1", "Kitchen1");
addFunc(data, tmpList, "Kitchen2", "Kitchen2");
addFunc(data, tmpList, "Kitchen1", "Kitchen 1");
addFunc(data, tmpList, "Kitchen2", "Kitchen 2");
addFunc(data, tmpList, "Today's\u003Cbr\u003ESalad", "Today's Salad");
addFunc(data, tmpList, "Dinner", "Dinner");
} else if (cafeteriaIndex == 3) {
addFunc(data, tmpList, "Menu1", "Menu1");
addFunc(data, tmpList, "Menu2", "Menu2");
addFunc(data, tmpList, "Menu3", "Menu3");
addFunc(data, tmpList, "Menu4", "Menu4");
addFunc(data, tmpList, "Menu1", "Menu 1");
addFunc(data, tmpList, "Menu2", "Menu 2");
addFunc(data, tmpList, "Menu3", "Menu 3");
addFunc(data, tmpList, "Menu4", "Menu 4");
} else if (cafeteriaIndex == 4) {
addFunc(data, tmpList, "PASTA", "PASTA");
addFunc(data, tmpList, "RICE", "RISOTTO");
Expand All @@ -148,9 +164,58 @@ class CafeteriaMenuModel {
cafeteriaMenus.add(tmpList);
}

void addDataZh(int cafeteriaIndex, var data) {
List<List<String>> tmpList = [];
if (cafeteriaIndex == 0) {
addFunc(data, tmpList, "1角\u003Cbr\u003ESNACK1", "Corner 1 SNACK1");
addFunc(data, tmpList, "1角\u003CBR\u003ENOODLE", "Corner 1 SNACK2");
addFunc(data, tmpList, "2角\u003CBR\u003ENOODLE", "Corner 2 NOODLE");
addFunc(data, tmpList, "3角\u003Cbr\u003E小刀", "Corner 3 CUTLET");
addFunc(data, tmpList, "4Corner\u003Cbr\u003ERICE.Oven",
"Corner 4 RICE.Oven");
addFunc(data, tmpList, "5Corner\u003Cbr\u003EGUKBAP.Chef",
"Corner 5 GUKBAP.Chef");
} else if (cafeteriaIndex == 1) {
addFunc(data, tmpList, "天苑早餐", "天苑早餐");
addFunc(data, tmpList, "Breakfast for a Thousand",
"Breakfast for a Thousand");
addFunc(data, tmpList, "伽马\u003Cbr\u003E午餐", "Kama lunch");
addFunc(data, tmpList, "每日膳食\u003Cbr\u003E午餐", "DailyBop Lunch");
addFunc(
data, tmpList, "Vegetarian\u003Cbr\u003EMedium", "Vegiterian Lunch");
addFunc(data, tmpList, "国际大厨\u003Cbr\u003E午餐", "InterChef Lunch");
addFunc(data, tmpList, "面颂\u003Cbr\u003E午餐", "NoodleSong Lunch");
addFunc(data, tmpList, "晚餐Ⅰ", "Dinner Ⅰ");
addFunc(data, tmpList, "晚餐 II", "Dinner Ⅱ");
} else if (cafeteriaIndex == 2) {
addFunc(data, tmpList, "厨房1", "Kitchen 1");
addFunc(data, tmpList, "厨房2", "Kitchen 2");
addFunc(data, tmpList, "今日沙拉", "今日沙拉");
addFunc(data, tmpList, "晚餐", "晚餐");
} else if (cafeteriaIndex == 3) {
addFunc(data, tmpList, "菜单1", "菜单 1");
addFunc(data, tmpList, "菜单2", "菜单 2");
addFunc(data, tmpList, "菜单3", "菜单 3");
addFunc(data, tmpList, "菜单4", "菜单 4");
} else if (cafeteriaIndex == 4) {
addFunc(data, tmpList, "意大利面", "PASTA");
addFunc(data, tmpList, "里索托", "RISOTTO");
addFunc(data, tmpList, "牛排", "STEAK");
} else if (cafeteriaIndex == 5) {
addFunc(data, tmpList, "午餐", "午餐");
cafeteriaMenus.add(tmpList);
tmpList = [];
if (data != null && data["晚餐"] != null) {
tmpList.add(["晚餐", data["晚餐"]["메뉴"], "仅限申请人"]);
}
}
cafeteriaMenus.add(tmpList);
}

CafeteriaMenuModel.fromJson(
List<dynamic> json, String date, String language) {
if (language == 'KO') {
// 한국어
for (int i = 0; i < cafeteriaKo.length; i++) {
bool dataAdded = false;
for (int j = 0; j < json.length; j++) {
Expand All @@ -165,6 +230,7 @@ class CafeteriaMenuModel {
}
}
} else if (language == 'EN-US') {
// 영어
for (int i = 0; i < cafeteriaEn.length; i++) {
bool dataAdded = false;
for (int j = 0; j < json.length; j++) {
Expand All @@ -178,6 +244,21 @@ class CafeteriaMenuModel {
cafeteriaMenus.add([]);
}
}
} else {
// 중국어
for (int i = 0; i < cafeteriaZh.length; i++) {
bool dataAdded = false;
for (int j = 0; j < json.length; j++) {
if (json[j][cafeteriaZh[i]] != null) {
addDataZh(i, json[j][cafeteriaZh[i]][date]);
dataAdded = true;
break;
}
}
if (!dataAdded) {
cafeteriaMenus.add([]);
}
}
}
}
}
50 changes: 28 additions & 22 deletions front/capstone_front/lib/screens/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,20 @@ class _HomeScreenState extends State<HomeScreen>
fontSize: 24,
fontWeight: FontWeight.w700,
)),
IconButton(
icon: const Icon(Icons.add),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const NoticeScreen(),
),
);
},
Transform.translate(
offset: Offset(10, -10),
child: IconButton(
icon: const Icon(Icons.add),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const NoticeScreen(),
),
);
},
),
),
],
),
Expand Down Expand Up @@ -240,17 +243,20 @@ class _HomeScreenState extends State<HomeScreen>
fontSize: 24,
fontWeight: FontWeight.w700,
)),
IconButton(
icon: const Icon(Icons.add),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const CafeteriaMenuScreen(),
),
);
},
Transform.translate(
offset: Offset(10, -10),
child: IconButton(
icon: const Icon(Icons.add),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const CafeteriaMenuScreen(),
),
);
},
),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Map<String, String> userInfo = {
'department': '',
'country': '',
};
int selectedPageIndex = 0;

Future<String> signup() async {
Map<String, dynamic> userData = {
Expand Down
16 changes: 15 additions & 1 deletion front/capstone_front/lib/services/speech_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:capstone_front/models/speech_model.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:http_parser/http_parser.dart';
import 'package:path_provider/path_provider.dart';

Future<SpeechModel> getSpeechResult(String filePath, String sentence) async {
Expand All @@ -15,6 +16,8 @@ Future<SpeechModel> getSpeechResult(String filePath, String sentence) async {
// Multipart request 생성
var request = http.MultipartRequest('POST', url);

request.headers['Content-Type'] = 'multipart/form-data';

var file = File.fromUri(Uri.parse(filePath));
// 오디오 파일 추가
var audioStream = http.ByteStream(file.openRead());
Expand All @@ -28,7 +31,18 @@ Future<SpeechModel> getSpeechResult(String filePath, String sentence) async {
var data = {
'context': sentence,
};
request.fields.addAll(data);

// JSON 데이터를 UTF-8로 인코딩하여 바이트로 변환 후 MultipartFile로 추가
List<int> jsonData = utf8.encode(jsonEncode(data));
request.files.add(http.MultipartFile.fromBytes(
'context',
jsonData,
contentType: MediaType(
'application',
'json',
{'charset': 'utf-8'},
),
));

// 요청 보내기
var streamResponse = await request.send();
Expand Down

0 comments on commit 7c6781f

Please sign in to comment.