示例#1
0
 /// <summary>The implementation of what to run on a command-line call of CoreNLPWebClient</summary>
 /// <exception cref="System.IO.IOException">If any IO problem</exception>
 public virtual void Run()
 {
     StanfordRedwoodConfiguration.MinimalSetup();
     StanfordCoreNLP.OutputFormat outputFormat = StanfordCoreNLP.OutputFormat.ValueOf(properties.GetProperty("outputFormat", "text").ToUpper());
     //
     // Process one file or a directory of files
     //
     if (properties.Contains("file") || properties.Contains("textFile"))
     {
         string fileName = properties.GetProperty("file");
         if (fileName == null)
         {
             fileName = properties.GetProperty("textFile");
         }
         ICollection <File> files = new FileSequentialCollection(new File(fileName), properties.GetProperty("extension"), true);
         StanfordCoreNLP.ProcessFiles(null, files, 1, properties, null, StanfordCoreNLP.CreateOutputter(properties, new AnnotationOutputter.Options()), outputFormat, false);
     }
     else
     {
         //
         // Process a list of files
         //
         if (properties.Contains("filelist"))
         {
             string             fileName   = properties.GetProperty("filelist");
             ICollection <File> inputFiles = StanfordCoreNLP.ReadFileList(fileName);
             ICollection <File> files      = new List <File>(inputFiles.Count);
             foreach (File file in inputFiles)
             {
                 if (file.IsDirectory())
                 {
                     Sharpen.Collections.AddAll(files, new FileSequentialCollection(new File(fileName), properties.GetProperty("extension"), true));
                 }
                 else
                 {
                     files.Add(file);
                 }
             }
             StanfordCoreNLP.ProcessFiles(null, files, 1, properties, null, StanfordCoreNLP.CreateOutputter(properties, new AnnotationOutputter.Options()), outputFormat, false);
         }
         else
         {
             //
             // Run the interactive shell
             //
             Shell(this);
         }
     }
 }
示例#2
0
 /// <summary>Runs an interactive shell where input text is processed with the given pipeline.</summary>
 /// <param name="pipeline">The pipeline to be used</param>
 /// <exception cref="System.IO.IOException">If IO problem with stdin</exception>
 private static void Shell(StanfordCoreNLPClient pipeline)
 {
     log.Info("Entering interactive shell. Type q RETURN or EOF to quit.");
     StanfordCoreNLP.OutputFormat outputFormat = StanfordCoreNLP.OutputFormat.ValueOf(pipeline.properties.GetProperty("outputFormat", "text").ToUpper());
     IOUtils.Console("NLP> ", null);
 }