public void ProcessValidationSample(SentenceData sample) { n_test_samples++; for (int iword = 1; iword < sample.CountWords() - 1; ++iword) { WordData token = sample.GetWord(iword); string wordform = token.GetWord().ToLower(); string lemma = gren.GetEntryName(token.GetEntryID()); if (IsUnknownLexem(lemma) || IsNumword(lemma)) { continue; } CheckData d = new CheckData(); d.POS_tag = tags.MatchTags(token, gren); d.wordform = wordform; d.lemma = lemma; check_data_list.Add(d); } return; }
private void Publish_Data_Click(object sender, RoutedEventArgs e) { using (FileStream DistanceFileWriter = System.IO.File.OpenWrite(StartTime.Month + "-" + StartTime.Day + "-" + StartTime.Year + " " + StartTime.Hour + "-" + StartTime.Minute + " movementtrack.xml")) { Write(("<movement date=\"" + StartTime.Month + "-" + StartTime.Day + "-" + StartTime.Year + " " + StartTime.Hour + "-" + StartTime.Minute + "\">"), DistanceFileWriter); while (TextData.Count > 0) { Write(TextData.Dequeue(), DistanceFileWriter); } while (SentenceData.Count > 0) { Write(SentenceData.Dequeue(), DistanceFileWriter); } while (WordData.Count > 0) { Write(WordData.Dequeue(), DistanceFileWriter); } while (PositionData.Count > 0) { Write(PositionData.Dequeue(), DistanceFileWriter); } Write("\r\n</movement>", DistanceFileWriter); System.Windows.Application.Current.Shutdown(); } }
public bool ProcessTrainingSample(SentenceData sample) { n_learn_samples++; for (int iword = 1; iword < sample.CountWords() - 1; ++iword) { WordData token = sample.GetWord(iword); string wordform = token.GetWord().ToLower(); if (wordform.Contains(" ")) { // кратные пробелы сокращаем до одинарных System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex("[ ]{2,}"); wordform = rx.Replace(wordform, " "); } string lemma = gren.GetEntryName(token.GetEntryID()); if (IsUnknownLexem(lemma) || IsNumword(lemma)) { continue; } int POS_tag = tags.MatchTags(token, gren); table.Store(POS_tag, wordform, lemma); n_learn_wordforms++; } return(true); }
private void LoadAudio(SentenceData data) { var start = TimeSpan.FromSeconds(data.Start); var end = TimeSpan.FromSeconds(data.End); var len = end - start; var trimmed = new AudioFileReader(AudioFile).Skip(start).Take(len); var path = "abc.avi"; WaveFileWriter.CreateWaveFile16(path, trimmed); mAudioService.UploadSentenceAudio(data.Sentence, path); }
private void Enter_Button_Click(object sender, RoutedEventArgs e) { SendKeys.SendWait("{Enter}"); string sentence = "\r\n\t<sentence>"; while (SentenceData.Count > 0) { sentence += SentenceData.Dequeue(); } sentence += "\r\n\t\t</sentence>"; TextData.Enqueue(sentence); SentenceData = new Queue <string>(); }
private void Enter_Button_Click(object sender, RoutedEventArgs e) { SendKeys.SendWait("{Enter}"); WordStack = new Stack <string>(); CenterBubble_Label.Content = ""; ReturnedToCenter = false; string sentence = "\r\n\t<sentence>"; while (SentenceData.Count > 0) { sentence += SentenceData.Dequeue(); } sentence += "\r\n\t\t</sentence>"; TextData.Enqueue(sentence); SentenceData = new Queue <string>(); BlueFlash = DateTime.Now; }
public void ProcessInputData(string all) { string[] lines = all.Split('\n'); sentenceDataArray = new SentenceData[lines.Length]; int lineIndex = 0; foreach (var line in lines) { string[] elements = line.Split(','); var data = new SentenceData(); data.main = elements[0]; data.substitutes = new string[elements.Length - 1]; for (int i = 1; i < elements.Length; i++) { data.substitutes[i - 1] = elements[i]; } sentenceDataArray[lineIndex] = data; lineIndex++; } }
public void RunWordSearch() { if (TrackedSkeleton != null) { Joint MotionHandJoint = (TrackedSkeleton.Joints[MotionHand]).ScaleTo(222, 1044); Joint MotionHandJointScaled = TrackedSkeleton.Joints[MotionHand].ScaleTo(1366, 768, 0.55f, 0.55f); Joint SelectionHandJoint = (TrackedSkeleton.Joints[SelectionHand]).ScaleTo(222, 656); Joint SelectionHandJointScaled = (TrackedSkeleton.Joints[SelectionHand]).ScaleTo(1366, 768, 0.55f, 0.55f); Point MotionHandPosition = new Point((MotionHandJointScaled.Position.X), (MotionHandJointScaled.Position.Y)); Point SelectionHandPosition = new Point((SelectionHandJointScaled.Position.X), (SelectionHandJointScaled.Position.Y)); //Move Cursor //SetCursorPos((int)(MotionHandPosition.X), (int)(MotionHandPosition.Y)); Point destination_top_left = theCanvas.PointFromScreen(MotionHandPosition); destination_top_left = Point.Add(destination_top_left, new System.Windows.Vector(Pointer_Ellipse.Width / -2, Pointer_Ellipse.Height / -2)); Canvas.SetTop(Pointer_Ellipse, destination_top_left.Y); Canvas.SetLeft(Pointer_Ellipse, destination_top_left.X); //Added data position to a queue of positions that will be loaded for each letter PositionData.Enqueue("\r\n\t\t\t\t<entry motionhand_x=\"" + MotionHandPosition.X + "\" motionhand_y=\"" + MotionHandPosition.Y + "\" selectionhand_x=\"" + SelectionHandPosition.X + "\" selectionhand_y=\"" + SelectionHandPosition.Y + "\" relative_timestamp=\"" + DateTime.Now.Subtract(StartTime).TotalMilliseconds + "\" />"); Gesture SelectionHandGesture = GestureTracker.track(TrackedSkeleton, TrackedSkeleton.Joints[SelectionHand], nui.NuiCamera.ElevationAngle); if (SelectionHandGesture != null && (SelectionHandGesture.id == GestureID.Push)) { foreach (System.Windows.Controls.Button beta in Buttons) { if (PointerOver(beta)) { if ((((string)(beta.Content)).Equals(last_char) && DateTime.Now.Subtract(last_char_time).TotalSeconds > 0.75) || (!((string)(beta.Content)).Equals(last_char))) { SendKeys.SendWait(beta.Content.ToString().ToLowerInvariant()); CurrentWord += (beta.Content.ToString().ToLowerInvariant()); string letter = ("\r\n\t\t\t<print char=\"" + (beta.Content.ToString().ToLowerInvariant()) + "\" selection_hand_distance=\"" + SelectionHandDistance + "\" motion_hand_distance=\"" + MotionHandDistance + "\""); while (PositionData.Count > 0) { letter += PositionData.Dequeue(); } PositionData = new Queue <string>(); letter += ("\r\n\t\t\t</print>"); WordData.Enqueue(letter); SelectionHandDistance = 0.0; MotionHandDistance = 0.0; last_char = (string)(beta.Content); last_char_time = DateTime.Now; } } } if (PointerOver(Button_Space)) { if ((((string)(Button_Space.Content)).Equals(last_char) && DateTime.Now.Subtract(last_char_time).TotalSeconds > 0.75) || (!((string)(Button_Space.Content)).Equals(last_char))) { SendKeys.SendWait(" "); string word = "\r\n\t\t<word text=\"" + CurrentWord + "\">"; CurrentWord = ""; while (WordData.Count > 0) { word += WordData.Dequeue(); } word += "\r\n\t\t</word>"; SentenceData.Enqueue(word); WordData = new Queue <string>(); last_char = (string)(Button_Space.Content); last_char_time = DateTime.Now; } } else if (PointerOver(Button_Backspace)) { if ((last_char.Equals("bksp") && DateTime.Now.Subtract(last_char_time).TotalSeconds > 0.75) || (!last_char.Equals("bksp"))) { SendKeys.SendWait("{Backspace}"); PositionData.Enqueue("\r\n\t\t\t\t<backspace motionhand_x=\"" + MotionHandPosition.X + "\" motionhand_y=\"" + MotionHandPosition.Y + "\" selectionhand_x=\"" + SelectionHandPosition.X + "\" selectionhand_y=\"" + SelectionHandPosition.Y + "\" relative_timestamp=\"" + DateTime.Now.Subtract(StartTime).TotalMilliseconds + "\" />"); last_char = "bksp"; last_char_time = DateTime.Now; } } } } }
public void ShowText(SentenceData sentenceData, Orientation orientation, int fontSize, float posX, float posY, int effectIndex, List <object> paramList, bool useGlobalParam = false) { rootCanvas.enabled = true; var txt = LeanPool.Spawn(txtPrefab); txt.transform.SetParent(rootCanvas.transform, false); txt.transform.localScale = Vector3.one; txt.text = sentenceData.main; var size = txt.rectTransform.sizeDelta; txt.alignment = TextAnchor.MiddleCenter; if (fontSize > 0) { txt.fontSize = fontSize; } else { fontSize = txt.fontSize; } var pos = new Vector3(); var val = Random.value; var range = val * 0.8f + 0.1f; var sinVal = (Mathf.Sin(range * 3.14f) + 1) / 2; //var range2 = sinVal * range; pos.y = corners[0].y * range + (corners[2].y) * (1 - range); pos.x = corners[0].x * range + (corners[2].x) * (1 - range); pos.x = posX >= 0? (corners[0].x * posX + corners[2].x * (1 - posX)):pos.x; pos.y = posY >= 0? (corners[0].y * posY + corners[2].y * (1 - posY)):pos.y; pos.z = 0; txt.transform.position = pos; if (orientation == Orientation.Horizontal) { size.y = fontSize + 2; txt.horizontalOverflow = HorizontalWrapMode.Overflow; txt.verticalOverflow = VerticalWrapMode.Overflow; } else { size.x = fontSize + 2; txt.horizontalOverflow = HorizontalWrapMode.Wrap; txt.verticalOverflow = VerticalWrapMode.Overflow; } txt.rectTransform.sizeDelta = size; int nextEffectIndex = effectIndex; float duration = 1; if (nextEffectIndex == 0) { var effect = txt.GetComponent <MovingFade>(); int dirX = val > 0.5f? 1:-1; int dirY = dirX != 0? 0 : (val > 0.5? 1 : -1); float speed = effect.speed; duration = effect.duration; effect.txtManager = this; effect.substitutes = sentenceData.substitutes; if (paramList != null) { for (int i = 0; i < paramList.Count; i++) { switch (i) { case 0: int.TryParse(paramList[i].ToString(), out dirX); break; case 1: int.TryParse(paramList[i].ToString(), out dirY); break; case 2: float.TryParse(paramList[i].ToString(), out speed); break; case 3: float.TryParse(paramList[i].ToString(), out duration); break; } } } else if (useGlobalParam) { duration = this.duration; dirX = (int)this.dirX; dirY = (int)this.dirY; speed = this.speed; } effect.speed = speed; effect.duration = duration; effect.dir = new Vector2(dirX, dirY); effect.cb += OnTextAnimationEnd; effect.enabled = true; } else if (nextEffectIndex == 1) { var effect = txt.GetComponent <Jitter>(); float factor = effect.factor; duration = effect.duration; effect.txtManager = this; effect.substitutes = sentenceData.substitutes; if (paramList != null) { for (int i = 0; i < paramList.Count; i++) { switch (i) { case 0: float.TryParse(paramList[i].ToString(), out factor); break; case 1: float.TryParse(paramList[i].ToString(), out duration); break; } } } else if (useGlobalParam) { duration = this.duration; factor = this.jitterFactor; } effect.factor = factor; effect.duration = duration; effect.cb += OnTextAnimationEnd; effect.enabled = true; } else if (nextEffectIndex == 2) { var effect = txt.GetComponent <TypeWord>(); effect.txtManager = this; effect.substitutes = sentenceData.substitutes; float interval = effect.typeInterval; duration = effect.duration; if (paramList != null) { for (int i = 0; i < paramList.Count; i++) { switch (i) { case 0: float.TryParse(paramList[i].ToString(), out interval); break; case 1: float.TryParse(paramList[i].ToString(), out duration); break; case 2: break; case 3: break; } } } else if (useGlobalParam) { duration = this.duration; interval = this.interval; } effect.duration = duration; effect.typeInterval = interval; effect.orientation = orientation; effect.cb += OnTextAnimationEnd; effect.enabled = true; } }
public void RunWordSearch() { if (TrackedSkeleton != null) { Joint MotionHandJoint = (TrackedSkeleton.Joints[MotionHand]).ScaleTo(222, 1044); Joint MotionHandJointScaled = TrackedSkeleton.Joints[MotionHand].ScaleTo(1366, 768, 0.55f, 0.55f); Joint SelectionHandJoint = (TrackedSkeleton.Joints[SelectionHand]).ScaleTo(222, 656); Joint SelectionHandJointScaled = (TrackedSkeleton.Joints[SelectionHand]).ScaleTo(1366, 768, 0.55f, 0.55f); Point MotionHandPosition = new Point((MotionHandJointScaled.Position.X), (MotionHandJointScaled.Position.Y)); Point SelectionHandPosition = new Point((SelectionHandJointScaled.Position.X), (SelectionHandJointScaled.Position.Y)); //Move Cursor //SetCursorPos((int)(MotionHandPosition.X), (int)(MotionHandPosition.Y)); Point destination_top_left = theCanvas.PointFromScreen(MotionHandPosition); if (selected.Count > 0) { Pointer_Ellipse.Visibility = Visibility.Hidden; int best = 0; for (int i = 1; i < selected.Count; i++) { if (selected_time[i][1].Subtract(selected_time[i][0]).TotalDays > selected_time[best][1].Subtract(selected_time[best][0]).TotalDays) { best = i; } } Bubble select = selected[best]; if (halo != null) { halo.RemoveFromParent(); } halo = select.ConstructClone(destination_top_left); halo_parent = select; } else { Pointer_Ellipse.Visibility = Visibility.Visible; if (halo != null) { halo.RemoveFromParent(); halo = null; halo_parent = null; } } destination_top_left = Point.Add(destination_top_left, new System.Windows.Vector(Pointer_Ellipse.Width / -2, Pointer_Ellipse.Height / -2)); Canvas.SetTop(Pointer_Ellipse, destination_top_left.Y); Canvas.SetLeft(Pointer_Ellipse, destination_top_left.X); //Added data position to a queue of positions that will be loaded for each letter PositionData.Enqueue("\r\n\t\t\t\t<entry motionhand_x=\"" + MotionHandPosition.X + "\" motionhand_y=\"" + MotionHandPosition.Y + "\" selectionhand_x=\"" + SelectionHandPosition.X + "\" selectionhand_y=\"" + SelectionHandPosition.Y + "\" relative_timestamp=\"" + DateTime.Now.Subtract(StartTime).TotalMilliseconds + "\" />"); //Setup the default colors of the bubbles foreach (Bubble beta in Letters) { if (CurrentNode.HasChild(beta.Word()) != null) { beta.SetColor(Brushes.Yellow); } else { beta.SetColor(Brushes.LightYellow); } } for (int i = 0; i < selected.Count; i++) { if (!selected_off[i] && !CircleOver(selected[i].Ellipse)) { selected_off[i] = true; selected_time[i][1] = DateTime.Now; } else if (!selected_off[i] && CircleOver(selected[i].Ellipse)) { selected_time[i][1] = DateTime.Now; } else if (selected_off[i] && CircleOver(selected[i].Ellipse)) { TimeSpan t = selected_time[i][1].Subtract(selected_time[i][0]); selected_time[i][0] = DateTime.Now.Subtract(t); selected_time[i][1] = DateTime.Now; selected_off[i] = false; } } //Starting Case (only occurs once) if (SelectionHandLast == null) { SelectionHandLast = SelectionHandPosition; } else { //Measures the distance traveled by the selection hand SelectionHandDistance += Point.Subtract(SelectionHandLast, SelectionHandPosition).Length; SelectionHandLast = SelectionHandPosition; } //Measures the distance traveled by the motion hand if (MotionHandLast == null) { MotionHandLast = MotionHandPosition; } else { MotionHandDistance += Point.Subtract(MotionHandLast, MotionHandPosition).Length; MotionHandLast = MotionHandPosition; } //foreach (Bubble beta in Letters) //{ // if (Shift) // { // beta.setText(beta.Word().ToString().ToUpperInvariant()[0]); // } // else // { // beta.setText(beta.Word().ToString().ToLowerInvariant()[0]); // } //} Gesture MotionHandGesture = keyboardGestureTracker.track(TrackedSkeleton, TrackedSkeleton.Joints[MotionHand], nui.NuiCamera.ElevationAngle); Gesture SelectionHandGesture = regularGestureTracker.track(TrackedSkeleton, TrackedSkeleton.Joints[SelectionHand], nui.NuiCamera.ElevationAngle); if (CircleOver(CenterBubble_Ellipse)) { ReturnedToCenter = true; if (!EnterCenterFirst) { PositionData = new Queue <string>(); EnterCenterFirst = true; } if (SelectionHandGesture != null && ((SelectionHandGesture.id == GestureID.SwipeLeft && SelectionHand == JointID.HandRight) || (SelectionHandGesture.id == GestureID.SwipeRight && SelectionHand == JointID.HandLeft))) { SendKeys.SendWait("{Backspace}"); if (CenterBubble_Label.Content.ToString().Length > 0) { CenterBubble_Label.Content = CenterBubble_Label.Content.ToString().Substring(0, CenterBubble_Label.Content.ToString().Length - 1); CurrentNode = (CurrentNode.parent != null ? CurrentNode.parent : CurrentNode); } RemoveLayout(); ConstructLetterLayout(); PositionData.Enqueue("\r\n\t\t\t\t<backspace motionhand_x=\"" + MotionHandPosition.X + "\" motionhand_y=\"" + MotionHandPosition.Y + "\" selectionhand_x=\"" + SelectionHandPosition.X + "\" selectionhand_y=\"" + SelectionHandPosition.Y + "\" relative_timestamp=\"" + DateTime.Now.Subtract(StartTime).TotalMilliseconds + "\" />"); } else if (SelectionHandGesture != null && SelectionHandGesture.id == GestureID.Push) { if (DateTime.Now.Subtract(last_space).TotalSeconds > 0.75) { RemoveLayout(); CurrentNode = InitialNode; ConstructLetterLayout(); SendKeys.SendWait(" "); WordStack.Push(CenterBubble_Label.Content.ToString()); string word = "\r\n\t\t<word text=\"" + WordStack.Peek() + "\">"; while (WordData.Count > 0) { word += WordData.Dequeue(); } word += "\r\n\t\t</word>"; SentenceData.Enqueue(word); WordData = new Queue <string>(); CenterBubble_Label.Content = ""; last_space = DateTime.Now; } } //if ((SelectionHandGesture != null && SelectionHandGesture.id == GestureID.SwipeUp) || Shift == true) //{ // Shift = true; // foreach (Bubble beta in Letters) // { // beta.setText(beta.Word().ToString().ToUpperInvariant()[0]); // } //} //if ((SelectionHandGesture != null && SelectionHandGesture.id == GestureID.SwipeDown) || Shift == false) //{ // Shift = false; // foreach (Bubble beta in Letters) // { // beta.setText(beta.Word().ToString().ToLowerInvariant()[0]); // } //} if (selected.Count > 0 && MotionHandGesture != null && MotionHandGesture.id == GestureID.Still) { Bubble select = halo; //Shift = false; ReturnedToCenter = false; char c = select.GetCharacter(); RemoveLayout(); WordTreeNode NextNode = CurrentNode.HasChild(c); if (NextNode == null) { NextNode = new WordTreeNode(c, false); NextNode.parent = CurrentNode; } CurrentNode = NextNode; ConstructLetterLayout(); SendKeys.SendWait(c.ToString()); CenterBubble_Label.Content = CenterBubble_Label.Content.ToString() + c.ToString(); string letter = ""; string InnerRing = (select.r == Bubble.RingStatus.INNER ? "true" : (PreviousCharacterLocation.Contains(CurrentNode) ? "false" : "outside")); letter += ("\r\n\t\t\t<print char=\"" + c + "\" selection_hand_distance=\"" + SelectionHandDistance + "\" motion_hand_distance=\"" + MotionHandDistance + "\" InnerRing=\"" + InnerRing + "\""); while (PositionData.Count > 0) { letter += PositionData.Dequeue(); } PositionData = new Queue <string>(); letter += ("\r\n\t\t\t</print>"); WordData.Enqueue(letter); SelectionHandDistance = 0.0; MotionHandDistance = 0.0; if (CurrentNode.HasChild('!') != null) { CenterBubble_Ellipse.Fill = Brushes.AntiqueWhite; } else { CenterBubble_Ellipse.Fill = Brushes.GreenYellow; } selected = new List <Bubble>(); selected_time = new List <DateTime[]>(); selected_off = new List <bool> (); } } // We can make changes to the layout if (ReturnedToCenter) { if (MotionHandGesture.id == GestureID.Still) { foreach (Bubble beta in Letters) { if (CircleOver(beta.Ellipse) && !selected.Contains(beta)) { selected.Add(beta); DateTime[] arr = new DateTime[2]; arr[0] = DateTime.Now; arr[1] = DateTime.Now; selected_time.Add(arr); selected_off.Add(false); } if (CurrentNode.HasChild(beta.Word()) != null) { beta.SetColor(Brushes.Yellow); } else { beta.SetColor(Brushes.LightYellow); } } } } } if (DateTime.Now.Subtract(BlueFlash).TotalMilliseconds < 500) { CenterBubble_Ellipse.Fill = Brushes.LightBlue; } else { if (CurrentNode.HasChild('!') != null) { CenterBubble_Ellipse.Fill = Brushes.AntiqueWhite; } else { CenterBubble_Ellipse.Fill = Brushes.GreenYellow; } } if (halo_parent != null) { halo_parent.SetColor(Brushes.LightGreen); } }