Beispiel #1
0
        internal CompoundIndex addCompound(Compound compound)
        {
            CompoundIndex compoundIndex = CompoundIndex.make((uint)compounds.Count);

            compounds.Add(compound);

            compoundIdToCompoundIndex[compound.compoundId] = compoundIndex;

            termRefererIdToCompound[compound.thisTermReferer.getMaskedOutId] = compound;



            // add it to the hashtables
            compound.updateHashes();
            compoundHashtableByWithId.insert(compoundIndex);
            compoundHashtableByWithoutId.insert(compoundIndex);

            return(compoundIndex);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        // checks if the compound exists and returns the index of the compound if it is the case
        // the compoundId is not used for hash lookup/comparision
        internal bool existsCompoundWithoutCompoundId(Compound compoundToCompareWithoutCompoundId, out CompoundIndex foundCompoundIndex)
        {
            foundCompoundIndex = CompoundIndex.makeInvalid();

            if (!compoundHashtableByWithoutId.existHash(compoundToCompareWithoutCompoundId.cachedHashWithoutCompoundId))
            {
                return(false);
            }

            ulong[] potentialCompoundIndices = getPotentialIndicesOfCompoundsByHashWithoutCompoundId(compoundToCompareWithoutCompoundId.cachedHashWithoutCompoundId);

            // compare and search the compound which matches the queried one
            foreach (var iCompoundIndex in potentialCompoundIndices)
            {
                Compound iCompound = compounds[(int)iCompoundIndex];
                if (Compound.isEqualWithoutCompoundIdAndTermReferer(compoundToCompareWithoutCompoundId, iCompound))
                {
                    foundCompoundIndex = CompoundIndex.make((/*quick and dirty conversation*/ (uint)iCompoundIndex));
                    return(true);
                }
            }

            return(false);
        }
Beispiel #4
0
 public Compound accessCompoundByIndex(CompoundIndex value)
 {
     return(compounds[(int)value.index]);
 }