예제 #1
0
    private void Start()
    {
        Result <Formula>[] result = ModelParser.ParseSentences(_input);

        if (result[0].IsValid)
        {
            if (result[0].Value is Predicate predicate)
            {
                Debug.Log("Predicate:" + predicate.Identifier);
                Debug.Log("Argument:" + ((Constant)predicate.Arguments[0]).Value);
            }
        }

        List <string> sentences = new List <string> {
            "Tet(a)"
        };
        List <string> arguments = new List <string> {
            "a"
        };
        List <string> predicates = new List <string> {
            "Tet"
        };
        List <DataStruct> dataStructs = new List <DataStruct> {
            new DataStruct(arguments, predicates, 0, 0)
        };

        var resultValidate = ModelValidater.ValidateModel(dataStructs, sentences);

        Debug.Log("Sentence is " + resultValidate.Value[0]);
    }
예제 #2
0
    private void Validate(List <GUI_TextInputElement> elements, List <string> sentences, List <DataStruct> boardInfo)
    {
        Result <List <bool> > resultValidate = ModelValidater.ValidateModel(boardInfo, sentences);
        var inputElements = _textInputField.GetTextInputElement();

        for (int i = 0; i < resultValidate.Value.Count; i++)
        {
            elements[i].Validate(resultValidate.Value[i]);
        }
    }
        public void ModelValidater_Parsing_InvalidSentence()
        {
            List <string> sentences = new List <string> {
                "Tet325332"
            };
            List <string> arguments = new List <string> {
                "a"
            };
            List <string> predicates = new List <string> {
                "Tet"
            };
            List <DataStruct> dataStructs = new List <DataStruct> {
                new DataStruct(arguments, predicates, 0, 0)
            };

            var result = ModelValidater.ValidateModel(dataStructs, sentences);

            Assert.IsFalse(result.Value[0]);
        }
        public void ModelValidater_Parsing_InvalidIdentifier()
        {
            List <string> sentences = new List <string> {
                "Tet(a)"
            };
            List <string> arguments = new List <string> {
                "a"
            };
            List <string> identifier = new List <string> {
                "Tet("
            };
            List <DataStruct> dataStructs = new List <DataStruct> {
                new DataStruct(arguments, identifier, 0, 0)
            };

            var result = ModelValidater.ValidateModel(dataStructs, sentences);

            Assert.IsFalse(result.Value[0]);
        }
        public void ModelValidater_ValidateOnePredicateNoConstantOneSentence_IsTrue()
        {
            List <string> sentences = new List <string> {
                "Tet(a)"
            };
            List <string> arguments = new List <string> {
                ""
            };
            List <string> predicates = new List <string> {
                "Tet"
            };
            List <DataStruct> dataStructs = new List <DataStruct> {
                new DataStruct(arguments, predicates, 0, 0)
            };

            var result = ModelValidater.ValidateModel(dataStructs, sentences);

            Assert.IsTrue(result.IsValid, "Validatemodel result is not valid" + result.Message);

            Assert.IsFalse(result.Value[0], "Sentence should be false");
        }