private void AnalyseText()
        {
            IsBusy = true;
            Sentences.Clear();
            var text = Text.Replace("\r\n", "\r");
            // 去除行首的发言人
            {
                var reg = new Regex(@"^.*:", RegexOptions.Multiline);
                text = reg.Replace(text, "");
            }
            var fkf = new[] { '.', '\"', '\r', '?', '!' };
            var cs  = text.Split(fkf);

            foreach (var l in cs)
            {
                var s = l.Trim();
                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }
                Sentences.Add(new SentenceData
                {
                    Sentence = l.Trim()
                });
            }
            InitRange();
            RaisePropertyChanged("CanSave");
            FindSign();
            MakeUtfText();
            IsBusy = false;
        }
Beispiel #2
0
        public TokenizedText(GraphemeString graphemeString, TokenRange tokenRange)
        {
            GraphemeString = graphemeString;
            TokenRange     = tokenRange;

            for (TokenNode start = tokenRange.Start, node = tokenRange.Start; ;)
            {
                if (node.Value.Type == TokenType.FullStop || node.Value.Type == TokenType.QuestionMark || node.Value.Type == TokenType.ExclamationPoint)
                {
                    for (node = node.Next; node.Value.Type == TokenType.FullStop; node = node.Next)
                    {
                        ;
                    }
                    Sentences.Add(new TokenizedSentence(new TokenRange(start, node)));
                    start = node;
                    continue;
                }

                if (node.Value.Type == TokenType.Eof)
                {
                    if (start != node)
                    {
                        Sentences.Add(new TokenizedSentence(new TokenRange(start, node)));
                    }

                    break;
                }

                node = node.Next;
            }
        }
Beispiel #3
0
 public Text(IEnumerable <ISentence> sentences) : this()
 {
     foreach (var sentence in sentences)
     {
         Sentences.Add(sentence);
     }
 }
Beispiel #4
0
 public void AddSentence(int sentence)
 {
     if (!Sentences.Contains(sentence))
     {
         Sentences.Add(sentence);
     }
 }
Beispiel #5
0
 public void Add(ISentence sentence)
 {
     if (sentence != null)
     {
         Sentences.Add(sentence);
     }
 }
 // Handle the KeyDown Event
 void gHook_KeyDown(object sender, KeyEventArgs e)
 {
     TempSentence += ((char)e.KeyValue).ToString();
     if (e.KeyCode == Keys.Return)
     {
         Sentences.Add(TempSentence);
         //OnReturn(this, TempSentence);
         TempSentence = String.Empty;
     }
 }
Beispiel #7
0
 public void AddStatement(Sentence sentence)
 {
     Sentences.Add(sentence);
     foreach (string l in sentence.Symbols)
     {
         if (!Symbols.Contains(l) && l != "")
         {
             Symbols.Add(l);
         }
     }
 }
Beispiel #8
0
        /// <summary>
        ///		Genera un bloque
        /// </summary>
        internal ProgramSentencesBuilder WithBlock(string message)
        {
            SentenceBlock block = new SentenceBlock
            {
                Message = message
            };

            // Añade el bloque a las sentencias
            Sentences.Add(block);
            // Crea un nuevo generador de sentencias
            return(new ProgramSentencesBuilder(Main, this, block.Sentences));
        }
        public void Add(SentenceItem sentence)
        {
            if (sentence == null)
            {
                throw new ArgumentNullException(nameof(sentence));
            }

            sentence.Index = Sentences.Count;
            Sentences.Add(sentence);
            if (!string.IsNullOrEmpty(Text))
            {
                Text += " ";
            }

            Text += sentence.Text;
            Text  = Text.Trim();
        }
        private async void SentenceClick(string obj)
        {
            Translations.Clear();
            Synonyms.Clear();
            Antonyms.Clear();
            Sentences.Clear();

            var reply = await new OxfordDictionaryMVVMService().GetSentenceAsync(chosenSrc, obj);

            if (reply != null)
            {
                foreach (var result in reply.results)
                {
                    foreach (var lexicalEntry in result.lexicalEntries)
                    {
                        foreach (var sentence in lexicalEntry.sentences)
                        {
                            Sentences.Add(sentence.text);
                        }
                    }
                }
            }

            // exception handling
            else if (ChosenSrc.ToString() != "en" && ChosenSrc.ToString() != "es")
            {
                var messageDialog = new MessageDialog("Sentences are not supported in this language at present.")
                {
                    Title = "Warning"
                };
                messageDialog.Commands.Add(new UICommand("Close"));

                await messageDialog.ShowAsync();
            }
            else
            {
                var messageDialog = new MessageDialog("There is no example sentence for that word!")
                {
                    Title = "Warning"
                };

                messageDialog.Commands.Add(new UICommand("Close"));

                await messageDialog.ShowAsync();
            }
        }
Beispiel #11
0
        public MascotEditor(Mascot Mascot)
        {
            InitializeComponent();
            DataContext = this;
            MascotMenu  = MascotV.ContextMenu.Items[0] as MenuItem;

            this.Mascot = Mascot;
            foreach (Voice v in Mascot.Voices)
            {
                Sentences.Add(v);
            }

            MascotV.MascotSources.Add(new BitmapImage(new Uri(Mascot.ImageFilePath)));

            Sentences.CollectionChanged += Sentences_CollectionChanged;
            MascotMenu.ItemsSource       = Sentences.Where((v) => v.OnManual).ToList();
        }
Beispiel #12
0
        public override void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);

            foreach (var node in parseNode.ChildNodes)
            {
                // copy sentences to block
                if (node.AstNode is AuxiliaryNode)
                {
                    var auxNode = node.AstNode as AuxiliaryNode;

                    foreach (var s in auxNode.ChildNodes.OfType <Sentence>())
                    {
                        Sentences.Add(s);
                    }
                }
            }
        }
Beispiel #13
0
        protected void BuildSentences()
        {
            int currentIndex = 0;

            for (int index = 0; index < Text.Length; index++)
            {
                // If we're at the end, accept the sentence.
                if (index == (Text.Length - 1) && currentIndex != index)
                {
                    Sentence sentence = new Sentence(
                        Text.Substring(currentIndex, index - currentIndex).Trim(),
                        currentIndex, index);
                    Sentences.Add(sentence);
                }

                if (!Sentence.Delimiters.Contains(Text[index]))
                {
                    continue;
                }

                // If we're at the end of the sentence (scanning ahead one character
                // means we exceed the length) we can stop.
                if (Text.Length <= (index + 1))
                {
                    continue;
                }

                // If we find a delimiter, scan ahead for whitespace
                if (Sentence.Whitespace.Contains(Text[index + 1]))
                {
                    Sentence sentence = new Sentence(
                        Text.Substring(currentIndex, index - currentIndex).Trim(),
                        currentIndex, index);
                    Sentences.Add(sentence);
                    currentIndex = index + 1;
                }
            }
        }
Beispiel #14
0
        public void ParseText(string text)
        {
            string[] words = text.Split(' ', '\r'); //space and line feed characters are the ends of words.

            Sentence cursentence = new Sentence();

            Sentences.Add(cursentence);

            StringBuilder originalSentence = new StringBuilder();

            foreach (string word in words)
            {
                string locWord = word;

                if (locWord.StartsWith("\n") && word.Length > 2)
                {
                    locWord = locWord.Replace("\n", "");
                }

                originalSentence.AppendFormat("{0} ", locWord);

                cursentence.Words.Add(new Word(locWord));

                AddWordCount(locWord);

                if (IsSentenceBreak(locWord))
                {
                    cursentence.OriginalSentence = originalSentence.ToString();

                    cursentence = new Sentence();

                    originalSentence = new StringBuilder();

                    Sentences.Add(cursentence);
                }
            }
        }
Beispiel #15
0
 public void Add(Sentence item)
 {
     Sentences.Add(item);
 }
Beispiel #16
0
    public override void DrawWindow()
    {
        base.DrawWindow();

        Event e = Event.current;

        NumText = EditorGUILayout.IntField("Number of Sentences", NumText);
        if (NumText < 0)
        {
            NumText = 0;
        }

        EditorGUILayout.LabelField("Dialogue:");
        EditorGUILayout.Space();

        int difference = Mathf.Abs(NumText - Sentences.Count);

        if (Sentences.Count < NumText)
        {
            for (int i = 0; i < difference; i++)
            {
                Sentences.Add("Enter Dialogue Here");
            }
        }
        else if (Sentences.Count > NumText)
        {
            if (NumText != 0)
            {
                Sentences.RemoveRange(NumText - 1, difference);
            }
            else
            {
                Sentences.Clear();
            }
        }

        for (int i = 0; i < inputRects.Count; i++)
        {
            if (e.type == EventType.Repaint)
            {
                inputRects[i] = GUILayoutUtility.GetLastRect();
            }
        }

        for (int i = 0; i < outputRects.Count; i++)
        {
            if (e.type == EventType.Repaint)
            {
                outputRects[i] = GUILayoutUtility.GetLastRect();
            }
        }

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, false);
        for (int i = 0; i < Sentences.Count; i++)
        {
            Sentences[i] = EditorGUILayout.TextArea(Sentences[i], GUILayout.Height(30));
        }
        EditorGUILayout.EndScrollView();

        dialogueType.windowRect  = windowRect;
        dialogueType.index       = index;
        dialogueType.sentences   = Sentences;
        dialogueType.inputRects  = inputRects;
        dialogueType.inputCount  = inputRects.Count;
        dialogueType.outputRects = outputRects;
        dialogueType.outputCount = outputRects.Count;

        if (GUILayout.Button("Clear All", GUILayout.Height(20)))
        {
            NumText = 0;
            Sentences.Clear();
            inputs.Clear();
            inputRects.Clear();
            outputs.Clear();
            outputRects.Clear();
        }
    }
Beispiel #17
0
    //명령어 분해
    //"s(x y z) rz0 ry0 rx0 t(x y z)";
    public void CommandDecomposition(Sentences sts)
    {
        //int L = sts.text - 1;

        //int start = -1;
        string temp = "";

        string[] split = null;
        Vector3  xyz   = Vector3.zero;

        if (Sentences.eKind.Translate == sts.kind || Sentences.eKind.Scale == sts.kind || Sentences.eKind.Quaternion == sts.kind)
        {
            temp  = sts.text.Trim('t', 's', 'q', ')', ' ');
            temp  = temp.Trim('(', ' ');
            temp  = temp.Trim();
            split = temp.Split(' ');

            foreach (string s in split)
            {
                if (s.Length != 0 && 'x' == s[0])
                {
                    temp = s.TrimStart('x');
                    if (false == float.TryParse(temp, out xyz.x))
                    {
                        xyz.x = 0;
                    }
                }
                if (s.Length != 0 && 'y' == s[0])
                {
                    temp = s.TrimStart('y');
                    if (false == float.TryParse(temp, out xyz.y))
                    {
                        xyz.y = 0;
                    }
                }
                if (s.Length != 0 && 'z' == s[0])
                {
                    temp = s.TrimStart('z');
                    if (false == float.TryParse(temp, out xyz.z))
                    {
                        xyz.z = 0;
                    }
                }
            }
            sts.Add(new Command(xyz));
        }
        if (Sentences.eKind.Rotate == sts.kind)
        {
            temp = sts.text.Trim('r', ' ');

            if (temp.Length != 0 && 'x' == temp[0])
            {
                float value = 0;
                temp = temp.TrimStart('x');
                if (false == float.TryParse(temp, out value))
                {
                    value = 0;
                }
                sts.Add(new Command(TRSParser.Command.eKind.X, value));
            }
            if (temp.Length != 0 && 'y' == temp[0])
            {
                float value = 0;
                temp = temp.TrimStart('y');
                if (false == float.TryParse(temp, out value))
                {
                    value = 0;
                }
                sts.Add(new Command(TRSParser.Command.eKind.Y, value));
            }
            if (temp.Length != 0 && 'z' == temp[0])
            {
                float value = 0;
                temp = temp.TrimStart('z');
                if (false == float.TryParse(temp, out value))
                {
                    value = 0;
                }
                sts.Add(new Command(TRSParser.Command.eKind.Z, value));
            }
        }
    }
Beispiel #18
0
 internal void Add(Contribution contribution)
 {
     Sentences.Add(contribution);
 }