Beispiel #1
0
        public void RefToNonTerminalWithTemplate()
        {
            var embedDic = new ExtractionDic("Main.S1", "1234", 5)
            {
                { "Val", new ExtractionValue(123, ValueType.Int) }
            };

            Checker.Check(
                "тест 1234.",
                "S1[Val=123] -> \"1234\";" +
                "S[Test=$0] -> S1 \".\";",
                new [] {
                embedDic,
                new ExtractionDic("Main.S", "1234.", 5)
                {
                    {
                        "Test",
                        new ExtractionValue(
                            embedDic,
                            ValueType.Dictionary
                            )
                    }
                }
            }
                );
        }
Beispiel #2
0
        private static void _checkDictionary(ExtractionDic etalonDic, ExtractionDic resultDic)
        {
            Assert.AreEqual(etalonDic.Name,
                            resultDic.Name,
                            $"Wrong name");

            Assert.AreEqual(etalonDic.Text,
                            resultDic.Text,
                            $"Wrong text");

            Assert.AreEqual(etalonDic.StartPosition,
                            resultDic.StartPosition,
                            $"Wrong start position");

            Assert.AreEqual(etalonDic.EndPosition,
                            resultDic.EndPosition,
                            $"Wrong length");

            Assert.AreEqual(etalonDic.Count,
                            resultDic.Count,
                            $"Wrong items count in");

            foreach (var etKp in etalonDic)
            {
                Assert.AreEqual(true,
                                resultDic.ContainsKey(etKp.Key),
                                $"Result doesn't contain key '{etKp.Key}'");

                var etItem  = etKp.Value;
                var resItem = resultDic[etKp.Key];

                Assert.AreEqual(etItem.Type,
                                resItem.Type,
                                $"Wrong item type with key '{etKp.Key}'");

                Assert.AreEqual(etItem.SemanticId,
                                resItem.SemanticId,
                                $"Wrong item semanticId with key '{etKp.Key}'");

                _checkValue(etItem, resItem, etKp.Key);
            }
        }