|
|
@ -1,13 +1,20 @@
|
|
|
|
package com.tz.platform.repository;
|
|
|
|
package com.tz.platform.repository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
import com.tz.platform.common.core.bo.Answer;
|
|
|
|
import com.tz.platform.common.core.bo.Answer;
|
|
|
|
import com.tz.platform.entity.Question;
|
|
|
|
import com.tz.platform.entity.Question;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
|
|
|
import sun.misc.Regexp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@SpringBootTest
|
|
|
|
@SpringBootTest
|
|
|
@ -40,4 +47,37 @@ public class QuestionDaoTest {
|
|
|
|
Question question = questionDao.getById(1L);
|
|
|
|
Question question = questionDao.getById(1L);
|
|
|
|
System.out.println(question.getAnswerList().size());
|
|
|
|
System.out.println(question.getAnswerList().size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void spiderQuestionTest(){
|
|
|
|
|
|
|
|
File file = new File("/Volumes/Lexar/tianze/testQuestion.txt");
|
|
|
|
|
|
|
|
String content = FileUtil.readString(file, Charset.defaultCharset());
|
|
|
|
|
|
|
|
// System.out.println(content);
|
|
|
|
|
|
|
|
String regex ="\\d+[\\.|、](.*)\\(.*?([A-Z]+).*?\\)";
|
|
|
|
|
|
|
|
String regexAnwser = "([A-Z])[\\s|\\.|、]{0,1}(\\S+.*?)";
|
|
|
|
|
|
|
|
Pattern pattern1 = Pattern.compile(regex);
|
|
|
|
|
|
|
|
Pattern pattern2 = Pattern.compile(regexAnwser);
|
|
|
|
|
|
|
|
Matcher matcher = pattern1.matcher(content);
|
|
|
|
|
|
|
|
String[] anwserArray = pattern1.split(content);
|
|
|
|
|
|
|
|
System.out.println(anwserArray.length);
|
|
|
|
|
|
|
|
pattern1.splitAsStream(content).forEach(s -> {
|
|
|
|
|
|
|
|
Matcher m = pattern2.matcher(s);
|
|
|
|
|
|
|
|
if (m.find()){
|
|
|
|
|
|
|
|
System.out.println(m.group(0));
|
|
|
|
|
|
|
|
System.out.println(m.group(2));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// int i = 0;
|
|
|
|
|
|
|
|
// while (matcher.find()){
|
|
|
|
|
|
|
|
// int len = matcher.group(0).length();
|
|
|
|
|
|
|
|
// int startIndex = content.indexOf(matcher.group(0));
|
|
|
|
|
|
|
|
// System.out.println(matcher.group(0));
|
|
|
|
|
|
|
|
// System.out.println(matcher.group(1));
|
|
|
|
|
|
|
|
// System.out.println(matcher.group(2));
|
|
|
|
|
|
|
|
// String stem = matcher.group(1);
|
|
|
|
|
|
|
|
// String anwserIds = matcher.group(2);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// i++;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|