Ejemplo n.º 1
0
        /// <summary>
        /// Parses the contents of a raw, untagged DocFile into a new Document instance.
        /// </summary>
        /// <param name="doc">The raw, untagged DocFile to parse.</param>
        /// <returns>
        /// The contents of the DocFile composed into a fully reified
        /// <see cref="Document"/> instance.
        /// </returns>
        public Document DocumentFromDoc(DocFile doc)
        {
            var docx = new DocToDocXConverter(doc).ConvertFile() as DocXFile;
            var txt  = new DocxToTextConverter(docx).ConvertFile();

            return(new TaggedSourceParser(new TaggedFile(new SharpNLPTagger(this.TaggerMode, txt.FullPath).ProcessFile())).LoadDocument(txt.NameSansExt));
        }
Ejemplo n.º 2
0
        public void DocToDocXConverterConstructorTest()
        {
            var infile = Input;
            var target = new DocToDocXConverter(infile);

            Check.That(target.Original).IsEqualTo(infile);
        }
Ejemplo n.º 3
0
        public void ConvertFileTest()
        {
            var       infile = Input;
            var       target = new DocToDocXConverter(infile);
            InputFile actual;

            actual = target.ConvertFile();
            Check.That(File.Exists(actual.FullPath)).IsTrue();
        }
Ejemplo n.º 4
0
        public async Task ConvertFileAsyncTest()
        {
            var       infile = Input;
            var       target = new DocToDocXConverter(infile);
            InputFile actual;

            actual = await target.ConvertFileAsync();

            Check.That(File.Exists(actual.FullPath)).IsTrue();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns a single string containing all of the text in the DocFile.
        /// </summary>
        /// <returns>A string containing all of the text in the DocFile.</returns>
        public override string LoadText()
        {
            var todocXConverter = new DocToDocXConverter(this);

            try
            {
                return(todocXConverter.ConvertFile().LoadText());
            }
            catch (IOException e)
            {
                throw CreateFileConversionFailureException("DOCX", e);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns a Task&lt;string&gt; which when awaited yields all of the text in the DocFile.
        /// </summary>
        /// <returns>A Task&lt;string&gt; which when awaited yields all of the text in the DocFile.</returns>
        public override async Task <string> LoadTextAsync()
        {
            var toDocXConverter = new DocToDocXConverter(this);

            try
            {
                var docx = await toDocXConverter.ConvertFileAsync().ConfigureAwait(false);

                return(await docx.LoadTextAsync().ConfigureAwait(false));
            }
            catch (IOException e)
            {
                throw CreateFileConversionFailureException("DOCX", e);
            }
        }