예제 #1
0
        internal TermTupleIndex returnIndexOfTermTupleForHumanReadableTermNameOrCreate(string name, out int termOrCompoundTermOrVariableRefererId)
        {
            bool nameIsPresentInHumanReadableNames = termNamesByhumanReadableName.ContainsKey(name);

            if (nameIsPresentInHumanReadableNames)
            {
                termOrCompoundTermOrVariableRefererId = termTuples[(int)termNamesByhumanReadableName[name].index].refererOrIntervals[0].referer.getAtomic;
                return(termNamesByhumanReadableName[name]);
            }
            // else here

            termOrCompoundTermOrVariableRefererId = TermOrCompoundTermOrVariableRefererCounter;
            TermOrCompoundTermOrVariableRefererCounter++;

            TermTuple termTuple = TermTuple.makeByReferers(new TermOrCompoundTermOrVariableReferer[] { TermOrCompoundTermOrVariableReferer.makeAtomic(termOrCompoundTermOrVariableRefererId) });

            TermTupleIndex index = TermTupleIndex.make((ulong)termTuples.Count);

            termTuples.Add(termTuple);

            termNamesByhumanReadableName[name] = index;
            termOrCompoundTermOrVariableRefererIdToHumanReadableName[termOrCompoundTermOrVariableRefererId] = name;

            return(index);
        }
예제 #2
0
        internal bool existHumanReadableTermName(string termName, out TermTupleIndex index)
        {
            if (termNamesByhumanReadableName.ContainsKey(termName))
            {
                index = termNamesByhumanReadableName[termName];
                return(true);
            }

            index = TermTupleIndex.makeInvalid();
            return(false);
        }
예제 #3
0
        internal TermTupleIndex addTermTupleByReferers(TermOrCompoundTermOrVariableReferer[] referers)
        {
            ulong hash = calcHashOfTermOrCompoundTermOrVariableReferers(referers);

            TermTupleIndex insertionIndex = TermTupleIndex.make((ulong)termTuples.Count);

            termTuples.Add(TermTuple.makeByReferers(referers));
            if (!termTupleIndicesByTermTupleHash.ContainsKey(hash))
            {
                termTupleIndicesByTermTupleHash[hash] = new List <TermTupleIndex>()
                {
                    insertionIndex
                };
                return(insertionIndex);
            }

            termTupleIndicesByTermTupleHash[hash].Add(insertionIndex);

            return(insertionIndex);
        }
예제 #4
0
        public CompoundIndex makeInheritance(string a, string b)
        {
            int termOrCompoundTermOrVariableRefererIdOfA, termOrCompoundTermOrVariableRefererIdOfB;

            TermTupleIndex termTupleIndexOfA = compoundAndTermContext.returnIndexOfTermTupleForHumanReadableTermNameOrCreate(a, out termOrCompoundTermOrVariableRefererIdOfA);
            TermTupleIndex termTupleIndexOfB = compoundAndTermContext.returnIndexOfTermTupleForHumanReadableTermNameOrCreate(b, out termOrCompoundTermOrVariableRefererIdOfB);

            var compoundReferers = new TermOrCompoundTermOrVariableReferer[] {
                compoundAndTermContext.accessTermTupleByIndex(termTupleIndexOfA).refererOrIntervals[0].referer,
                compoundAndTermContext.accessTermTupleByIndex(termTupleIndexOfB).refererOrIntervals[0].referer,
            };

            TermTupleIndex termTupleIndex;

            if (compoundAndTermContext.existTermTuple(compoundReferers))
            {
                termTupleIndex = compoundAndTermContext.getTermTupleIndexByReferers(compoundReferers);
            }
            else
            {
                termTupleIndex = compoundAndTermContext.addTermTupleByReferers(compoundReferers);
            }

            // create compound
            Compound.MakeParameters makeParameters = new Compound.MakeParameters();
            makeParameters.flagsOfCopula   = FlagsOfCopula.makeInheritance();
            makeParameters.termComplexity  = 3;
            makeParameters.termTupleIndex  = termTupleIndex;
            makeParameters.thisTermReferer = TermOrCompoundTermOrVariableReferer.makeNonatomic(compoundAndTermContext.TermOrCompoundTermOrVariableRefererCounter);
            compoundAndTermContext.TermOrCompoundTermOrVariableRefererCounter++;


            Compound      compound      = compoundAndTermContext.createCompound(makeParameters);
            CompoundIndex compoundIndex = compoundAndTermContext.addCompound(compound);


            return(compoundIndex);
        }
예제 #5
0
 internal TermTuple accessTermTupleByIndex(TermTupleIndex value)
 {
     return(termTuples[(int)value.index]);
 }