#include <mecab.h>
#include <iostream>
#include <stdexcept>

// $Id: example2.cpp,v 1.4 2003/05/03 10:14:22 taku-ku Exp $;
// c++ -I/usr/local/include -L/usr/local/lib -o example2 example2.cpp -lmecab

int main (int argc, char **argv)
{
   using namespace std;

   try {
      const char p[] = "太郎は次郎が持っている本を花子に渡した。";
      
      MeCab::Tagger t (argc, argv);
      std::cout << "INPUT:" << std::endl << p << std::endl;
      
      const char *r = t.parse (p);
      std::cout << "OUTPUT:" << std::endl << r;

      // t.lock ();

      MeCab::Node *n = t.parseToNode(p);
      for (; n; n = n->next) {
	 std::cout.write (n->surface, n->length);
	 std::cout << "\t" << n->feature << std::endl;
      }
      std::cout << "EOS\n";

      // t.unlock ();

      return 0;
   } 
   
   catch (exception &e) {
      cerr << "FATAL: " << e.what () << endl;
      return -1;
   }
}
