protected KifConjunction processingParentsXXX(DataFrame frame)
        {
            KifSequence <KifSentence> conjs = new KifSequence <KifSentence>();
            IList isA = frame.isA;

            if (isA.Count == 0)
            {
                isA = new ArrayList();
                isA.Add("Thing"); //TODO:
            }
            foreach (string parentName in isA)
            {
                conjs.addItem(
                    new KifRelationalSentence(new KifConstant(parentName),
                                              new KifConcreteTerm <KifIndividualVariable>(new KifIndividualVariable("X"))));
            }
            foreach (Slot slot in frame.ownSlots.Values)
            {
                if (!"".Equals(slot.slotValue))
                {
                    conjs.addItem(
                        new KifRelationalSentence(new KifConstant(slot.iden),
                                                  new KifConcreteTerm <KifConstant>(new KifConstant(slot.slotValue))));
                }
            }
            return(new KifConjunction(conjs));
        }
        public override IList <IModelItem> getChildren()
        {
            KifSequence <KifObject> sequence = new KifSequence <KifObject>(new KifConstant(Name));

            sequence.addItem(DELIMITER);
            sequence.addItem(Sentence);
            return(sequence.getChildren());
        }
        protected KifRelationalSentence createTrRelation(string relName, string firstArg, string secondArg, string thirdArg)  //TODO
        {
            KifSequence <KifTerm> terms = new KifSequence <KifTerm>(new KifConstant(firstArg));

            terms.addItem(new KifConstant(secondArg));
            terms.addItem(new KifConstant(thirdArg));
            return(new KifRelationalSentence(new KifConstant(relName), terms));
        }
        protected KifObject createSlotOfInstance(string frameName, Slot slot, KifSequence <KifSentence> slotsValues)
        {
            string slotIden = generateSlotIdentifier(frameName, slot.iden);
            KifSequence <KifSentence> sequence = new KifSequence <KifSentence>(createDocumentation(generateSlotComment(isOwnSlot(slot), slot.iden, frameName), frameName));

            sequence.addItem(createBinRelation(RANGE, slotIden, _resolver.resolveType(slot.slotType)));
            sequence.addItem(createBinRelation(DOMAIN, slotIden, frameName));
            sequence.addItem(createArity(slotIden, 2));
            sequence.addItem(createUnRelation(RELATION, slotIden));
            sequence.addItem(createUnRelation(BINARY_RELATION, slotIden));

            return(new KifRelationDefinition(slotIden, sequence));
        }
        public void createClassFrame(DataFrame frame)  //TODO: order
        {
            string frameName = frame.iden;
            KifSequence <KifSentence> sequence = new KifSequence <KifSentence>(createDocumentation(generateFrameComment(true, frameName), frameName));

            sequence.addRange(processingParentsXXX(frame));
            sequence.addItem(createArity(frameName, 1));
            sequence.addItem(createUnRelation(CLASS, frameName));
            IList <KifObject>     slots    = createSlots(frame, sequence);
            KifRelationDefinition relation = new KifRelationDefinition(frame.iden, sequence);

            _model.addObject(relation);
            _model.addRange(slots);
        }
        protected KifRelationalSentence createDocumentation(string docString, string docOwner)
        {
            KifSequence <KifTerm> terms = new KifSequence <KifTerm>(new KifConstant(docOwner));

            terms.addItem(new KifString(docString));
            return(new KifRelationalSentence(new KifConstant(DOCUMENTATION), terms));
        }
        protected KifSequence <KifSentence> processingParentsOfInstance(DataFrame frame)
        {
            KifSequence <KifSentence> parents = new KifSequence <KifSentence>();
            string frameName = frame.iden;
            IList  isA       = frame.isA;

            if (isA.Count == 0)
            {
                parents.addItem(createUnRelation(THING, frameName));
            }
            else
            {
                foreach (string parentName in isA)
                {
                    parents.addItem(createUnRelation(parentName, frameName));
                }
            }
            return(parents);
        }
        protected KifSequence <KifSentence> processingParentsXXX(DataFrame frame)
        {
            KifSequence <KifSentence> parents = new KifSequence <KifSentence>();
            string frameName = frame.iden;
            IList  isA       = frame.isA;

            if (isA.Count == 0)
            {
                parents.addItem(createSubclassOf(frameName, THING));
            }
            else
            {
                foreach (string parentName in isA)
                {
                    parents.addItem(createSubclassOf(frameName, parentName));
                }
            }
            return(parents);
        }
        protected KifObject createSlot(string frameName, Slot slot, KifSequence <KifSentence> slotsValues)
        {
            string slotIden = generateSlotIdentifier(frameName, slot.iden);
            KifSequence <KifSentence> sequence = new KifSequence <KifSentence>(createDocumentation(generateSlotComment(isOwnSlot(slot), slot.iden, frameName), frameName));

            sequence.addItem(createBinRelation(RANGE, slotIden, _resolver.resolveType(slot.slotType)));
            sequence.addItem(createBinRelation(DOMAIN, slotIden, frameName));
            sequence.addItem(createArity(slotIden, 2));
            sequence.addItem(createUnRelation(RELATION, slotIden));
            sequence.addItem(createUnRelation(BINARY_RELATION, slotIden));

//            bool isString = StringUtils.equalsIgnoreCase(slot.slotType, "string");
//            if (slot.slotValue != null && (!"".Equals(slot.slotValue) && isString))
//                slotsValues.addItem(createTrRelation(TEMPLATE_SLOT_VALUE, slotIden, frameName, slot.slotValue));
            if (!StringUtils.isEmpty(slot.slotValue))
            {
                slotsValues.addItem(createTrRelation(TEMPLATE_SLOT_VALUE, slotIden, frameName, slot.slotValue));
            }

            return(new KifRelationDefinition(slotIden, sequence));
        }
        protected void createSlot(string frameName, Slot slot)
        {
            KifIndividualVariable frameVar = new KifIndividualVariable("Frame");
            KifIndividualVariable valueVar = new KifIndividualVariable("Value");

            KifSequence <KifIndividualVariable> args = new KifSequence <KifIndividualVariable>(frameVar);

            args.addItem(valueVar);
            OntolinguaDefineRelation  relation = new OntolinguaDefineRelation(slot.iden, null, args);
            KifSequence <KifSentence> conjs    = new KifSequence <KifSentence>();

            conjs.addItem(
                new KifRelationalSentence(new KifConstant(frameName),
                                          new KifConcreteTerm <KifIndividualVariable>(frameVar)));
            conjs.addItem(
                new KifRelationalSentence(new KifConstant(slot.slotType),
                                          new KifConcreteTerm <KifIndividualVariable>(valueVar)));


            relation.DefSentence = new KifConjunction(conjs);
            _model.addObject(relation);
        }
Esempio n. 11
0
        protected IList <KifObject> createOwnSlotsOfInstance(DataFrame frame, KifSequence <KifSentence> slotsValues)
        {
            List <KifObject> result = new List <KifObject>(frame.ownSlots.Count);

            foreach (Slot slot in frame.ownSlots.Values)
            {
                string owner = _director.getSlotOwner(slot.iden, frame);
                if (frame.iden.Equals(owner))
                {
                    result.Add(createSlotOfInstance(frame.iden, slot, slotsValues));
                }
                if (!StringUtils.isEmpty(slot.slotValue))
                {
                    slotsValues.addItem(createBinRelation(generateSlotIdentifier(owner, slot.iden), frame.iden, slot.slotValue));
                }
            }
            return(result);
        }
Esempio n. 12
0
        protected IList <KifObject> createOwnSlots(DataFrame frame, KifSequence <KifSentence> slotsValues)
        {
            List <KifObject> result = new List <KifObject>(frame.ownSlots.Count);

            foreach (Slot slot in frame.ownSlots.Values)
            {
                string owner = _director.getSlotOwner(slot.iden, frame);
                if (frame.iden.Equals(owner))
                {
                    result.Add(createSlot(frame.iden, slot, slotsValues));
                }
                else
                {
                    if (slot.slotValue != null)
                    {
                        slotsValues.addItem(createTrRelation(TEMPLATE_SLOT_VALUE, generateSlotIdentifier(owner, slot.iden), frame.iden, slot.slotValue));
                    }
                }
            }
            return(result);
        }