From ecf9e0bb1cf5911fb6ec671e159845ebed2b7478 Mon Sep 17 00:00:00 2001 From: SalkCoding Date: Wed, 18 Dec 2024 22:18:37 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EC=9E=AC=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ohlottery/service/LotteryAINumberService.java | 7 ++++++- .../java/com/ohlottery/service/LotteryAIPriceService.java | 6 ++++-- src/main/resources/{AI => ai}/lottery_prediction.py | 0 .../resources/{AI => ai}/lottery_probability_predictor.py | 0 src/main/resources/{AI => ai}/oh-lottery_main.csv | 0 5 files changed, 10 insertions(+), 3 deletions(-) rename src/main/resources/{AI => ai}/lottery_prediction.py (100%) rename src/main/resources/{AI => ai}/lottery_probability_predictor.py (100%) rename src/main/resources/{AI => ai}/oh-lottery_main.csv (100%) diff --git a/src/main/java/com/ohlottery/service/LotteryAINumberService.java b/src/main/java/com/ohlottery/service/LotteryAINumberService.java index 6cff255..efe8c5c 100644 --- a/src/main/java/com/ohlottery/service/LotteryAINumberService.java +++ b/src/main/java/com/ohlottery/service/LotteryAINumberService.java @@ -6,14 +6,19 @@ import java.io.BufferedReader; import java.io.InputStreamReader; +import java.net.URL; @Service public class LotteryAINumberService { + + private final URL scriptURL + = getClass().getClassLoader().getResource("ai/lottery_probability_predictor.py"); + public JsonNode getAINumberResults() { JsonNode aiNumberResults = null; try { - ProcessBuilder processBuilder = new ProcessBuilder("python3", "lottery_probability_predictor.py"); + ProcessBuilder processBuilder = new ProcessBuilder("python3", scriptURL.getPath()); Process process = processBuilder.start(); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); diff --git a/src/main/java/com/ohlottery/service/LotteryAIPriceService.java b/src/main/java/com/ohlottery/service/LotteryAIPriceService.java index ad4f39f..decf047 100644 --- a/src/main/java/com/ohlottery/service/LotteryAIPriceService.java +++ b/src/main/java/com/ohlottery/service/LotteryAIPriceService.java @@ -5,17 +5,19 @@ import java.io.BufferedReader; import java.io.InputStreamReader; +import java.net.URL; @Service @RequiredArgsConstructor public class LotteryAIPriceService { - private final String scriptPath = getClass().getResource("/AI/lottery_prediction.py").getPath(); + private final URL scriptURL + = getClass().getClassLoader().getResource("ai/lottery_prediction.py"); public String executePythonPredictionScript() { try { // Python 스크립트 실행 - ProcessBuilder processBuilder = new ProcessBuilder("python3", scriptPath); + ProcessBuilder processBuilder = new ProcessBuilder("python3", scriptURL.getPath()); processBuilder.redirectErrorStream(true); Process process = processBuilder.start(); diff --git a/src/main/resources/AI/lottery_prediction.py b/src/main/resources/ai/lottery_prediction.py similarity index 100% rename from src/main/resources/AI/lottery_prediction.py rename to src/main/resources/ai/lottery_prediction.py diff --git a/src/main/resources/AI/lottery_probability_predictor.py b/src/main/resources/ai/lottery_probability_predictor.py similarity index 100% rename from src/main/resources/AI/lottery_probability_predictor.py rename to src/main/resources/ai/lottery_probability_predictor.py diff --git a/src/main/resources/AI/oh-lottery_main.csv b/src/main/resources/ai/oh-lottery_main.csv similarity index 100% rename from src/main/resources/AI/oh-lottery_main.csv rename to src/main/resources/ai/oh-lottery_main.csv