コード例 #1
0
ファイル: DoccatTool.cpp プロジェクト: benlm54/myassist-repo
                void DoccatTool::run(std::string args[])
                {

                  if (sizeof(args) / sizeof(args[0]) != 1)
                  {
                    std::cout << getHelp() << std::endl;
                    throw TerminateToolException(1);
                  }

                  DoccatModel *model = (new DoccatModelLoader())->load(new File(args[0]));

                  DocumentCategorizerME *doccat = new DocumentCategorizerME(model);

                  ObjectStream<std::string> *documentStream = new ParagraphStream(new PlainTextByLineStream(new InputStreamReader(System::in)));

                  PerformanceMonitor *perfMon = new PerformanceMonitor(System::err, "doc");
                  perfMon->start();

                  try
                  {
                    std::string document;
                    while ((document = documentStream->read()) != "")
                    {
//ORIGINAL LINE: double prob[] = doccat.categorize(document);
//JAVA TO C++ CONVERTER WARNING: Since the array size is not known in this declaration, Java to C++ Converter has converted this array to a pointer.  You will need to call 'delete[]' where appropriate:
                      double *prob = doccat->categorize(document);
                      std::string category = doccat->getBestCategory(prob);

                      DocumentSample *sample = new DocumentSample(category, document);
//JAVA TO C++ CONVERTER TODO TASK: There is no native C++ equivalent to 'toString':
                      std::cout << sample->toString() << std::endl;

                      perfMon->incrementCounter();
                    }
                  }
                  catch (IOException e)
                  {
                    CmdLineUtil::handleStdinIoError(e);
                  }

                  perfMon->stopAndPrintFinalResult();
                }