public void BoldlyGoTest()
        {
            var model = new ApplicationModel(new TracingWriterEnvironment());

            var script = new[]
            {
                "space",
                "the final frontier",
                "these are the voyages of the starship enterprise",
                "its five year mission",
                "to explore strange new worlds",
                "to seek out new life",
                "and new civilizations",
                "to boldly go where no man has gone before"
            };

            for (var line = 0; line < script.Length - 1; line++)
            {
                var lineSequence = TileSequence.FromRaw(script[line]);

                ApplicationRobotAction action;
                do
                {
                    action = ApplicationRobot.GetNextCompletionAction(model, lineSequence);
                    action.ExecuteItem(model);
                }while (!action.IsComplete);
            }

            var sequence = TileSequence.FromRaw(script[^ 1]);
        private static void RawSanityCheck(string raw)
        {
            var sequence = TileSequence.FromRaw(raw);

            SequenceSanityCheck(sequence);

            var rawRemade = sequence.ToRaw();

            Assert.AreEqual(raw, rawRemade);
        }
Ejemplo n.º 3
0
        private void OnTextChanged(object sender, RoutedEventArgs e)
        {
            var box  = (TextBox)sender;
            var text = box.Text;

            var sequence = TileSequence.FromRaw(text);

            ItemsContainer.Items.Clear();
            foreach (var child in sequence)
            {
                ItemsContainer.Items.Add(new TileVisualizationElement(child.Type, child.Content, TileColor.Text, TileColor.HeadBackground));
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var path = args[0];

            using (var stream = File.OpenRead(path))
            {
                var sentences = EpubStreamHelper.StreamToSentences(stream);

                foreach (var sentence in sentences)
                {
                    var sequence  = TileSequence.FromRaw(sentence);
                    var utterance = new UtteranceData(sequence, true);
                    var line      = utterance.ToLine();
                    Console.WriteLine(line);
                }
            }
        }
        public void JackAmpJillTest()
        {
            var sequence = TileSequence.FromRaw("Jack & Jill");
            var started  = new DateTimeOffset(1963, 12, 5, 12, 30, 45, 123, TimeSpan.FromMinutes(7 * 60));
            var duration = TimeSpan.FromSeconds(5 * 60);
            var keyCount = 42;

            var utterance = new UtteranceData(sequence, started, duration, keyCount);

            var line = utterance.ToLine();

            Assert.AreEqual("<U Started=\"1963-12-05T12:30:45.1230000+07:00\" Duration=\"300000\" KeyCount=\"42\"><T>Jack</T><T>&amp;</T><T>Jill</T></U>", line);

            var actual = UtteranceData.FromLine(line);

            Assert.AreEqual(sequence, actual.Sequence);
            Assert.AreEqual(started, actual.Started);
            Assert.AreEqual(duration, actual.Duration);
            Assert.AreEqual(keyCount, actual.KeyCount);
        }
        private static void MultiTest(string sentence, int expectedFirstClicks, int expectedSecondClicks, int expectedEmptyClicks, int expectedClicksWithRandomErrors, [CallerMemberName] string caller = null)
        {
            var words = TileSequence.FromRaw(sentence);

            MultiTest(words, expectedFirstClicks, expectedSecondClicks, expectedEmptyClicks, expectedClicksWithRandomErrors, caller);
        }
Ejemplo n.º 7
0
        private void OnCursedTextChanged(object sender, RoutedEventArgs e)
        {
            var box  = (TextBox)sender;
            var text = box.Text;

            var sequence = TileSequence.FromRaw(text);

            var start  = box.SelectionStart;
            var length = box.SelectionLength;

            Debug.WriteLine($"Selection is {start} for {length}");

            var list = new List <TileVisualizationElement>();

            var charPosition = 0;
            var tilePosition = 0;

            while (tilePosition < sequence.Count &&
                   charPosition + sequence[tilePosition].Content.Length <= start)
            {
                list.Add(new TileVisualizationElement(sequence[tilePosition].Type, sequence[tilePosition].Content, TileColor.Text, TileColor.HeadBackground));

                charPosition += sequence[tilePosition].Content.Length;
                tilePosition++;
                if (tilePosition < sequence.Count &&
                    !sequence[tilePosition - 1].IsPrefix &&
                    !sequence[tilePosition].IsSuffix)
                {
                    charPosition++;
                }
            }

            if (length == 0)
            {
                if (tilePosition < sequence.Count)
                {
                    if (charPosition < start)
                    {
                        var tile = sequence[tilePosition];
                        tilePosition++;

                        var prefix = TileData.Create(tile.Content.Substring(0, start - charPosition),
                                                     isPrefix: true,
                                                     isSuffix: tile.IsSuffix);
                        list.Add(new TileVisualizationElement(prefix.Type, prefix.Content, TileColor.Text, TileColor.HeadBackground));

                        var caret = TileData.Create("^");
                        list.Add(new TileVisualizationElement(caret.Type, caret.Content, TileColor.Text, TileColor.SuggestionPartBackground));

                        var suffix = TileData.Create(tile.Content.Substring(start - charPosition),
                                                     isPrefix: tile.IsPrefix,
                                                     isSuffix: true);
                        list.Add(new TileVisualizationElement(suffix.Type, suffix.Content, TileColor.Text, TileColor.HeadBackground));
                    }
                    else
                    {
                        var caret = TileData.Create("^",
                                                    isPrefix: start == charPosition,
                                                    isSuffix: start < charPosition);
                        list.Add(new TileVisualizationElement(caret.Type, caret.Content, TileColor.Text, TileColor.SuggestionPartBackground));
                    }
                }
                else
                {
                    var caret = TileData.Create("^", isSuffix: true);
                    list.Add(new TileVisualizationElement(caret.Type, caret.Content, TileColor.Text, TileColor.SuggestionPartBackground));
                }
            }
            else
            {
            }

            while (tilePosition < sequence.Count)
            {
                list.Add(new TileVisualizationElement(sequence[tilePosition].Type, sequence[tilePosition].Content, TileColor.Text, TileColor.HeadBackground));
                tilePosition++;
            }

            CursedContainer.Items.Clear();
            foreach (var child in list)
            {
                CursedContainer.Items.Add(child);
            }
        }