Exemplo n.º 1
0
        public DocumentViewModel(
            IDialogService dialogService,
            IWindowManager windowManager,
            ISiteContextGenerator siteContextGenerator,
            Func <string, IMetaWeblogService> getMetaWeblog,
            ISettingsProvider settingsProvider,
            IDocumentParser documentParser)
        {
            this.dialogService        = dialogService;
            this.windowManager        = windowManager;
            this.siteContextGenerator = siteContextGenerator;
            this.getMetaWeblog        = getMetaWeblog;
            this.settingsProvider     = settingsProvider;
            this.documentParser       = documentParser;

            FontSize   = GetFontSize();
            IndentType = settingsProvider.GetSettings <MarkPadSettings>().IndentType;

            Title          = "New Document";
            Original       = "";
            Document       = new TextDocument();
            Post           = new Post();
            timer          = new DispatcherTimer();
            timer.Tick    += TimerTick;
            timer.Interval = delay;
        }
Exemplo n.º 2
0
        private void ParseNode(IDocumentParser docParser, HtmlNode node, bool isReadonly = false)
        {
            var state = GetParagraphType(node);

            if (state.IsHierarchical())
            {
                using (docParser.ParseHierarchyElement(state))
                {
                    if (IsHerarchy(node))
                    {
                        foreach (var childNode in node.ChildNodes)
                        {
                            ParseNode(docParser, childNode, state == ElementType.Title || isReadonly);
                        }
                    }
                    else
                    {
                        ParseParagraph(docParser, node, state == ElementType.Title || isReadonly);
                    }
                }
            }
            else
            {
                ParseParagraph(docParser, node, isReadonly);
            }
        }
Exemplo n.º 3
0
 public LearnedClassifier(IDocumentParser parser, ISvmTestClient testClient)
 {
     Guard.NotNull(() => parser, parser);
     Guard.NotNull(() => testClient, testClient);
     this.parser     = parser;
     this.testClient = testClient;
 }
Exemplo n.º 4
0
        public static IDocumentParser CreateDocument(ParserContext context)
        {
            object          obj    = CreateObject(context, typeof(IDocumentParser), "CreateDocument");
            IDocumentParser parser = (IDocumentParser)obj;

            return(parser);
        }
Exemplo n.º 5
0
 public EventCapturer(IDocumentValidator documentValidator, IDocumentParser documentParser, IRequestPersister requestPersister, IUserProvider userProvider)
 {
     _documentValidator = documentValidator ?? throw new ArgumentException(nameof(documentValidator));
     _documentParser    = documentParser ?? throw new ArgumentException(nameof(documentParser));
     _requestPersister  = requestPersister ?? throw new ArgumentException(nameof(requestPersister));
     _userProvider      = userProvider ?? throw new ArgumentException(nameof(userProvider));
 }
Exemplo n.º 6
0
        //Parse document(option=['document'->.docx, .pdf] or ['txt'->.txt])
        //Removes punctuation and returns the words of the document in an array of strings
        public string[] GetText(string path, string option)
        {
            string text = null;

            try
            {
                ParserContext context = new ParserContext(path);
                if (option.Equals("txt"))
                {
                    ITextParser parser = ParserFactory.CreateText(context);
                    text = parser.Parse().ToString().ToLower().Replace('\n', ' ').Replace('\r', ' ')
                           .Replace('\t', ' ');
                }
                else if (option.Equals("document"))
                {
                    IDocumentParser parser = ParserFactory.CreateDocument(context);
                    text = parser.Parse().ToString().ToLower().Replace('\n', ' ').Replace('\r', ' ')
                           .Replace('\t', ' ');
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception found");
                Console.WriteLine(e.Message);
            }
            text = RemovePunctuation(text);
            string[] words = text.Split(default(Char[]), StringSplitOptions.RemoveEmptyEntries);
            return(words);
        }
Exemplo n.º 7
0
 public FileManager(IDocumentParser parser, CancellationToken token, int parallel = 1)
 {
     Guard.NotNull(() => parser, parser);
     this.parser   = parser;
     this.token    = token;
     this.parallel = parallel;
 }
        public DocumentViewModel(
            IDialogService dialogService,
            IWindowManager windowManager,
            ISettingsProvider settingsProvider,
            IDocumentParser documentParser,
            ISpellCheckProvider spellCheckProvider,
            ISearchProvider searchProvider,
            IShell shell)
        {
            SpellCheckProvider    = spellCheckProvider;
            this.dialogService    = dialogService;
            this.windowManager    = windowManager;
            this.settingsProvider = settingsProvider;
            this.documentParser   = documentParser;
            this.shell            = shell;
            SearchProvider        = searchProvider;

            FontSize   = GetFontSize();
            IndentType = settingsProvider.GetSettings <MarkPadSettings>().IndentType;

            Original       = "";
            Document       = new TextDocument();
            timer          = new DispatcherTimer();
            timer.Tick    += TimerTick;
            timer.Interval = delay;
        }
Exemplo n.º 9
0
 public GameDetailsProvider(IDocumentLoader documentLoader, GameDetailsConfigSettings settings, IDocumentParser <LineScoreData> lineScoreParser, IDocumentParser <TeamBoxScoreData, string> teamBoxScoreParser)
 {
     _documentLoader     = documentLoader ?? throw new ArgumentNullException(nameof(documentLoader));
     _settings           = settings ?? throw new ArgumentNullException(nameof(settings));
     _lineScoreParser    = lineScoreParser ?? throw new ArgumentNullException(nameof(lineScoreParser));
     _teamBoxScoreParser = teamBoxScoreParser ?? throw new ArgumentNullException(nameof(teamBoxScoreParser));
 }
Exemplo n.º 10
0
        public DocumentViewModel(
            IDialogService dialogService,
            IWindowManager windowManager,
            ISiteContextGenerator siteContextGenerator,
            Func<string, IMetaWeblogService> getMetaWeblog,
            ISettingsProvider settingsProvider,
            IDocumentParser documentParser)
        {
            this.dialogService = dialogService;
            this.windowManager = windowManager;
            this.siteContextGenerator = siteContextGenerator;
            this.getMetaWeblog = getMetaWeblog;
            this.settingsProvider = settingsProvider;
            this.documentParser = documentParser;

            FontSize = GetFontSize();

            title = "New Document";
            Original = "";
            Document = new TextDocument();
            Post = new Post();
            timer = new DispatcherTimer();
            timer.Tick += TimerTick;
            timer.Interval = delay;
        }
 public ConsentFormController(IMembershipService membershipService,
                              IBlobStore blobStore, IViewRepository<ConsentFormEditModel> viewRepository, 
                              IDocumentParser documentParser)
     : base(membershipService, blobStore)
 {
     _viewRepository = viewRepository;
     _documentParser = documentParser;
 }
Exemplo n.º 12
0
        public HtmlExporter(IFileWriterFactory writerFactory, IDocumentParser parser)
        {
            Ensure.ArgumentNotNull(writerFactory, "writerFactory");
            Ensure.ArgumentNotNull(parser, "parser");

            _writerFactory = writerFactory;
            _parser = parser;
        }
Exemplo n.º 13
0
 public AssetBundleCsvDataProvider(string assetBundleUrl, IDocumentParser parser)
 {
     if (string.IsNullOrEmpty(assetBundleUrl))
     {
         throw new ArgumentNullException("assetBundleUrl");
     }
     this.parser         = parser ?? throw new ArgumentNullException("parser");
     this.assetBundleUrl = assetBundleUrl;
 }
Exemplo n.º 14
0
        public ExportToHtmlPlugin(
            IDocumentParser documentParser,
            IPluginSettingsProvider settingsProvider)
        {
            _documentParser = documentParser;
            _settingsProvider = settingsProvider;

            _settings = _settingsProvider.GetSettings<ExportToHtmlPluginSettings>();
        }
Exemplo n.º 15
0
        public ExportToHtmlPlugin(
            IDocumentParser documentParser,
            IPluginSettingsProvider settingsProvider)
        {
            _documentParser   = documentParser;
            _settingsProvider = settingsProvider;

            _settings = _settingsProvider.GetSettings <ExportToHtmlPluginSettings>();
        }
Exemplo n.º 16
0
        public async Task <ParserOutput> GetXamlAsync(IAsyncServiceProvider serviceProvider)
        {
            ParserOutput result = null;

            if (CodeParserBase.GetSettings().Profiles.Any())
            {
                if (!(await serviceProvider.GetServiceAsync(typeof(EnvDTE.DTE)) is DTE dte))
                {
                    SharedRapidXamlPackage.Logger?.RecordError(StringRes.Error_FailedToGetDteInGetXamlAsync);
                }
                else
                {
                    var activeDocument = dte.ActiveDocument;

                    var textView = await GetTextViewAsync(serviceProvider);

                    var selection = textView.Selection;

                    bool isSelection = selection.Start.Position != selection.End.Position;

                    var caretPosition = textView.Caret.Position.BufferPosition;

                    var document = caretPosition.Snapshot.GetOpenDocumentInCurrentContextWithChanges();

                    var semanticModel = await document.GetSemanticModelAsync();

                    var vs         = new VisualStudioAbstraction(this.Logger, this.AsyncPackage, dte);
                    var xamlIndent = await vs.GetXamlIndentAsync();

                    var proj = dte.Solution.GetProjectContainingFile(document.FilePath);

                    if (proj == null)
                    {
                        // Default to the "active project" if file is not part of a known project
                        proj = ((Array)dte.ActiveSolutionProjects).GetValue(0) as Project;
                    }

                    var projType = vs.GetProjectType(proj);

                    this.Logger?.RecordInfo(StringRes.Info_DetectedProjectType.WithParams(projType.GetDescription()));

                    IDocumentParser parser = null;

                    if (activeDocument.Language == "CSharp")
                    {
                        parser = new CSharpParser(this.Logger, projType, xamlIndent);
                    }
                    else if (activeDocument.Language == "Basic")
                    {
                        parser = new VisualBasicParser(this.Logger, projType, xamlIndent);
                    }

                    result = isSelection
                        ? parser?.GetSelectionOutput(await document.GetSyntaxRootAsync(), semanticModel, selection.Start.Position, selection.End.Position)
                        : parser?.GetSingleItemOutput(await document.GetSyntaxRootAsync(), semanticModel, caretPosition.Position);
                }
            }
Exemplo n.º 17
0
        private static void ParseParagraph(IDocumentParser docParser, HtmlNode node, bool isReadonly)
        {
            var nodeWrapper = new HtmlNodeWrapper(node, isReadonly);

            if (node.HasChildNodes || nodeWrapper.IsValuableTextNode(IXmlTextNodeMode.Exact))
            {
                docParser.ParseParagraph(nodeWrapper);
            }
        }
Exemplo n.º 18
0
 public void Parse(IDocumentParser parser, string file)
 {
     Parser = parser.GetType().Name;
     parser.Parse(file, this);
     if (!DocumentDate.HasValue)
     {
         DocumentDate = DateTime.Now;
     }
 }
Exemplo n.º 19
0
        public TeamProvider(IDocumentLoader documentLoader, TeamConfigSettings settings, IDocumentParser <IEnumerable <PlayerRoosterData> > teamRoosterParser, IDocumentParser <IEnumerable <PlayerSeasonStatisticsData> > playerSeasonStatisticsParser, IDocumentParser <IEnumerable <PlayByPlayData> > playByPlayParser, IDocumentParser <TeamMiscData> teamMiscParser)
        {
            _documentLoader = documentLoader ?? throw new ArgumentNullException(nameof(documentLoader));
            _settings       = settings ?? throw new ArgumentNullException(nameof(settings));

            _teamRoosterParser            = teamRoosterParser ?? throw new ArgumentNullException(nameof(teamRoosterParser));
            _playerSeasonStatisticsParser = playerSeasonStatisticsParser ?? throw new ArgumentNullException(nameof(playerSeasonStatisticsParser));
            _playByPlayParser             = playByPlayParser ?? throw new ArgumentNullException(nameof(playByPlayParser));
            _teamMiscParser = teamMiscParser ?? throw new ArgumentNullException(nameof(teamMiscParser));
        }
Exemplo n.º 20
0
        private void GenerateFilesFromDocument(string documentName, IDocumentParser documentParser)
        {
            var index = documentParser.GetDocumentIndex().Keys;

            foreach (var fragmentKey in index)
            {
                string fragmentName = Cleanup(fragmentKey);
                string fragment     = documentProcessor.ProcessDocument(documentName, fragmentName);
                SaveAsDocument(documentName, fragmentName, fragment);
            }
        }
Exemplo n.º 21
0
 public AnomalyController(
     ILoggerFactory loggerFactory,
     IAnomalyDetection anomalyDetection,
     IDocumentParser documentParser,
     IDocumentExtractor extractor)
     : base(loggerFactory)
 {
     this.anomalyDetection = anomalyDetection ?? throw new ArgumentNullException(nameof(anomalyDetection));
     this.documentParser   = documentParser ?? throw new ArgumentNullException(nameof(documentParser));
     this.extractor        = extractor ?? throw new ArgumentNullException(nameof(extractor));
 }
Exemplo n.º 22
0
        public void SetUp()
        {
            StructureMapBootstrapper.Execute();

            ObjectFactory.Configure(x =>
            {
                x.For <IMessagePublisher>().Use <FakeMessagePublisher>();
            });
            _sut =
                ServiceLocator.Current.GetAllInstances <IDocumentParser>().Find(
                    p => p.CanProcess(BusinessPartner.MicroCenter, "850"));
        }
        public void SetUp()
        {
            StructureMapBootstrapper.Execute();

            ObjectFactory.Configure(x =>
            {
                x.For<IMessagePublisher>().Use<FakeMessagePublisher>();
            });
            _sut =
                ServiceLocator.Current.GetAllInstances<IDocumentParser>().Find(
                    p => p.CanProcess(BusinessPartner.MicroCenter, "850"));
        }
Exemplo n.º 24
0
            internal DstFileContainer(IDocumentParser parser, string dstFilePath, ISet <Word> dstWords)
            {
                _parser     = parser;
                DstFilePath = dstFilePath;
                _dstWordToValuesLocationContainer = new Dictionary <Word, ValuesLocationContainer>();

                _inited  = false;
                _changed = false;

                foreach (var dstWord in dstWords)
                {
                    _dstWordToValuesLocationContainer[dstWord] = new ValuesLocationContainer(dstFilePath);
                }
            }
        public DefaultDataProvider(string root, IDocumentParser parser)
        {
            if (string.IsNullOrEmpty(root))
            {
                throw new ArgumentNullException("root");
            }

            if (parser == null)
            {
                throw new ArgumentNullException("parser");
            }

            this.root   = root;
            this.parser = parser;
        }
Exemplo n.º 26
0
        public void TestParseSimpleDocumentFromWord()
        {
            ParserContext   context = new ParserContext(TestDataSample.GetWordPath("SampleDoc.docx"));
            IDocumentParser parser  = ParserFactory.CreateDocument(context);
            ToxyDocument    doc     = parser.Parse();

            Assert.AreEqual(7, doc.Paragraphs.Count);
            Assert.AreEqual("I am a test document", doc.Paragraphs[0].Text);
            Assert.AreEqual("This is page 1", doc.Paragraphs[1].Text);
            Assert.AreEqual("I am Calibri (Body) in font size 11", doc.Paragraphs[2].Text);
            Assert.AreEqual("\n", doc.Paragraphs[3].Text);
            Assert.AreEqual("This is page two", doc.Paragraphs[4].Text);
            Assert.AreEqual("It’s Arial Black in 16 point", doc.Paragraphs[5].Text);
            Assert.AreEqual("It’s also in blue", doc.Paragraphs[6].Text);
        }
Exemplo n.º 27
0
        public AssetBundleDataProvider(string assetBundleUrl, IDocumentParser parser)
        {
            if (string.IsNullOrEmpty(assetBundleUrl))
            {
                throw new ArgumentNullException("assetBundleUrl");
            }

            if (parser == null)
            {
                throw new ArgumentNullException("parser");
            }

            this.assetBundleUrl = assetBundleUrl;
            this.parser         = parser;
            this.executor       = new CoroutineExecutor();
        }
Exemplo n.º 28
0
        public void TestParseDocumentWithTable()
        {
            ParserContext   context = new ParserContext(TestDataSample.GetWordPath("simple-table.docx"));
            IDocumentParser parser  = ParserFactory.CreateDocument(context);
            ToxyDocument    doc     = parser.Parse();

            Assert.AreEqual(8, doc.Paragraphs.Count);
            Assert.AreEqual("This is a Word document that was created using Word 97 – SR2.  It contains a paragraph, a table consisting of 2 rows and 3 columns and a final paragraph.",
                            doc.Paragraphs[0].Text);
            Assert.AreEqual("This text is below the table.", doc.Paragraphs[1].Text);
            Assert.AreEqual("Cell 1,1", doc.Paragraphs[2].Text);
            Assert.AreEqual("Cell 1,2", doc.Paragraphs[3].Text);
            Assert.AreEqual("Cell 1,3", doc.Paragraphs[4].Text);
            Assert.AreEqual("Cell 2,1", doc.Paragraphs[5].Text);
            Assert.AreEqual("Cell 2,2", doc.Paragraphs[6].Text);
            Assert.AreEqual("Cell 2,3", doc.Paragraphs[7].Text);
        }
Exemplo n.º 29
0
        public async Task <ParserOutput> GetXamlAsync(IAsyncServiceProvider serviceProvider)
        {
            ParserOutput result = null;

            if (CodeParserBase.GetSettings().Profiles.Any())
            {
                if (!(await serviceProvider.GetServiceAsync(typeof(EnvDTE.DTE)) is DTE dte))
                {
                    RapidXamlPackage.Logger?.RecordError("Failed to get DTE in GetXamlFromCodeWindowBaseCommand.GetXamlAsync");
                }
                else
                {
                    var activeDocument = dte.ActiveDocument;

                    var textView = await GetTextViewAsync(serviceProvider);

                    var selection = textView.Selection;

                    bool isSelection = selection.Start.Position != selection.End.Position;

                    var caretPosition = textView.Caret.Position.BufferPosition;

                    var document = caretPosition.Snapshot.GetOpenDocumentInCurrentContextWithChanges();

                    var semanticModel = await document.GetSemanticModelAsync();

                    var vs         = new VisualStudioAbstraction(this.Logger, this.ServiceProvider, dte);
                    var xamlIndent = await vs.GetXamlIndentAsync();

                    IDocumentParser parser = null;

                    if (activeDocument.Language == "CSharp")
                    {
                        parser = new CSharpParser(this.Logger, xamlIndent);
                    }
                    else if (activeDocument.Language == "Basic")
                    {
                        parser = new VisualBasicParser(this.Logger, xamlIndent);
                    }

                    result = isSelection
                        ? parser?.GetSelectionOutput(await document.GetSyntaxRootAsync(), semanticModel, selection.Start.Position, selection.End.Position)
                        : parser?.GetSingleItemOutput(await document.GetSyntaxRootAsync(), semanticModel, caretPosition.Position);
                }
            }
Exemplo n.º 30
0
        public WebCrawler(ILogger <WebCrawler> logger, CrawlConfiguration crawlConfiguration, IThreadManager threadManager, ICrawlDecisionMaker crawlDecisionMaker, ICrawlScheduler crawlScheduler, IPageRequester pageRequester, IDocumentParser hyperLinkParser, IRateLimiter rateLimiter)
        {
            _logger             = logger;
            _crawlConfiguration = crawlConfiguration;
            _crawlContext       = new CrawlContext(logger)
            {
                CrawlConfiguration = crawlConfiguration
            };

            _threadManager      = threadManager;
            _crawlDecisionMaker = crawlDecisionMaker;
            _scheduler          = crawlScheduler;
            _pageRequester      = pageRequester;
            _hyperLinkParser    = hyperLinkParser;
            _rateLimiter        = rateLimiter;

            PageCrawlStartingAsync += WebCrawler_PageCrawlStartingAsync;
        }
Exemplo n.º 31
0
        public ServiceResult <DocumentUploadResponseDto> AnalyzeDocument(string fileFullPath)
        {
            var result = new DocumentUploadResponseDto();

            result.FilePath = fileFullPath;
            var serviceResult = new ServiceResult <DocumentUploadResponseDto>();

            try
            {
                result.FilePath = fileFullPath;
                if (fileFullPath.IsDocumentExtension())
                {
                    IDocumentParser parser       = GetDocumentParser(fileFullPath);
                    var             parsedDoc    = parser.Parse();
                    var             stringParser = new StringParser(parsedDoc.ToString());
                    result.PageCount           = parsedDoc.TotalPageNumber;
                    result.CharCountWithSpaces = stringParser.GenerateCharacterCount();
                    result.CharCount           = stringParser.GenerateCharacterCount(withoutWhitespaces: true);
                }
                else
                {
                    ITextParser parser       = GetTextParser(fileFullPath);
                    var         parsedDoc    = parser.Parse();
                    var         stringParser = new StringParser(parsedDoc);
                    result.PageCount           = 1;
                    result.CharCountWithSpaces = stringParser.GenerateCharacterCount();
                    result.CharCount           = stringParser.GenerateCharacterCount(withoutWhitespaces: true);
                }

                serviceResult.ServiceResultType = ServiceResultType.Success;
                serviceResult.Data = result;
            } catch (Exception exc) {
                serviceResult.Exception         = exc;
                serviceResult.ServiceResultType = ServiceResultType.Fail;
                _logger.Error($"Error occured in {MethodBase.GetCurrentMethod().Name} with exception message {exc.Message} and inner exception {exc.InnerException?.Message}");
            }
            return(serviceResult);
        }
Exemplo n.º 32
0
 public string ProcessDocument(string document, string fragment)
 {
     if (string.IsNullOrWhiteSpace(document))
     {
         var    userGuideIndex = userGuideDocumentParser.GetDocumentIndex();
         string str            = markdownProcessor.ProcessFragment(string.Join(Environment.NewLine + Environment.NewLine
                                                                               , userGuideIndex.Keys.OrderBy(k => k)));
         return(str);
     }
     else if (string.Compare(document, "userGuide", StringComparison.OrdinalIgnoreCase) != 0)
     {
         return("");
     }
     else
     {
         IDocumentParser parser        = userGuideDocumentParser;
         var             titleMD       = parser.GetFragment("userGuideTitle", fragment);
         var             titleHtml     = titleMD; // markdownProcessor.ProcessFragment(titleMD);
         var             userGuideMD   = parser.GetFragment("userGuide", fragment);
         var             userGuideHtml = markdownProcessor.ProcessFragment(userGuideMD);
         var             wrapper       = htmlWrapper.Replace("{userGuideTitle}", titleHtml).Replace("{userGuide}", userGuideHtml);
         return(wrapper);
     }
 }
Exemplo n.º 33
0
        public string ExtractText(string filePath, string extension)
        {
            ParserContext c = new ParserContext(filePath);

            try
            {
                IDocumentParser parser = ParserFactory.CreateDocument(c);
                ToxyDocument    result = parser.Parse();
                return(result.ToString());
            }
            catch (InvalidDataException)
            {
                Console.Error.WriteLine($"'{filePath}' is supported but don't have the required extension.");
                var newFilePath = $"{filePath}.{extension}";
                Console.Error.WriteLine($"Creating a copy in '{newFilePath}' and using that to read.");
                File.Copy(filePath, newFilePath);
                return(ExtractText(newFilePath, extension));
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("{0} Exception caught error with {1}.", e, filePath);
                return(null);
            }
        }
Exemplo n.º 34
0
        private void ParseNode(IDocumentParser docParser, XElement node)
        {
            var state = GetParagraphType(node);

            if (state.IsHierarchical())
            {
                using (docParser.ParseHierarchyElement(state))
                {
                    foreach (var childNode in node.Elements())
                    {
                        ParseNode(docParser, childNode);
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(node.Value.Trim()))
                {
                    var htmlNode = new HtmlNodeWrapper(node.Value);
                    docParser.ParseParagraph(htmlNode);
                    node.Value = htmlNode.InnerXml;
                }
            }
        }
Exemplo n.º 35
0
        public List <BankTransfer> GetAllBanktransfers(string path)
        {
            IDocumentParser <BankTransfer> documentParser = GetElement(path);

            return(documentParser.GetAllResults(path));
        }
 public void SetUp()
 {
     _addrParser = new Mock<IAddressParser>();
     _lineParser = new Mock<IFedex850LineParser>();
     _recorder = new Mock<IEDIResponseReferenceRecorder>();
     _genericParser = new Mock<IGeneric850Parser>();
     _sut = new Fedex850Parser(_addrParser.Object,  _recorder.Object, _genericParser.Object, _lineParser.Object);
 }