-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: 구글 번역 api를 활용하여 채팅 메시지 번역 #6
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니다! 잘짜여진 코드라고 생각합니다!
아호코라 알고리즘, STOMP 메시징, Facade 패턴 등 다양한 시도를 하신 내용들을 코드 리뷰 하면서 좋은 공부가 되었던 것 같습니다ㅎㅎ
비동기 부분은 아직 잘 이해하지 못해서, 어떤 흐름인지 미팅에서 직접 듣고 싶습니다.
수고하셨습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
term 관련된 내용들을 domain에 포함시키지 않고 common에 포함시킨 이유가 따로 있나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 개인적으로 궁금한 내용인데,
Chat 에 대해서는 Service 레이어를 사용하지 않고, Facade를 거치게 하신 이유가 있나요?
ChatService
에 과도한 책임을 지지 않게 하시기 위한 고려인지 궁금합니다!
private Map<String, String> termsWithMeaning; | ||
|
||
public TermManager() { | ||
Set<String> terms = TermLoader.loadTermsOnly(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trie에 단어들을 적재하는 과정을 의존성주입 시점에만 작동하도록 하여 최적화를 진행하신 부분
정말 좋은것 같습니다.
Collection<Emit> emits = this.trie.parseText(chat); | ||
Set<String> terms = emits.stream() | ||
.map(Emit::getKeyword) | ||
.collect(Collectors.toSet()); | ||
Set<String> finalTerms = new HashSet<>(terms); | ||
|
||
this.removeDuplicatedWord(terms, finalTerms); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chat
에서 타겟 단어들 emits
를 꺼낸다음, Collectors.toSet()
으로 중복을 제거하는거 같은데,
그 결과물인 finalTerms
과 terms
를 다시 비교해서 중복을 제거하는 이유가 무엇인가요?
제가 로직을 잘못 이해했다면 설명 부탁드립니다ㅠ
} | ||
|
||
@Async("threadPoolTaskExecutor") | ||
public CompletableFuture<String> translate(final String text, final List<TermDataDto> terms, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translate API 를 호출하는 호출부는 termManger
에서 별도의 클래스로 분리하는게 추후 API 교체나, 유지보수에 용이하지 않을까 싶습니다!
messagingTemplate.convertAndSend(CHAT_SUB_URL + teamId, | ||
ChatConverter.toChatResponseDto(name, chat, result.getTerms())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Controller -> ChatFacade
로 이어지는 계층구조를 보이고 있는데,
ChatFacade
에서 비즈니스 로직만을 담당하고 있는 것이 아니라, 채팅 메시지를 직접 보내는 책임까지 가지고 있는 것이 조금 부담스러울 수 있다는 생각이 드는 것 같습니다!
messagingTemplate
을 주입받는 별도의 service를 분리해서 ( ex) MessageSendService
) 메서드단위로 메시지 전송 로직을 분리하는 것은 어떨까요?
MessageSendService messageService
messageService.sendTeamDataMessage(final Long userId, TeamListDto teamListDto)
messageService.sendTranslatedMessage(final Long teamId, final Long userId, TranslatedTextResponseDto translatedTextResponseDto)
추가된 기능
1. 구글 번역 api를 이용해 채팅 메시지 번역
2. 따라서 문장 번역을 비동기처리하여 영상처럼 번역 처리가 완료되면 버튼을 눌러(?) 번역 문장을 확인할 수 있게 한다
3. 번역 사용 가능 언어는 /term 디렉토리에 enum으로 관리
남은 기능
1. 현장 용어에 대한 번역 처리
배포 관련
1. google-credentials.json 파일을 resources 위치에 저장해야 한다. (노션에 올려두겠습니다.)
2. yml 파일에 json 파일 경로 설정�
2025-03-02.10.40.40.mov
2025-03-02.10.42.49.mov