Ejemplo n.º 1
0
 public TextController(TextResourceManager textResourceManager, ITextConverter textConverter, SearchManager searchManager, IPageWithHtmlTagsCreator pageWithHtmlTagsCreator)
 {
     m_textResourceManager     = textResourceManager;
     m_textConverter           = textConverter;
     m_searchManager           = searchManager;
     m_pageWithHtmlTagsCreator = pageWithHtmlTagsCreator;
 }
Ejemplo n.º 2
0
 public UpdateService(IShopService shopService, IBotService botService, ITrackingRepository trackingRepository, ITextConverter textConverter)
 {
     _shopService        = shopService ?? throw new ArgumentNullException(nameof(shopService));
     _botService         = botService ?? throw new ArgumentNullException(nameof(botService));
     _trackingRepository = trackingRepository ?? throw new ArgumentNullException(nameof(trackingRepository));
     _textConverter      = textConverter ?? throw new ArgumentNullException(nameof(textConverter));
 }
Ejemplo n.º 3
0
        internal Collection(string tag, ITextRepository textRepository, ITextConverter textConverter)
        {
            ValidateCollectionName(tag);

            this.tag            = tag;
            this.textRepository = textRepository;
            TextConverter       = textConverter;
        }
Ejemplo n.º 4
0
        public string Convert(ITextConverter converter)
        {
            if (converter == null)
            {
                throw new ArgumentNullException($"{nameof(converter)} is null.");
            }

            return(converter.Convert(parts));
        }
Ejemplo n.º 5
0
        static void Train_Test(string train, string test, ITextConverter textConverter)
        {
            string path = Path.Combine(Constants.SPP_RootPath, @"model\Sentiment");

            new LearnerConsole(path, textConverter, classifier).Learn(train, true, true, c_coll);
            string root = Constants.SPP_RootPath;

            Test(root, test, textConverter);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Host a new network server
        /// </summary>
        /// <param name="directory">Path server will save data to
        /// <para>Example:  @"C:\MyTemp\Embark\Server\"</para></param>
        /// <param name="port">port to use, default set to 8030</param>
        /// <param name="textConverter">Custom converter between objects and text.
        /// <para>If parameter is NULL, the textConverter is set to default json converter.</para>
        /// </param>
        public Server(string directory, int port = 8030, ITextConverter textConverter = null)
        {
            if (textConverter == null)
                textConverter = new JavascriptSerializerTextConverter();

            var store = new DiskDataStore(directory);
            var textRepository = new LocalRepository(store, textConverter);

            Uri url = new Uri("http://localhost:" + port + "/embark/");
            webHost = new WebServiceHost(textRepository, url);
        }
Ejemplo n.º 7
0
        public LocalRepository(IDataStore dataStore, ITextConverter textComparer)
        {
            this.dataStore    = dataStore;
            this.textComparer = textComparer;

            var futureTimeStamp = System.DateTime.Now.AddMilliseconds(100).Ticks;

            keyProvider = new DocumentKeySource(futureTimeStamp);

            hashLock = new HashLock(avaliableLocks: 2000);
        }
Ejemplo n.º 8
0
        public LocalRepository(IDataStore dataStore, ITextConverter textComparer)
        {
            this.dataStore = dataStore;
            this.textComparer = textComparer;

            var futureTimeStamp = System.DateTime.Now.AddMilliseconds(100).Ticks;

            keyProvider = new DocumentKeySource(futureTimeStamp);

            hashLock = new HashLock(avaliableLocks: 2000);
        }
Ejemplo n.º 9
0
 private void RaiseIfArgumentsAreIncorrect(IDirectionChooser <TextType> chooser,
                                           ITextConverter <TextPart, MdConvertedItem> converter)
 {
     if (chooser == null)
     {
         throw new ArgumentException("Chooser can't be null");
     }
     if (converter == null)
     {
         throw new ArgumentException("Converter can't be null");
     }
 }
Ejemplo n.º 10
0
        public static async Task <string> Translate(this ITurnContext context, string text)
        {
            string         translateText = text;
            ITextConverter textConverter = context.Get <ITextConverter>();

            if (textConverter != null)
            {
                var language = GetLanguageForTranslate(context);
                translateText = await textConverter.Translate(language, text);
            }
            return(translateText);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Host a new network server
        /// </summary>
        /// <param name="directory">Path server will save data to
        /// <para>Example:  @"C:\MyTemp\Embark\Server\"</para></param>
        /// <param name="port">port to use, default set to 8030</param>
        /// <param name="textConverter">Custom converter between objects and text.
        /// <para>If parameter is NULL, the textConverter is set to default json converter.</para>
        /// </param>
        public Server(string directory, int port = 8030, ITextConverter textConverter = null)
        {
            if (textConverter == null)
            {
                textConverter = new JavascriptSerializerTextConverter();
            }

            var store          = new DiskDataStore(directory);
            var textRepository = new LocalRepository(store, textConverter);

            Uri url = new Uri("http://localhost:" + port + "/embark/");

            webHost = new WebServiceHost(textRepository, url);
        }
Ejemplo n.º 12
0
        public static void ValidateUpload <T>(this ITextConverter converter, T sourceObject, string convertedText)
        {
            var reconvertedObject = converter.ToObject <object>(convertedText);

            var reconvertToText = converter.ToText(reconvertedObject);

            if (convertedText != reconvertToText)
            {
                throw new ArgumentException(string.Format("Could not convert {0} consistently.\r\n"
                                                          + "Either the object is not a POCO with public get and set properties,"
                                                          + "or your ITextConverter {1} does not suppport the type {2}.",
                                                          sourceObject.ToString(), converter.ToString(), typeof(T).ToString()));
            }
        }
Ejemplo n.º 13
0
        static void Test(string path, string file, ITextConverter textConverter)
        {
            string root = Path.Combine(Constants.SPP_RootPath, @"model\sentiment\learning\");

            string[] dirs = Directory.GetDirectories(root);
            int      max  = 0;

            foreach (string dir in dirs)
            {
                string name = Path.GetFileName(dir);
                bool   run  = true;
                foreach (char ch in name)
                {
                    if (!char.IsDigit(ch))
                    {
                        run = false;
                        break;
                    }
                }

                if (!run)
                {
                    continue;
                }

                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.WriteLine("C VALUE AT: {0}", c_coll[Int32.Parse(name)]);
                Console.ResetColor();

                SECoreImpl      learnCoreImpl = CreateLearningCoreImpl(path, Int32.Parse(name));
                ISemanticTagger lexiconTagger = new LexiconSentimentTagger(textConverter.Tokenizer);
                SentimentEngine engine        = new SentimentEngine(textConverter, lexiconTagger, learnCoreImpl);

                SentimentEvaluator evaluator = new SentimentEvaluator(engine);

                evaluator.Evaluate(file, true, true);

                if (++max >= c_coll.Length)
                {
                    break;
                }
            }
        }
Ejemplo n.º 14
0
        public TimerService(
            ITrackingRepository trackingRepository,
            IPullAndBearClient pullAndBearClient,
            IBershkaClient bershkaClient,
            IBotService botService,
            ITextConverter textConverter,
            IUpdateInfoHelper updateInfoHelper)
        {
            _trackingRepository = trackingRepository ?? throw new ArgumentNullException(nameof(trackingRepository));
            _pullAndBearClient  = pullAndBearClient ?? throw new ArgumentNullException(nameof(pullAndBearClient));
            _bershkaClient      = bershkaClient ?? throw new ArgumentNullException(nameof(bershkaClient));
            _botService         = botService ?? throw new ArgumentNullException(nameof(botService));
            _textConverter      = textConverter ?? throw new ArgumentNullException(nameof(textConverter));
            _updateInfoHelper   = updateInfoHelper ?? throw new ArgumentNullException(nameof(updateInfoHelper));

            var existedItems = _trackingRepository.GetItemsAsync().Result;

            itemsQueue = existedItems.Any() ? new Queue <Item>(existedItems) : new Queue <Item>();

            timer           = new Timer(10000); // 10 sec
            timer.Elapsed  += OnTimedEvent;
            timer.AutoReset = true;
            timer.Enabled   = true;
        }
 public ArrayRunElementSegment(string name, ElementContentType type, int length, ITextConverter converter = null) => (Name, Type, Length, TextConverter) = (name, type, length, converter);
Ejemplo n.º 16
0
 public RenderMdToHtml(IDirectionChooser <TextType> chooser, ITextConverter <TextPart, MdConvertedItem> converter)
 {
     RaiseIfArgumentsAreIncorrect(chooser, converter);
     this.chooser   = chooser;
     this.converter = converter;
 }
Ejemplo n.º 17
0
 public Subtitle(SubRip subrip)
 {
     _subFormat  = subrip;
     _paragraphs = new List <Paragraph>();
     FileName    = "Untitled";
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Modify a local database
 /// </summary>
 /// <param name="directory">The path of where to save data
 /// <para>Example: @"C:\MyTemp\Embark\Local\"</para>
 /// </param>
 /// <param name="textConverter">Custom converter between objects and text.
 /// <para>If parameter is NULL, the textConverter is set to default json converter.</para>
 /// </param>
 /// <returns>Client with db commands</returns>>
 public Client(string directory, ITextConverter textConverter = null)
     : this(new DiskDataStore(directory), textConverter)
 {
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Get a connection to a server database
        /// </summary>
        /// <param name="address">IP Address / DNS Name of server. Example: "220.114.0.12" or "srv-embark-live"</param>
        /// <param name="port">Port used by server</param>
        /// <param name="textConverter">Custom converter between objects and text used on the server
        /// <para>If parameter is NULL, the textConverter is set to default json converter.</para>
        /// </param>
        /// <returns>Client with db commands</returns>>
        public Client(string address, int port, ITextConverter textConverter = null)
        {
            this.textConverter = textConverter ?? new JavascriptSerializerTextConverter();

            textRepository = new WebServiceRepository(address, port);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Get a temporary in-memory-only database connection
 /// </summary>
 /// <returns>Runtime Client with db commands</returns>
 public static Client GetCachedDB(string directory, ITextConverter textConverter = null, int maxAsyncOperations = 100)
 => new Client(new CachedDataStore(directory, maxAsyncOperations), textConverter);
Ejemplo n.º 21
0
        /// <summary>
        /// Modify a custom database
        /// </summary>
        /// <param name="dataStore">Custom data store implementation to save data</param>
        /// <param name="textConverter">Custom converter between objects and text.
        /// <para>If parameter is NULL, the textConverter is set to default json converter.</para>
        /// </param>
        /// <returns>Client with db commands</returns>>
        public Client(IDataStore dataStore, ITextConverter textConverter = null)
        {
            this.textConverter = textConverter ?? new JavascriptSerializerTextConverter();

            textRepository = new LocalRepository(dataStore, this.textConverter);
        }
Ejemplo n.º 22
0
 public BotSample(ITranslateHandler translateHandler, IDialogFactory dialogFactory, ILuisRecognizer recognizer, ITextConverter textConverter, BotAccessors botAccessors) :
     base(translateHandler, null, dialogFactory, recognizer, textConverter)
 {
     Dialogs = dialogFactory.UseDialogAccessor(botAccessors.DialogStateAccessor)
               .Create <StockDialog>()
               .Create <TextPrompt>("prompt")
               .Build();
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Get a temporary in-memory-only database connection
 /// </summary>
 /// <returns>Runtime Client with db commands</returns>
 public static Client GetRuntimeDB(ITextConverter textConverter = null)
 => new Client(new RuntimeDataStore(), textConverter);
Ejemplo n.º 24
0
 public LuisChatBot(ITranslateHandler translateHandler, IMessageRepository messageRepository, IDialogFactory dialogFactory, ILuisRecognizer recognizer, ITextConverter textConverter, ILogger <BotBase> logger)
     : this(translateHandler, messageRepository, dialogFactory, logger)
 {
     _recognizer    = recognizer;
     _textConverter = textConverter;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// 为匹配的成员表达式添加转换器。
        /// </summary>
        public CompositeJsonConverter <T> AddConverter <V>(Expression <Func <T, V> > expression, ITextConverter converter)
        {
            if (expression is LambdaExpression lambda)
            {
                if (lambda.Body is MemberExpression mbrExp && mbrExp.Member.MemberType == MemberTypes.Property)
                {
                    _converters.Add(mbrExp.Member as PropertyInfo, converter);
                }
            }

            return(this);
        }
Ejemplo n.º 26
0
 public LuisChatBot(ITranslateHandler translateHandler, IMessageRepository messageRepository, IDialogFactory dialogFactory, ILuisRecognizer recognizer, ITextConverter textConverter)
     : this(translateHandler, messageRepository, dialogFactory, recognizer, textConverter, null)
 {
 }
Ejemplo n.º 27
0
 public BotDemo(ITranslateHandler translateHandler, IDialogFactory dialogFactory, ILuisRecognizer recognizer, ITextConverter textConverter, BotAccessors accessors)
     : base(translateHandler, null, dialogFactory, recognizer, textConverter)
 {
     Dialogs = dialogFactory.UseDialogAccessor(accessors.DialogStateAccessor)
               .Create <AvionDialog>(AvionDialog.ID, accessors.AvionStateAccessor)
               .Create <TextPrompt>("prompt")
               .Build();
 }
 public AnalyzeTextAppService()
 {
     textConveter          = new TextConverter();
     textEntityExtraction  = new TextEntityExtraction();
     textSentimentAnalyzer = new TextSentimentAnalyzer();
 }