Skip to content
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

Merged
merged 6 commits into from
Mar 6, 2025

Conversation

Hyun0828
Copy link
Collaborator

@Hyun0828 Hyun0828 commented Mar 1, 2025

추가된 기능

1. 구글 번역 api를 이용해 채팅 메시지 번역

  • 그러나 "가다 와꾸 제대로 맞추고 공구리 타설 준비해! 고야 옆에 구루마 놔두고 나라시 끝내면 보고해! 겐나와로 정확히 재고 가네가다 작업 시작해!" 이정도 길이의 문장도 1초정도 딜레이가 발생하는 문제가 존재.
  • DeepL API도 있으나 번역 가능한 언어 종류 수가 한정적

2. 따라서 문장 번역을 비동기처리하여 영상처럼 번역 처리가 완료되면 버튼을 눌러(?) 번역 문장을 확인할 수 있게 한다

3. 번역 사용 가능 언어는 /term 디렉토리에 enum으로 관리

남은 기능

1. 현장 용어에 대한 번역 처리

배포 관련

1. google-credentials.json 파일을 resources 위치에 저장해야 한다. (노션에 올려두겠습니다.)
2. yml 파일에 json 파일 경로 설정�

image
2025-03-02.10.40.40.mov
2025-03-02.10.42.49.mov

@Hyun0828 Hyun0828 requested review from bingle625 and meanyong March 1, 2025 14:05
@Hyun0828 Hyun0828 self-assigned this Mar 1, 2025
@Hyun0828 Hyun0828 added the enhancement New feature or request label Mar 2, 2025
Copy link
Collaborator

@bingle625 bingle625 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다! 잘짜여진 코드라고 생각합니다!

아호코라 알고리즘, STOMP 메시징, Facade 패턴 등 다양한 시도를 하신 내용들을 코드 리뷰 하면서 좋은 공부가 되었던 것 같습니다ㅎㅎ
비동기 부분은 아직 잘 이해하지 못해서, 어떤 흐름인지 미팅에서 직접 듣고 싶습니다.

수고하셨습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

term 관련된 내용들을 domain에 포함시키지 않고 common에 포함시킨 이유가 따로 있나요?

Copy link
Collaborator

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();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trie에 단어들을 적재하는 과정을 의존성주입 시점에만 작동하도록 하여 최적화를 진행하신 부분
정말 좋은것 같습니다.

Comment on lines +50 to +56
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chat 에서 타겟 단어들 emits 를 꺼낸다음, Collectors.toSet() 으로 중복을 제거하는거 같은데,
그 결과물인 finalTermsterms 를 다시 비교해서 중복을 제거하는 이유가 무엇인가요?
제가 로직을 잘못 이해했다면 설명 부탁드립니다ㅠ

}

@Async("threadPoolTaskExecutor")
public CompletableFuture<String> translate(final String text, final List<TermDataDto> terms,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

translate API 를 호출하는 호출부는 termManger 에서 별도의 클래스로 분리하는게 추후 API 교체나, 유지보수에 용이하지 않을까 싶습니다!

Comment on lines 87 to 88
messagingTemplate.convertAndSend(CHAT_SUB_URL + teamId,
ChatConverter.toChatResponseDto(name, chat, result.getTerms()));
Copy link
Collaborator

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)

@Hyun0828 Hyun0828 merged commit 2f0d1d9 into dev Mar 6, 2025
@Hyun0828 Hyun0828 deleted the feat/chat branch March 6, 2025 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants