From 1518045fb6b0527cd581f202666d645371cbdf78 Mon Sep 17 00:00:00 2001 From: inulee Date: Tue, 20 Apr 2021 18:36:11 +0900 Subject: [PATCH 1/2] fitst --- src/input.txt | 5 +++++ src/search_engine/getSnippet.java | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/input.txt create mode 100644 src/search_engine/getSnippet.java diff --git a/src/input.txt b/src/input.txt new file mode 100644 index 0000000..32d2570 --- /dev/null +++ b/src/input.txt @@ -0,0 +1,5 @@ +라면 밀가루 달걀 밥 생선 +라면 물 소금 반죽 +첨부 봉지면 인기 +초밥 라면 밥물 채소 소금 +초밥 종류 활어 \ No newline at end of file diff --git a/src/search_engine/getSnippet.java b/src/search_engine/getSnippet.java new file mode 100644 index 0000000..fa4bb87 --- /dev/null +++ b/src/search_engine/getSnippet.java @@ -0,0 +1,11 @@ +package search_engine; + +public class getSnippet { + + + public getSnippet(String txt, String keyword) { + + } + + +} \ No newline at end of file From 8f3214f12369dcaba564ef347780c924c73e5ef1 Mon Sep 17 00:00:00 2001 From: inulee Date: Tue, 20 Apr 2021 18:57:04 +0900 Subject: [PATCH 2/2] =?UTF-8?q?args=EC=9D=BD=EA=B8=B0,=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=9D=BD=EA=B8=B0,=20=EA=B3=B5=EB=B0=B1?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20split,=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5=20=EA=B0=92=20=EB=B0=9B=EA=B8=B0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/search_engine/getSnippet.java | 44 ++++++++++++++++++++++++++++++- src/search_engine/kuir.java | 11 +++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/search_engine/getSnippet.java b/src/search_engine/getSnippet.java index fa4bb87..6bdfbe2 100644 --- a/src/search_engine/getSnippet.java +++ b/src/search_engine/getSnippet.java @@ -1,10 +1,52 @@ 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(); + } + } diff --git a/src/search_engine/kuir.java b/src/search_engine/kuir.java index 6c509cf..b4ba2bb 100644 --- a/src/search_engine/kuir.java +++ b/src/search_engine/kuir.java @@ -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]); } @@ -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] + "\" ɾԴϴ."); } @@ -23,5 +30,7 @@ else if(args[0].equals("-i")) { } + + //searcher q = new searcher("鿡 , и ִ.", "index.post"); } }