示例#1
0
 static Parser()
 {
     Splitter = new string[] {
         " ", "은", "는", "를", "이", "가", "나", "어", "지", "고", "거", "아", "내", "있", "요", "네", "하", "로", "을지", "답니다", "도", "에", "ㅂ니다", "는데요", "었는데", "의", "이르", "어는", "게", "어다", "니", "에게"
     };
     workflow = WorkflowFactory.getPredefinedWorkflow(WorkflowFactory.WORKFLOW_POS_SIMPLE_09);
     workflow.activateWorkflow(true);
 }
示例#2
0
        public static string[] ParseKorean(string input)
        {
            if (input == null)
            {
                return new string[] { }
            }
            ;
            if (String.IsNullOrEmpty(input) || string.IsNullOrWhiteSpace(input))
            {
                return new string[] { }
            }
            ;
            if (workflow == null)
            {
                workflow = WorkflowFactory.getPredefinedWorkflow(WorkflowFactory.WORKFLOW_POS_SIMPLE_09);

                workflow.activateWorkflow(true);
            }

            workflow.analyze(input);
            LinkedList <Sentence> result = workflow.getResultOfDocument(new Sentence(0, 0, false));

            List <string> res = new List <string>();

            foreach (Sentence s in result)
            {
                Eojeol[] eojeolArray = s.Eojeols;
                for (int i = 0; i < eojeolArray.Length; i++)
                {
                    if (eojeolArray[i].length > 0)
                    {
                        String[] morphemes = eojeolArray[i].Morphemes;
                        for (int j = 0; j < morphemes.Length; j++)
                        {
                            if (Josa.Contains(morphemes[j]))
                            {
                                continue;
                            }
                            res.Add(morphemes[j]);
                        }
                    }
                }
            }

            return(res.ToArray());
        }
示例#3
0
        static void Main(string[] args)
        {
            Workflow workflow = WorkflowFactory.getPredefinedWorkflow(WorkflowFactory.WORKFLOW_NOUN_EXTRACTOR);

            try
            {
                /* Activate the work flow in the thread mode */
                workflow.activateWorkflow(true);

                string        document = File.ReadAllText("sample.txt");
                StringBuilder sb       = new StringBuilder();

                /* Analysis using the work flow */
                workflow.analyze(document);

                LinkedList <Sentence> resultList = workflow.getResultOfDocument(new Sentence(0, 0, false));
                foreach (Sentence s in resultList)
                {
                    Eojeol[] eojeolArray = s.Eojeols;
                    for (int i = 0; i < eojeolArray.Length; i++)
                    {
                        if (eojeolArray[i].length > 0)
                        {
                            String[] morphemes = eojeolArray[i].Morphemes;
                            for (int j = 0; j < morphemes.Length; j++)
                            {
                                sb.Append(morphemes[j]);
                                sb.Append(", ");
                            }
                        }
                    }
                }

                File.WriteAllText("sample.output.txt", sb.ToString());

                workflow.close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return;
            }

            /* Shutdown the work flow */
            workflow.close();
        }