public IServiceCollection ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IWordsDictionary, BasicEnglishDictionary>();
            services.AddSingleton <INRCDictionary>(ctx =>
            {
                var dictionary = new NRCDictionary();
                dictionary.Load();
                return(dictionary);
            });

            services.AddSingleton <ISentenceTokenizerFactory, SentenceTokenizerFactory>();
            services.AddSingleton <IPOSTagger, NaivePOSTagger>();
            services.AddSingleton <BNCList>();
            services.AddSingleton <IPosTagResolver>(ctx => ctx.GetService <BNCList>());
            services.AddSingleton <IWordFrequencyList>(ctx => ctx.GetService <BNCList>());

            services.AddSingleton(ctx => WordTypeResolver.Instance);

            services.AddSingleton <IMessageCleanup>(ctx =>
            {
                var item           = new MessageCleanup();
                item.CleanCashTags = false;
                item.LowerCase     = false;
                return(item);
            });

            services.AddSingleton <IRawTextExtractor, RawWordExtractor>();
            services.AddSingleton <IMemoryCache>(ctx => new MemoryCache(new MemoryCacheOptions()));
            return(services);
        }
Exemplo n.º 2
0
        private void SetupAnomaly(ContainerBuilder builder)
        {
            logger.LogInformation("Setting up lexicon libraries");
            var tagger = new NaivePOSTagger(new BNCList(), WordTypeResolver.Instance);

            builder.RegisterInstance(tagger).As <IPOSTagger>();

            var dictionary = new NRCDictionary();

            dictionary.Load();
            builder.RegisterInstance(dictionary).As <INRCDictionary>();

            var inquirer = new InquirerManager();

            inquirer.Load();
            builder.RegisterInstance(inquirer).As <IInquirerManager>();

            builder.RegisterType <FrequencyListManager>().As <IFrequencyListManager>().SingleInstance();
            builder.RegisterType <StyleFactory>().As <IStyleFactory>();
            builder.RegisterType <AnomalyFactory>().As <IAnomalyFactory>();
            builder.RegisterType <SupervisedAnomaly>().As <ISupervisedAnomaly>();
            builder.RegisterType <DocumentReconstructor>().As <IDocumentReconstructor>();
            builder.RegisterType <DocumentExtractor>().As <IDocumentExtractor>();

            builder.RegisterType <EmbeddingVectorSource>().As <IDocumentVectorSource>();
            builder.RegisterType <SvmModelStorageFactory>().As <IModelStorageFactory>();

            logger.LogInformation("Downloading model...");
            var model = new Uri(Configuration["Anomaly:model"]);

            new DataDownloader(loggerFactory).DownloadFile(model, "resources").Wait();
            builder.Register(context => WordModel.Load("resources/model.bin")).SingleInstance();
        }
Exemplo n.º 3
0
        public void Setup()
        {
            PosTagger  = new NaivePOSTagger(new BNCList(), WordTypeResolver.Instance);
            Dictionary = new NRCDictionary();
            Dictionary.Load();
            var inquirer = new InquirerManager();

            inquirer.Load();
            StyleFactory = new StyleFactory(PosTagger, new NRCDictionary(), new FrequencyListManager(), inquirer);
            var factory = new SentenceTokenizerFactory(PosTagger, new RawWordExtractor(new BasicEnglishDictionary(), new MemoryCache(new MemoryCacheOptions())));

            Extraction = new SimpleWordsExtraction(factory.Create(true, false));
        }
 public NRCDictionaryTests()
 {
     dictionary = new NRCDictionary();
     dictionary.Load();
 }