/// <summary>
 /// Convert a String expressing an output format to its internal
 /// coding as an OutputStyle.
 /// </summary>
 /// <param name="name">The String name</param>
 /// <returns>OutputStyle The internal constant</returns>
 public static PlainTextDocumentReaderAndWriter.OutputStyle FromShortName(string name)
 {
     PlainTextDocumentReaderAndWriter.OutputStyle result = PlainTextDocumentReaderAndWriter.OutputStyle.shortNames[name];
     if (result == null)
     {
         throw new ArgumentException(name + " is not an OutputStyle");
     }
     return(result);
 }
        public virtual string GetAnswers(IList <In> l, PlainTextDocumentReaderAndWriter.OutputStyle outputStyle, bool preserveSpacing)
        {
            StringWriter sw = new StringWriter();
            PrintWriter  pw = new PrintWriter(sw);

            PrintAnswers(l, pw, outputStyle, preserveSpacing);
            pw.Flush();
            return(sw.ToString());
        }
        /// <summary>Print the classifications for the document to the given Writer.</summary>
        /// <remarks>
        /// Print the classifications for the document to the given Writer. This method
        /// now checks the
        /// <c>outputFormat</c>
        /// property, and can print in
        /// slashTags, inlineXML, xml (stand-Off XML), tsv, or a 3-column tabbed format
        /// for easy entity retrieval. For both the XML output
        /// formats, it preserves spacing, while for the other formats, it prints
        /// tokenized (since preserveSpacing output is somewhat dysfunctional with these
        /// formats, but you can control this by calling getAnswers()).
        /// </remarks>
        /// <param name="list">List of tokens with classifier answers</param>
        /// <param name="out">Where to print the output to</param>
        public virtual void PrintAnswers(IList <In> list, PrintWriter @out)
        {
            string style = null;

            if (flags != null)
            {
                style = flags.outputFormat;
            }
            if (style == null || style.IsEmpty())
            {
                style = "slashTags";
            }
            PlainTextDocumentReaderAndWriter.OutputStyle outputStyle = PlainTextDocumentReaderAndWriter.OutputStyle.FromShortName(style);
            PrintAnswers(list, @out, outputStyle, PlainTextDocumentReaderAndWriter.OutputStyle.DefaultToPreserveSpacing(style));
        }
        public virtual void PrintAnswers(IList <In> l, PrintWriter @out, PlainTextDocumentReaderAndWriter.OutputStyle outputStyle, bool preserveSpacing)
        {
            switch (outputStyle)
            {
            case PlainTextDocumentReaderAndWriter.OutputStyle.SlashTags:
            {
                if (preserveSpacing)
                {
                    PrintAnswersAsIsText(l, @out);
                }
                else
                {
                    PrintAnswersTokenizedText(l, @out);
                }
                break;
            }

            case PlainTextDocumentReaderAndWriter.OutputStyle.Xml:
            {
                if (preserveSpacing)
                {
                    PrintAnswersXML(l, @out);
                }
                else
                {
                    PrintAnswersTokenizedXML(l, @out);
                }
                break;
            }

            case PlainTextDocumentReaderAndWriter.OutputStyle.InlineXml:
            {
                if (preserveSpacing)
                {
                    PrintAnswersInlineXML(l, @out);
                }
                else
                {
                    PrintAnswersTokenizedInlineXML(l, @out);
                }
                break;
            }

            case PlainTextDocumentReaderAndWriter.OutputStyle.Tsv:
            {
                if (preserveSpacing)
                {
                    PrintAnswersAsIsTextTsv(l, @out);
                }
                else
                {
                    PrintAnswersTokenizedTextTsv(l, @out);
                }
                break;
            }

            case PlainTextDocumentReaderAndWriter.OutputStyle.Tabbed:
            {
                if (preserveSpacing)
                {
                    PrintAnswersAsIsTextTabbed(l, @out);
                }
                else
                {
                    PrintAnswersTokenizedTextTabbed(l, @out);
                }
                break;
            }

            default:
            {
                throw new ArgumentException(outputStyle + " is an unsupported OutputStyle");
            }
            }
        }