Exemplo n.º 1
0
 public NLPTextDocumentBuilder(string uri = "?")
 {
     TextDocument   = new NLPTextDocument(uri);
     containersType = new Stack <DocumentElementType>();
     containersType.Push(DocumentElementType.Section);
     containers = new Stack <IList <DocumentElement> >();
     containers.Push(TextDocument.Elements);
 }
Exemplo n.º 2
0
        public static void WriteToFile(NLPTextDocument doc, string path)
        {
            using (var writer = new StreamWriter(path, false, Encoding.UTF8))
            {
                int lastNestingLevel = 0;

                WriteDocumentProperty(writer, NLPTextDocumentFormat.TEXT_DOCUMENT_TITLE, doc.Title);
                WriteDocumentProperty(writer, NLPTextDocumentFormat.TEXT_DOCUMENT_URI, doc.Uri);
                WriteDocumentProperty(writer, NLPTextDocumentFormat.TEXT_DOCUMENT_TIMESTAMP, doc.Timestamp.ToString(CultureInfo.InvariantCulture));
                if (doc.HasMetadata)
                {
                    foreach (var key in doc.Metadata.Keys)
                    {
                        WriteDocumentProperty(writer, NLPTextDocumentFormat.TEXT_DOCUMENT_METADATA, key + "=" + doc.Metadata[key]);
                    }
                }
                writer.WriteLine();
                WriteDocumentElements(writer, doc.Elements);
            }
        }