private static Tuple <RecognitionRoot, List <InkRecognitionUnit> > _parseRecognitionUnits(JsonElement recoUnitsJson) { try { List <InkRecognitionUnit> recoUnits = new List <InkRecognitionUnit>(); RecognitionRoot root = null; foreach (var recoUnitJson in recoUnitsJson.EnumerateArray()) { var category = recoUnitJson.GetProperty("category").GetString(); switch (category) { case "unknown": var unclassifiedInk = new Unclassified(recoUnitJson); recoUnits.Add(unclassifiedInk); break; case "writingRegion": var recognizedWritingRegion = new RecognizedWritingRegion(recoUnitJson); recoUnits.Add(recognizedWritingRegion); break; case "paragraph": var recognizedParagraph = new RecognizedParagraph(recoUnitJson); recoUnits.Add(recognizedParagraph); break; case "line": var recognizedLine = new RecognizedLine(recoUnitJson); recoUnits.Add(recognizedLine); break; case "inkWord": var inkWord = new InkWord(recoUnitJson); recoUnits.Add(inkWord); break; case "inkBullet": var inkBullet = new InkBullet(recoUnitJson); recoUnits.Add(inkBullet); break; case "inkDrawing": var inkDrawing = new InkDrawing(recoUnitJson); recoUnits.Add(inkDrawing); break; case "listItem": var inkList = new RecognizedListItem(recoUnitJson); recoUnits.Add(inkList); break; } } return(Tuple.Create(root, recoUnits)); } catch (Exception) { throw; } }
private void TestLine(RecognizedLine line, RecognizedParagraph paragraph) { Assert.IsNotNull(line); Assert.IsTrue(line.Id == 3); Assert.IsTrue(line.Kind == InkRecognitionUnitKind.RecognizedLine); Assert.IsTrue(line.Parent == paragraph); Assert.IsTrue(line.Children.Count() == 1); Assert.IsTrue(line.Words.Count() == 1); Assert.IsNull(line.Bullet); Assert.IsTrue(line.RecognizedText == "hey"); var strokeIds = new List <long>() { 95, 96, 97 }; Assert.IsTrue(line.StrokeIds.SequenceEqual(strokeIds)); var boundingRect = new RectangleF(); boundingRect.Height = 33.8f; boundingRect.X = 37.9f; boundingRect.Y = 16.7f; boundingRect.Width = 34.8f; Assert.IsTrue(line.BoundingBox.Equals(boundingRect)); var point1 = new PointF(40.1f, 12.8f); var point2 = new PointF(77.5f, 33.4f); var point3 = new PointF(66.8f, 53.6f); var point4 = new PointF(29.2f, 32.4f); var rotatedBoundingRect = new List <PointF> { point1, point2, point3, point4 }; Assert.IsTrue(line.RotatedBoundingBox.SequenceEqual(rotatedBoundingRect)); var alternates = new List <string>() { "hoy", "ney", "heif" }; Assert.IsTrue(line.Alternates.SequenceEqual(alternates)); }