Skip to content

Commit

Permalink
[#25] feat: Add Event num & Event List
Browse files Browse the repository at this point in the history
  • Loading branch information
hellouz818 committed May 31, 2022
1 parent f1f6014 commit 399c8ef
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public NoticeOCRDto executeOCR (@RequestPart MultipartFile uploadfile, HttpServl
String en_full = noticeService.englishText(korean); // 영어 추출
List<EventRequestDto> eventWords = noticeService.detectEvent(korean, trans_full, targetLanguage, en_full); //이벤트 추출
List<NoticeSentenceDto> fullText = noticeService.extractSentenceFromEventRequestDto(trans_full, eventWords);
return new NoticeOCRDto(korean, trans_full, fullText);
List<NoticeEventListDto> events = noticeService.extractEventList(fullText);
Integer event_num = events.size();
return new NoticeOCRDto(korean, trans_full, fullText, event_num, events);
}

@RequestMapping(value = "/notice/save", method = RequestMethod.POST)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.answer.notinote.Notice.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDate;

@Getter
@AllArgsConstructor
@Builder
public class NoticeEventListDto {
String title;
LocalDate date;

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ public class NoticeOCRDto {
private String korean;
private String trans_full;
private List<NoticeSentenceDto> fullText;
private Integer event_num;
private List<NoticeEventListDto> events;

public NoticeOCRDto(String korean, String trans_full, List<NoticeSentenceDto> fullText){
public NoticeOCRDto(String korean, String trans_full, List<NoticeSentenceDto> fullText, Integer event_num, List<NoticeEventListDto> events){
this.korean = korean;
this.trans_full = trans_full;
this.fullText = fullText;
this.event_num = event_num;
this.events = events;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@ public List<NoticeSentenceDto> extractSentenceFromEventRequestDto(String text, L
return sentences;
}

public List<NoticeEventListDto> extractEventList(List<NoticeSentenceDto> fullText){
List<NoticeEventListDto> events = new ArrayList<>();

for (int i = 0; i < fullText.size(); i++){
if(fullText.get(i).isHighlight()){
NoticeEventListDto event = new NoticeEventListDto(fullText.get(i).getContent(), fullText.get(i).getDate());
events.add(event);
}
}
return events;
}

public Notice findNoticeById(Long id) {
return noticeRepository.findById(id).orElseThrow(
Expand Down

0 comments on commit 399c8ef

Please sign in to comment.