Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
라면 밀가루 달걀 밥 생선
라면 물 소금 반죽
첨부 봉지면 인기
초밥 라면 밥물 채소 소금
초밥 종류 활어
53 changes: 53 additions & 0 deletions src/search_engine/getSnippet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package search_engine;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.jsoup.Jsoup;
import org.jsoup.parser.Parser;
import org.w3c.dom.Document;


public class getSnippet {


public getSnippet(String txt, String keyword) {
try {
String fileName = "src\\" + txt;
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();

Path filePath = Paths.get(fileName);
InputStream inputStream = Files.newInputStream(filePath);
org.jsoup.nodes.Document readDoc = Jsoup.parse(inputStream, "UTF-8", "", Parser.xmlParser());

String total = readDoc.text();

String data[] = total.split(" ");

System.out.println("<" + txt + " ������ split>");
for(int i =0 ; i < data.length ; i++) {
System.out.println(data[i]);
}

System.out.println("\n<����� �Է� ��>");
System.out.println(keyword + "\n");


} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}


}
11 changes: 10 additions & 1 deletion src/search_engine/kuir.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
public class kuir {
public static void main(String[] args) {

if(args.length == 2) {

if(args.length >= 2) {
if(args[0].equals("-c")) {
makeCollection trigger = new makeCollection(args[1]);
}
Expand All @@ -13,6 +14,12 @@ else if(args[0].equals("-k")) {
else if(args[0].equals("-i")) {
indexer trigger = new indexer(args[1]);
}
else if(args[0].equals("-s")) {
searcher trigger = new searcher(args[3], args[1]);
}
else if(args[0].equals("-f")) {
getSnippet trigger = new getSnippet(args[1], args[3]);
}
else {
System.out.println("\"" + args[0] + "\"�� ���� ���ɾ��Դϴ�.");
}
Expand All @@ -23,5 +30,7 @@ else if(args[0].equals("-i")) {
}



//searcher q = new searcher("��鿡�� ��, �и� ������ �ִ�.", "index.post");
}
}