diff --git a/.gitignore b/.gitignore
index f3dab4a..3974f8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,4 @@ buildNumber.properties
# application.yml
src/main/resources/application.yml
+src/test/resources/application.yml
diff --git a/pom.xml b/pom.xml
index 9058ef6..caa6697 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
1.0.3-SNAPSHOT
pasteme-algorithm
- 1.0.4
+ 1.0.5
PasteMe Algorithm
PasteMe Algorithm Collection
diff --git a/src/main/java/cn/pasteme/algorithm/http/impl/HttpClientImpl.java b/src/main/java/cn/pasteme/algorithm/http/HttpClientImpl.java
similarity index 95%
rename from src/main/java/cn/pasteme/algorithm/http/impl/HttpClientImpl.java
rename to src/main/java/cn/pasteme/algorithm/http/HttpClientImpl.java
index 02a75bc..e2a9fde 100644
--- a/src/main/java/cn/pasteme/algorithm/http/impl/HttpClientImpl.java
+++ b/src/main/java/cn/pasteme/algorithm/http/HttpClientImpl.java
@@ -1,4 +1,4 @@
-package cn.pasteme.algorithm.http.impl;
+package cn.pasteme.algorithm.http;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
@@ -46,7 +46,7 @@ public JSONObject post(String url, JSONObject json) throws IOException {
@Override
public JSONObject post(String url, String json) throws IOException {
HttpPost request = new HttpPost(url);
- StringEntity params = new StringEntity(json);
+ StringEntity params = new StringEntity(json, "UTF-8");
request.addHeader("Content-Type", "application/json");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
diff --git a/src/main/java/cn/pasteme/algorithm/model/TextRiskClassification.java b/src/main/java/cn/pasteme/algorithm/model/TextRiskClassification.java
index 47b852a..d5e8e2a 100644
--- a/src/main/java/cn/pasteme/algorithm/model/TextRiskClassification.java
+++ b/src/main/java/cn/pasteme/algorithm/model/TextRiskClassification.java
@@ -13,9 +13,9 @@ public interface TextRiskClassification {
/**
* 调用模型
*
- * @param jsonString 模型参数
+ * @param content 文本内容
* @return 模型的推理结果,0 代表 Normal,1 代表 Risk
* @throws IOException HTTP 请求出错
*/
- int inference(String jsonString) throws IOException;
+ int inference(String content) throws IOException;
}
diff --git a/src/main/java/cn/pasteme/algorithm/model/impl/TextRiskClassificationImpl.java b/src/main/java/cn/pasteme/algorithm/model/TextRiskClassificationImpl.java
similarity index 91%
rename from src/main/java/cn/pasteme/algorithm/model/impl/TextRiskClassificationImpl.java
rename to src/main/java/cn/pasteme/algorithm/model/TextRiskClassificationImpl.java
index dc345a2..699963f 100644
--- a/src/main/java/cn/pasteme/algorithm/model/impl/TextRiskClassificationImpl.java
+++ b/src/main/java/cn/pasteme/algorithm/model/TextRiskClassificationImpl.java
@@ -1,8 +1,6 @@
-package cn.pasteme.algorithm.model.impl;
+package cn.pasteme.algorithm.model;
import cn.pasteme.algorithm.http.HttpClient;
-import cn.pasteme.algorithm.http.impl.HttpClientImpl;
-import cn.pasteme.algorithm.model.TextRiskClassification;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/src/test/java/cn/pasteme/algorithm/http/impl/HttpClientImplTest.java b/src/test/java/cn/pasteme/algorithm/http/HttpClientImplTest.java
similarity index 81%
rename from src/test/java/cn/pasteme/algorithm/http/impl/HttpClientImplTest.java
rename to src/test/java/cn/pasteme/algorithm/http/HttpClientImplTest.java
index 0c0daaf..7dbace2 100644
--- a/src/test/java/cn/pasteme/algorithm/http/impl/HttpClientImplTest.java
+++ b/src/test/java/cn/pasteme/algorithm/http/HttpClientImplTest.java
@@ -1,10 +1,12 @@
-package cn.pasteme.algorithm.http.impl;
+package cn.pasteme.algorithm.http;
import cn.pasteme.algorithm.http.HttpClient;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -13,9 +15,12 @@
@RunWith(SpringRunner.class)
public class HttpClientImplTest {
+ @Autowired
+ private HttpClient httpClient;
+
@Test
+ @Ignore
public void testPost() {
- HttpClient httpClient = new HttpClientImpl();
try {
JSONObject jsonResponse = httpClient.post(
"http://predict.pasteme.lucien.ink/v1/models/PasteMeRIM:predict",
diff --git a/src/test/java/cn/pasteme/algorithm/model/TextRiskClassificationImplTest.java b/src/test/java/cn/pasteme/algorithm/model/TextRiskClassificationImplTest.java
new file mode 100644
index 0000000..a51a0dd
--- /dev/null
+++ b/src/test/java/cn/pasteme/algorithm/model/TextRiskClassificationImplTest.java
@@ -0,0 +1,29 @@
+package cn.pasteme.algorithm.model;
+
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@Slf4j
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
+@RunWith(SpringRunner.class)
+public class TextRiskClassificationImplTest {
+
+ @Autowired
+ private TextRiskClassification textRiskClassification;
+
+ @Test
+ @Ignore
+ public void inference() {
+ String content = "你好,世界!";
+ try {
+ int result = textRiskClassification.inference(content);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file