Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHATBOT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,17 @@ let response3 = await chatManager.sendMessage("2 days");
## 🌍 언어별 Fallback 전략

- **지원 언어**: ko (한국어), en (영어), ja (일본어), zh (중국어)
- **완전 지원**: 모든 4개 언어가 데이터베이스에서 완전 지원됨
- **Fallback 규칙**:
- ja/zh → en (일본어/중국어는 영어로 fallback)
- 각 언어별 데이터가 누락된 경우에만 다음 순서로 fallback:
- ja (일본어) → en (영어) → ko (한국어)
- zh (중국어) → en (영어) → ko (한국어)
- en (영어) → ko (한국어)
- 기타 모든 언어 → ko (한국어 기본값)
- **데이터 품질**:
- 모든 Place 엔티티에 4개 언어 완전 지원 (nameKo/En/Jp/Ch, descriptionKo/En/Jp/Ch, addressKo/En/Jp/Ch)
- RAG 시스템에서 언어별 맞춤 검색 및 응답 생성
- 챗봇 메시지 템플릿 4개 언어 완전 지원
- **언어 코드 변환**:
- chatbot 도메인: "ja", "zh" 사용
- Tour API 호출 시: "J", "C"로 자동 변환
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ public String getPlaceName(com.mey.backend.domain.place.entity.Place place, Stri
return switch (language) {
case "ko" -> place.getNameKo();
case "en" -> place.getNameEn() != null ? place.getNameEn() : place.getNameKo();
case "ja", "zh" -> {
// 일본어/중국어는 아직 지원되지 않으므로 영어로 fallback
String englishName = place.getNameEn();
yield englishName != null ? englishName : place.getNameKo();
}
case "ja" -> place.getNameJp() != null ? place.getNameJp() :
(place.getNameEn() != null ? place.getNameEn() : place.getNameKo());
case "zh" -> place.getNameCh() != null ? place.getNameCh() :
(place.getNameEn() != null ? place.getNameEn() : place.getNameKo());
default -> place.getNameKo();
};
}
Expand All @@ -65,21 +64,27 @@ public String getPlaceDescription(com.mey.backend.domain.place.entity.Place plac
return switch (language) {
case "ko" -> place.getDescriptionKo();
case "en" -> place.getDescriptionEn() != null ? place.getDescriptionEn() : place.getDescriptionKo();
case "ja", "zh" -> {
// 일본어/중국어는 아직 지원되지 않으므로 영어로 fallback
String englishDesc = place.getDescriptionEn();
yield englishDesc != null ? englishDesc : place.getDescriptionKo();
}
case "ja" -> place.getDescriptionJp() != null ? place.getDescriptionJp() :
(place.getDescriptionEn() != null ? place.getDescriptionEn() : place.getDescriptionKo());
case "zh" -> place.getDescriptionCh() != null ? place.getDescriptionCh() :
(place.getDescriptionEn() != null ? place.getDescriptionEn() : place.getDescriptionKo());
default -> place.getDescriptionKo();
};
}

/**
* Place 데이터에서 해당 언어의 주소를 가져옵니다.
* 현재는 한국어 주소만 지원하므로 모든 언어에 대해 한국어 주소를 반환
*/
public String getPlaceAddress(com.mey.backend.domain.place.entity.Place place, String language) {
return place.getAddressKo(); // 현재는 한국어 주소만 지원
return switch (language) {
case "ko" -> place.getAddressKo();
case "en" -> place.getAddressEn() != null ? place.getAddressEn() : place.getAddressKo();
case "ja" -> place.getAddressJp() != null ? place.getAddressJp() :
(place.getAddressEn() != null ? place.getAddressEn() : place.getAddressKo());
case "zh" -> place.getAddressCh() != null ? place.getAddressCh() :
(place.getAddressEn() != null ? place.getAddressEn() : place.getAddressKo());
default -> place.getAddressKo();
};
}

/**
Expand Down Expand Up @@ -123,9 +128,9 @@ public boolean isLanguageSupported(String language) {

/**
* 데이터베이스에서 완전히 지원되는 언어인지 확인합니다.
* (현재는 한국어와 영어만 완전 지원)
* (현재는 한국어, 영어, 일본어, 중국어 모두 완전 지원)
*/
public boolean isLanguageFullySupported(String language) {
return "ko".equals(language) || "en".equals(language);
return SUPPORTED_LANGUAGES.contains(language);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
public class RagService {
private final InMemoryDocumentVectorStore vectorStore;
private final OpenAiApi openAiApi;
private final LanguageService languageService;

/**
* 질의와 관련된 문서를 검색합니다.
Expand Down Expand Up @@ -287,6 +288,11 @@ private String createPlaceContext(com.mey.backend.domain.place.entity.Place plac
language = "ko";
}

// LanguageService를 사용하여 다국어 데이터 가져오기
String placeName = languageService.getPlaceName(place, language);
String placeDescription = languageService.getPlaceDescription(place, language);
String placeAddress = languageService.getPlaceAddress(place, language);

return switch (language) {
case "ko" -> String.format("""
장소명: %s
Expand All @@ -297,9 +303,9 @@ private String createPlaceContext(com.mey.backend.domain.place.entity.Place plac
비용정보: %s
연락처: %s
""",
place.getNameKo(),
place.getDescriptionKo(),
place.getAddressKo(),
placeName,
placeDescription,
placeAddress,
place.getRegion().getNameKo(),
String.join(", ", place.getThemes()),
place.getCostInfo(),
Expand All @@ -314,9 +320,9 @@ private String createPlaceContext(com.mey.backend.domain.place.entity.Place plac
Cost Info: %s
Contact: %s
""",
place.getNameEn() != null ? place.getNameEn() : place.getNameKo(),
place.getDescriptionEn() != null ? place.getDescriptionEn() : place.getDescriptionKo(),
place.getAddressKo(), // Address is only available in Korean
placeName,
placeDescription,
placeAddress,
place.getRegion().getNameKo(),
String.join(", ", place.getThemes()),
place.getCostInfo(),
Expand All @@ -331,9 +337,9 @@ private String createPlaceContext(com.mey.backend.domain.place.entity.Place plac
費用情報: %s
連絡先: %s
""",
place.getNameEn() != null ? place.getNameEn() : place.getNameKo(), // Fallback to English
place.getDescriptionEn() != null ? place.getDescriptionEn() : place.getDescriptionKo(),
place.getAddressKo(),
placeName,
placeDescription,
placeAddress,
place.getRegion().getNameKo(),
String.join(", ", place.getThemes()),
place.getCostInfo(),
Expand All @@ -348,9 +354,9 @@ private String createPlaceContext(com.mey.backend.domain.place.entity.Place plac
费用信息: %s
联系方式: %s
""",
place.getNameEn() != null ? place.getNameEn() : place.getNameKo(), // Fallback to English
place.getDescriptionEn() != null ? place.getDescriptionEn() : place.getDescriptionKo(),
place.getAddressKo(),
placeName,
placeDescription,
placeAddress,
place.getRegion().getNameKo(),
String.join(", ", place.getThemes()),
place.getCostInfo(),
Expand Down
37 changes: 18 additions & 19 deletions src/main/java/com/mey/backend/domain/place/entity/Place.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,44 @@ public class Place extends BaseTimeEntity {
@Column(nullable = false)
private String nameEn;

// @Column(nullable = false)
// private String nameJp;
//
// @Column(nullable = false)
// private String nameCh;
@Column(nullable = false)
private String nameJp;

@Column(nullable = false)
private String nameCh;

@Column(nullable = false, columnDefinition = "TEXT")
private String descriptionKo;

@Column(nullable = false, columnDefinition = "TEXT")
private String descriptionEn;

@Column(nullable = false, columnDefinition = "TEXT")
private String descriptionJp;

// @Column(nullable = false, columnDefinition = "TEXT")
// private String descriptionJp;
//
// @Column(nullable = false, columnDefinition = "TEXT")
// private String descriptionCh;
@Column(nullable = false, columnDefinition = "TEXT")
private String descriptionCh;

@Column(nullable = false)
private Double longitude;

@Column(nullable = false)
private Double latitude;

@Column(nullable = false)
@Column(nullable = false, columnDefinition = "TEXT")
private String imageUrl;

@Column(nullable = false)
private String addressKo;

// @Column(nullable = false)
// private String addressEn;
//
// @Column(nullable = false)
// private String addressJp;
//
// @Column(nullable = false)
// private String addressCh;
@Column(nullable = false)
private String addressEn;

@Column(nullable = false)
private String addressJp;

@Column(nullable = false)
private String addressCh;

private String contactInfo;

Expand Down
Loading