두 가지 방법을 결합하고 싶습니다. 내 문서 파서, frequencyCounter 및 parseFiles thsi 코드에서 오류가 발생합니다.이 Java 코드에서 Java의 두 가지 방법을 함께 사용하면
나는 모든 frequencyCounter가 parseFiles 내에서 실행되어야하는 함수 여야하고 관련 정보는 doSomething에 전달되어야하는 파일의 내용에 대해 걱정할 필요가 없으므로 인쇄 할 내용을 알고 있어야합니다.
지금은 단지이 두 가지 방법을 넣어하는 방법을 엉망으로 유지, 약간의 조언
이 내 주요 클래스를 적어주세요 해요 :
public class Yolo {
public static void frodo() throws Exception {
int n; // number of keywords
Scanner sc = new Scanner(System.in);
System.out.println("number of keywords : ");
n = sc.nextInt();
for (int j = 0; j <= n; j++) {
Scanner scan = new Scanner(System.in);
System.out.println("give the testword : ");
String testWord = scan.next();
System.out.println(testWord);
File document = new File("path//to//doc1.txt");
boolean check = true;
try {
FileInputStream fstream = new FileInputStream(document);
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
String strLine;
strLine = br.readLine();
// Read File Line By Line
int count = 0;
while ((strLine = br.readLine()) != null) {
// check to see whether testWord occurs at least once in the
// line of text
check = strLine.toLowerCase().contains(testWord.toLowerCase());
if (check) {
// get the line
String[] lineWords = strLine.split("\\s+");
// System.out.println(strLine);
count++;
}
}
System.out.println(testWord + "frequency: " + count);
br.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
CosineSimilarity() 및 TfIdf()는 어디에 있습니까? – Nuwanda