public void Pattern()
        {
            SimplePhrase s = new SimplePhrase(new TestPartFactory(), "hello");

            Assert.AreEqual("hello", s.Pattern);

            s = new SimplePhrase(new TestPartFactory(), "The {TESTPART}.");
            Assert.AreEqual("The {TESTPART}.", s.Pattern);
        }
Esempio n. 2
0
        public async Task <IActionResult> PostJellySimpleHook([FromBody] SimplePhrase simplePhrase)
        {
            JellyPhrase phrase = await _languageService.ParseJellyfinSimplePhrase(simplePhrase.Content);

            await _loggingService.LogDebug("PostJellySimpleHook - parsed phrase.", $"Succesfully parsed the following phrase from the search term: {simplePhrase.Content}", phrase);

            if (string.IsNullOrWhiteSpace(phrase.SearchTerm))
            {
                return(BadRequest("Missing search content! Please specify a search term along with any optional filters."));
            }

            return(await ProcessJellyPhrase(phrase, nameof(PostJellySimpleHook)));
        }
Esempio n. 3
0
        private void OnTextGenerate(object sender, EventArgs e)
        {
            this._txResult.Clear();

            for (int i = 0; i < (int)this._nudNumberOfPhrases.Value; i++)
            {
                SimplePhrase phrase = this._language.CreateSimplePhrase();

                if (phrase != null)
                {
                    this._txResult.AppendText(phrase.ToString() + " ");
                }
            }
        }
Esempio n. 4
0
        public async Task <IActionResult> PostHomeySimpleHook([FromBody] SimplePhrase simplePhrase)
        {
            HomeyPhrase phrase = await _languageService.ParseHomeySimplePhrase(simplePhrase.Content);

            await _loggingService.LogDebug("PostHomeySimpleHook - parsed phrase.", $"Succesfully parsed the following phrase from the search term: {simplePhrase.Content}", phrase);

            if (string.IsNullOrWhiteSpace(phrase.WebhookId))
            {
                return(BadRequest($"No webhook found in phrase: {simplePhrase.Content}. Please make sure to include webhook keywords in phrase!"));
            }

            await _homeAssistantService.PostWebhook(phrase.WebhookId, phrase.Content);

            return(Ok($"Processing webhook \"{phrase.WebhookId}\"{(string.IsNullOrWhiteSpace(phrase.Content) ? string.Empty : $" with the content: \"{phrase.Content}\"" )}."));
        }
        static void Main(string[] args)
        {
            PartFactory f;

            f = PartFactory.GetPartFactory(@"TBCIR.Providers.Factory.TextFiles.dll", "TBCIR.Providers.Factory.TextFiles.TextFilesPartFactory");
            //f = PartFactory.GetPartFactory(@"TBCIR.Providers.Factory.MsAccess.dll", "TBCIR.Providers.Factory.MsAccess.MsAccessPartFactory");

            Console.WriteLine("Supported symbols: " + String.Join(" ", f.SupportedSymbols));

            Phrase p = new SimplePhrase(f, "The {ADJ} {N} is {ADJ} and {ADJ}.");

            Console.WriteLine(((SimplePhrase)p).Pattern);
            for (int i = 1; i <= 5; i++)
            {
                Console.WriteLine(p.GetRandomValue());
            }

            Console.WriteLine("Done");
            Console.ReadLine();
        }
        public void GetRandomValue_SimpleLiteralPattern()
        {
            SimplePhrase s = new SimplePhrase(new TestPartFactory(), "hello");

            Assert.AreEqual("hello", s.Pattern);
        }
        public void GetRandomValue_EmptyStringPattern()
        {
            SimplePhrase s = new SimplePhrase(new TestPartFactory(), "");

            Assert.AreEqual("", s.GetRandomValue());
        }