java 정규식 관련 질문드립니다.
조회수 1313회
java로 "(한글,한글자음,영어,숫자,특수문자) + / + 품사태그" 이런 형식만 추출을 하려고 하는데요
다른건 다 문제가 없는데 한글 자음이 추출이 안되서 질문드립니다. 혹시나 해서 유니코드로 바꿔서 추출하려고 했는데 그것도 마땅치가 않네요.. 도와주시면 감사하겠습니다!
package text;
import org.jetbrains.annotations.NotNull;
import java.io.*;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class makeWord2Vec {
public static void main(String[] args) throws IOException {
String path="C:\\Users\\skarl\\Desktop\\형태분석 말뭉치\\전체";
File dirFile=new File(path);
File []fileList=dirFile.listFiles();
for(File tempFile : fileList) {
if(tempFile.isFile()) {
String name=tempFile.getName();
BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\skarl\\Desktop\\형태분석 말뭉치\\전체\\"+name));
BufferedWriter fw = new BufferedWriter(new FileWriter("C:\\Users\\skarl\\Desktop\\전체.txt",true));
while (true) {
String line = br.readLine();
if (line == null) break;
if(line.contains("<")||line.contains(">")) line = "";
//fw.write(line);
//if(line!="")fw.write("\r\n");
String matchLine = null;
Pattern regex=Pattern.compile("([a-zA-Z0-9!@#$%^&*()_+/.,'?~…]|[\"]|[가-힣ㄱ-ㅎㅏ-ㅣ])+\\/+[A-Z]+");
Matcher regexMatcher=regex.matcher(line);
while(regexMatcher.find()) {
matchLine = regexMatcher.group();
fw.write(matchLine + " ");
}
}
br.close();
fw.close();
}
}
}
}
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력