示例#1
0
    static void Main(String[] argv)
    {
        try {
            Console.WriteLine(MeCab.MeCab.VERSION);
            String arg = "";
            for (int i = 0; i < argv.Length; ++i)
            {
                arg += " ";
                arg += argv[i];
            }
            MeCab.Tagger t = new MeCab.Tagger(arg);
            String       s = "太郎は花子が持っている本を次郎に渡した。";
            Console.WriteLine(t.parse(s));

            for (MeCab.Node n = t.parseToNode(s); n != null; n = n.next)
            {
                Console.WriteLine(n.surface + "\t" + n.feature);
            }

            MeCab.Model  model = new MeCab.Model(arg);
            MeCab.Tagger t2    = model.createTagger();
            Console.WriteLine(t2.parse(s));

            MeCab.Lattice lattice = model.createLattice();
            Console.WriteLine(s);
            lattice.set_sentence(s);
            if (t2.parse(lattice))
            {
                Console.WriteLine(lattice.toString());
            }

            lattice.add_request_type(MeCab.MeCab.MECAB_NBEST);
            lattice.set_sentence(s);
            t2.parse(lattice);
            for (int i = 0; i < 10; ++i)
            {
                lattice.next();
                Console.WriteLine(lattice.toString());
            }
        }

        catch (Exception e) {
            Console.WriteLine("Generic Exception Handler: {0}", e.ToString());
        }
    }
示例#2
0
文件: Tagger.cs 项目: Hayaki/mecab
 public virtual string formatNode(Node node) {
   string ret = MeCabPINVOKE.Tagger_formatNode(swigCPtr, Node.getCPtr(node));
   if (MeCabPINVOKE.SWIGPendingException.Pending) throw MeCabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
示例#3
0
文件: Node.cs 项目: Hayaki/mecab
 internal static HandleRef getCPtr(Node obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
示例#4
0
文件: Lattice.cs 项目: Hayaki/mecab
 public virtual string toString(Node node) {
   string ret = MeCabPINVOKE.Lattice_toString__SWIG_1(swigCPtr, Node.getCPtr(node));
   if (MeCabPINVOKE.SWIGPendingException.Pending) throw MeCabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }