示例#1
0
        public Outro(IRenderView renderView, OutroData outroData, Font outroFont, Font outroFontLarge, Action finishAction)
        {
            this.finishAction    = finishAction;
            this.outroData       = outroData;
            this.outroFont       = outroFont;
            this.outroFontLarge  = outroFontLarge;
            this.renderView      = renderView;
            renderLayer          = renderView.GetLayer(Layer.OutroGraphics);
            picture              = renderView.SpriteFactory.Create(160, 128, true, 1) as ILayerSprite;
            picture.Layer        = renderLayer;
            picture.PaletteIndex = paletteOffset = renderView.GraphicProvider.FirstOutroPaletteIndex;
            picture.Visible      = false;
            renderTextFactory    = renderView.RenderTextFactory;
            textProcessor        = renderView.TextProcessor;

            fadeArea         = renderView.ColoredRectFactory.Create(Global.VirtualScreenWidth, Global.VirtualScreenHeight, Color.Black, 255);
            fadeArea.Layer   = renderView.GetLayer(Layer.Effects);
            fadeArea.X       = 0;
            fadeArea.Y       = 0;
            fadeArea.Visible = false;

            graphicInfos = outroData.GraphicInfos;

            EnsureTextures(renderView, outroData, outroFont, outroFontLarge);
        }
示例#2
0
        internal static TagCloud GetTagCloud(string text, ICloudLayoter layoter,
                                             ITextProcessor textProcessor, IWordsMetric wordsMetric)
        {
            var metric = wordsMetric.GetMetric(textProcessor.GetLiterals(text));

            return(new TagCloud(metric, layoter));
        }
        public bool AddItem(Room room, InventoryItem item, out InventoryItem droppedItem, ITextProcessor textProcessor)
        {
            Guard.NullParameter(room, () => room);
            Guard.NullParameter(item, () => item);

            return AddItem(room.Name, item, out droppedItem, textProcessor);
        }
示例#4
0
 public BookContentProcessor(
     ITextProcessor textProcessor,
     ISentenceFactory sentenceFactory)
 {
     _textProcessor   = textProcessor;
     _sentenceFactory = sentenceFactory;
 }
示例#5
0
文件: CLI.cs 项目: blankego/cccount
        void DoJob()
        {
            _counter = new Counter ();

            if (_files.Count == 0)//get input from stdin
            {
                using (var sr = new StreamReader (Console.OpenStandardInput (), input_encoding))
                {
                    _counter.Process (sr);
                }
            }
            else
            {
                WalkFileEntries (_files, f =>
                {
                    if (string.IsNullOrEmpty (extension) || f.EndsWith ("." + extension))
                    {
                        using(var sr = new StreamReader(f,input_encoding))
                        {
                            _counter.Process (sr);
                        }
                    }
                });
            }
        }
示例#6
0
        public void OneTimeSetUp()
        {
            var mock = new Mock <ITextProcessor>();

            mock.Setup(p => p.Process(It.IsAny <string>()))
            .Returns((string v) => v);
            _textProcessorMock = mock.Object;
        }
 public static IEnumerable <string> GetNormalizedWordsEnumerable(
     this ITextProcessor textProcessor, string text)
 {
     return(textProcessor.GetWordsEnumerable(text)
            .Select(word => textProcessor.NormalizeWord(word))
            .Where(word => word.Length > 0)
            .Distinct());
 }
 public static IEnumerable <string> GetSentencesEnumerable(
     this ITextProcessor textProcessor,
     string text,
     LanguageInformation languageInformation)
 {
     return(textProcessor.GetSentencesEnumerable(text)
            .Where(sentence => languageInformation.IsAllLettersAllowed(sentence)));
 }
示例#9
0
 public void SetUp()
 {
     _embeddedContentVisitorFactoryMock = A.Fake <IEmbeddedContentVisitorFactory>();
     _embeddedContetnRegexSettingsMock  = A.Fake <IEmbeddedContentRegexSettings>();
     _textProcessorMock  = A.Fake <ITextProcessor>();
     _settingsBundleMock = A.Fake <ISettingsBundle>();
     _itemFactoryMock    = A.Fake <IDocumentItemFactory>();
 }
示例#10
0
 public SentenceQuery(
     LibraryDbContext dbContext,
     ITextProcessor textProcessor,
     string language)
 {
     _dbContext     = dbContext;
     _textProcessor = textProcessor;
     _language      = language;
 }
示例#11
0
 private void SetTagInfo(OptionsTagInfo info)
 {
     processor = TextProcessorAssosiation
                 .GetProcessor(SkipSpaces(info.Processor));
     metric = WordsMetricAssosiation
              .GetMetric(SkipSpaces(info.Metric));
     layoter = CloudLayoterAssosiation
               .GetCloudLayoter(SkipSpaces(info.Layoter), SkipSpaces(info.PointGetter));
 }
示例#12
0
        static void Main(string[] args)
        {
            Initialize();
            ITextSource    textSource    = null;
            IResultWriter  resultWriter  = null;
            ITextProcessor textProcessor = null;

#if version1
            //Проверяем наличие модулей
            if (sourses.Length == 0)
            {
                System.Diagnostics.Trace.WriteLine("Not found any SourceModule");
                return;
            }

            if (writers.Length == 0)
            {
                System.Diagnostics.Trace.WriteLine("Not found any SourceModule");
                return;
            }

            if (processors.Length == 0)
            {
                System.Diagnostics.Trace.WriteLine("Not found any SourceModule");
                return;
            }
#endif
            //Получаем название модулей и загружаем
            var textSourceName    = SelectModuleName("Select a source of text", sourses);
            var resultWriterName  = SelectModuleName("Select method of write result", writers);
            var textProcessorName = SelectModuleName("Select method of word processing", processors);

#if version2
            textSourceModule.SetNecessaryType(textSourceName);
            resultWriterModule.SetNecessaryType(resultWriterName);
            textProcessorModule.SetNecessaryType(textProcessorName);

            kernel = new StandardKernel(new NinjectModule[] { textSourceModule, resultWriterModule, textProcessorModule });
#endif

            textSource    = kernel.Get <ITextSource>(textSourceName);
            resultWriter  = kernel.Get <IResultWriter>(resultWriterName);
            textProcessor = kernel.Get <ITextProcessor>(textProcessorName);

            //Запускаем обработку текста
            var spinner = new ConsoleSpiner();
            spinner.Start("Processing");

            IWorker worker = new SimpleWorker(textSource, resultWriter, textProcessor);
            var     d      = worker.ExecuteAsync().Result;

            spinner.Stop();
            Console.WriteLine();
            Console.Write("All done. Press any key...");
            Console.ReadKey();
        }
示例#13
0
        public InMemoryStore(IDictionary <string, string> sourceDictionary, ITextProcessor textProcessor)
        {
            if (sourceDictionary == null)
            {
                throw new ArgumentNullException(nameof(sourceDictionary));
            }
            Store = new ConcurrentDictionary <string, string>(sourceDictionary);

            TextProcessor = textProcessor ?? throw new ArgumentNullException(nameof(textProcessor));
        }
 public IEmbeddedContentVisitor CreateVisitor(IDocumentItemFactory itemFactory,
                                              IPropertiesFactory propertiesFactory, ITextProcessor textProcessor)
 {
     _itemFactory       = itemFactory;
     _propertiesFactory = propertiesFactory;
     _textProcessor     = textProcessor;
     GeneratedParagraph = _itemFactory.CreateParagraphUnit(LockTypeFlags.Unlocked).Source;
     _currentContainer  = GeneratedParagraph;
     return(this);
 }
 public static IEnumerable <string> GetNormalizedWordsEnumerable(
     this ITextProcessor textProcessor,
     string text,
     LanguageInformation languageInformation)
 {
     return(textProcessor.GetWordsEnumerable(text)
            .Select(word => textProcessor.NormalizeWord(word))
            .Where(word => languageInformation.IsAllLettersAllowed(word))
            .Where(word => word.Length > 0)
            .Distinct());
 }
示例#16
0
    public BawBagBot(BawBagBotConfiguration configuration)
    {
      Guard.NullParameter(configuration, () => configuration);

      _configuration = configuration;

      _store = new DocumentStore { ConnectionStringName = "RavenDB" };
      _randomProvider = new RandomNumberProvider();
      _inventoryManager = new InventoryManager(5, _store, _randomProvider);
      _textProcessor = new TextProcessor();
      _dateTimeProvider = new DefaultDateTimeProvider();

      _rooms = new Dictionary<string, Room>();
      _botAddressedMatcher = new Regex("^@?" + _configuration.JabbrNick + "[,: ](.*)$", RegexOptions.IgnoreCase);
    }
示例#17
0
 public BookImporter(
     IBookRepository bookStore,
     ISentenceRepository sentenceRepository,
     ITextProcessor textProcessor,
     ILanguageProvider languageProvider,
     IBookContentProcessor bookContentProcessor,
     ILogger <BookImporter> logger)
 {
     _bookStore            = bookStore;
     _sentenceRepository   = sentenceRepository;
     _textProcessor        = textProcessor;
     _languageProvider     = languageProvider;
     _bookContentProcessor = bookContentProcessor;
     _logger = logger;
 }
示例#18
0
 public TextcMessageReceiver(
     ITextProcessor textProcessor,
     IContextProvider contextProvider,
     IExceptionHandler exceptionHandler = null)
 {
     if (textProcessor == null)
     {
         throw new ArgumentNullException(nameof(textProcessor));
     }
     if (contextProvider == null)
     {
         throw new ArgumentNullException(nameof(contextProvider));
     }
     _textProcessor    = textProcessor;
     _contextProvider  = contextProvider;
     _exceptionHandler = exceptionHandler;
 }
示例#19
0
        public IList <IToken> Process(ITextProcessor input)
        {
            return(Tokenize(input.Presentation));

            /*var accum = new StringBuilder();
             * var outp = new List<IToken>();
             *
             * var code = input.Presentation.Aggregate("", (s, s1) => s + s1);
             * var length = code.Length;
             * for (var i = 0; i < length; i++)
             * {
             *  if (code[i] == ' ')
             *  {
             *      accum.Clear();
             *      while (i < length - 1 && code[i] == ' ')
             *          i++;
             *  }
             *  if (i + 1 == length) break;
             *
             *  accum.Append(code[i]);
             *  var accumStr = accum.ToString();
             *
             *  if (ops.Contains(accumStr))
             *  {
             *      outp.Add(new ExampleToken(accumStr, "Operation"));
             *      accum.Clear();
             *  }
             *  else if (singleOps.Contains(accumStr))
             *  {
             *      outp.Add(new ExampleToken(accumStr, "Single Operation"));
             *      accum.Clear();
             *  }
             *  else if (Regex.IsMatch(accumStr, @"^e?(([a-d]x)|([sd]i))$"))
             *  {
             *      outp.Add(new ExampleToken(accumStr, "Register"));
             *      accum.Clear();
             *  }
             *  else if (accumStr == ",")
             *  {
             *      outp.Add(new ExampleToken(",", "Comma"));
             *      accum.Clear();
             *  }
             * }
             *
             * return outp;*/
        }
示例#20
0
        public void OneTimeSetup()
        {
            var mock = new Mock <ITextProcessor>();

            mock.Setup(p => p.Process(It.IsAny <string>()))
            .Returns((string v) => v);
            _textProcessor = mock.Object;

            var connectionString = new ConnectionString
            {
                Filename = DataFilename,
            };

            _db = new LiteDatabase(connectionString, BsonMapper.Global);

            _repository = new DataRepository(DataFilename);
        }
        public void SetUp()
        {
            _itemFactoryMock       = A.Fake <IDocumentItemFactory>();
            _propertiesFactoryMock = A.Fake <IPropertiesFactory>();
            _textProcessorMock     = A.Fake <ITextProcessor>();
            _sourceParagraphMock   = A.Fake <IParagraph>();
            _textMock = A.Fake <IText>();

            var paragraphUnitMock = A.Fake <IParagraphUnit>();

            A.CallTo(() => _itemFactoryMock.CreateParagraphUnit(LockTypeFlags.Unlocked)).Returns(paragraphUnitMock);
            A.CallTo(() => paragraphUnitMock.Source).Returns(_sourceParagraphMock);

            var propertiesMock = A.Fake <ITextProperties>();

            A.CallTo(() => propertiesMock.Text).Returns(TexBeforeProcessing);
            A.CallTo(() => _textMock.Properties).Returns(propertiesMock);
        }
        internal string GetOutput(IEnumerable <string> selectedItems, ITextProcessor textProcessor)
        {
            try
            {
                StringBuilder buffer = new StringBuilder();
                int           count  = selectedItems.Count();
                for (int i = 0; i < count; i++)
                {
                    textProcessor.AppendTextItem(i, count, selectedItems.ElementAt(i), buffer);
                }

                return(buffer.ToString());
            }
            catch (Exception ex)
            {
                logService.Write(LogEntryType.Warning, "Error occured while appending text item in '{0}':  {1}", textProcessor.GetType().Name, ex.Message);
                return(string.Empty);
            }
        }
示例#23
0
        public string GenerateTextReport(ITextProcessor txtProcessor)
        {
            string report = txtProcessor.AddHeader($"{this.customerName}'s Rental Record");

            foreach (var rental in this.customerRentals)
            {
                var amount = rental.GetRentalAmount();
                var title  = txtProcessor.AddTitle(rental.GetItemTitle());

                report += txtProcessor.AddLine($"{title}{amount}");
            }

            var footerContent = txtProcessor.AddLine($"Amount owed is {this.totalAmount}");

            footerContent += txtProcessor.Add($"{this.customerName} has {this.frequentRentPoints} frequent renter points");

            report += txtProcessor.AddFooter(footerContent);
            return(report);
        }
        public bool AddItem(string roomName, InventoryItem item, out InventoryItem droppedItem, ITextProcessor textProcessor)
        {
            Guard.NullParameter(roomName, () => roomName);
            Guard.NullParameter(item, () => item);

            using (var session = _documentStore.OpenSession())
            {
                var inventory = session.Query<Inventory>().Customize(x => x.WaitForNonStaleResults()).SingleOrDefault(x => x.Room == roomName);
                if (inventory == null)
                {
                    inventory = new Inventory
                    {
                        Room = roomName,
                        Items = new List<InventoryItem>()
                    };

                    session.Store(inventory);
                }

                droppedItem = null;

                if (inventory.Items.Any(x => textProcessor.SimplifiedEquals(x.Value, item.Value)))
                {
                    session.SaveChanges();

                    return true;
                }

                if (inventory.Items.Count >= _inventoryCapacity)
                {
                    var itemIndex = _randomNumberProvider.Next(_inventoryCapacity);
                    droppedItem = inventory.Items[itemIndex];
                    inventory.Items.RemoveAt(itemIndex);
                }

                inventory.Items.Add(item);
                session.SaveChanges();

                return false;
            }
        }
示例#25
0
 public xTextFile(string filePath)
 {
     this.words = new List <xWord>();
     //  this.frequencies = new List<xWordFrequencies>();
     this.filePath = filePath;
     fileName      = (new FileInfo(filePath)).Name;
     if (fileName.EndsWith(".doc"))
     {
         Processor = DocProcessor.GetInstance();
     }
     else if (fileName.EndsWith("docx"))
     {
         Processor = DocxProcessor.GetInstance();
     }
     else if (fileName.EndsWith("htm") || fileName.EndsWith("html"))
     {
         Processor = HtmlProcessor.GetInstance();
     }
     else if (fileName.EndsWith("odt"))
     {
         Processor = OdtProcessor.GetInstance();
     }
     else if (fileName.EndsWith("pdf"))
     {
         Processor = PdfProcessor.GetInstance();
     }
     else if (fileName.EndsWith("rtf"))
     {
         Processor = RtfProcessor.GetInstance();
     }
     else if (fileName.EndsWith("txt"))
     {
         Processor = TxtProcessor.GetInstance();
     }
     else if (fileName.EndsWith("xlsx"))
     {
         Processor = XlsProcessor.GetInstance();
     }
 }
示例#26
0
        public async Task RunAsync()
        {
            while (true)
            {
                ProviderOption   providerOption   = _providerSettingsProvider.GetProviderOption();
                ProviderSettings providerSettings = _providerSettingsProvider.GetProviderSettings(providerOption);

                SaverOption   saverOption   = _saverSettingsProvider.GetSaverOptions();
                SaverSettings saverSettings = _saverSettingsProvider.GetSaverSettings(saverOption);

                ProcessingOption processingOption = _processingSettingsProvider.GetProcessingOption();

                ITextProvider          provider  = GetTextProvider(providerSettings);
                ITextProcessor         processor = GetTextProcessor(processingOption);
                IProcessingResultSaver saver     = GetResultSaver(saverSettings);

                var text = provider.GetTextAsync(CancellationToken.None);
                IProcessingResult result = await processor.GetResultAsync(text, CancellationToken.None);

                await saver.SaveAsync(result, CancellationToken.None);
            }
        }
示例#27
0
 public CommentAndStringProcessor(ITextProcessor textProcessor) : base(textProcessor)
 {
 }
示例#28
0
 public SentenceFactory(ITextProcessor textProcessor)
 {
     _textProcessor = textProcessor;
 }
示例#29
0
 public ResumePreprocess(IStopwordsFile stopwords, ITextProcessor textProcessor) : base(textProcessor)
 {
     this.stopwords = stopwords;
 }
示例#30
0
 public TextProcessorDecorator(ITextProcessor textProcessor)
 {
     this.textProcessor = textProcessor;
 }
示例#31
0
 public TfIdfCalc(ITextProcessor textProcessor)
 {
     this.textProcessor = textProcessor;
 }
示例#32
0
 public KeywordProcessor(ITextProcessor textProcessor, HashSet <string> keywords, string template) : base(textProcessor)
 {
     this.keywords = keywords;
     this.template = template;
 }
 public void SetTextProcessor(ITextProcessor aTextProcessor)
 {
     this.mTextProcessor = aTextProcessor;
 }
 public static ITextProcessor Then(
     this ITextProcessor first, ITextProcessor next) =>
 first is DoNothing ? next
     : next is DoNothing ? first
     : new ChainedProcessor(first, next);
示例#35
0
 public SubtitlesBuilder Using(ITextProcessor processor)
 {
     this.Processing = this.Processing.Then(processor);
     return(this);
 }
示例#36
0
 public virtual void ProcessElement(ITextProcessor processor)
 {
     string [] words = processor.ProcessText(header+ " " +body);
     if (words.Length < 1)
         return;
     this.fullStemmed = words;
 }