示例#1
0
        public static TermTuple makeByReferers(TermOrCompoundTermOrVariableReferer[] referers)
        {
            TermTuple result = new TermTuple();

            result.refererOrIntervals = referers.Select(v => RefererOrInterval.makeReferer(v)).ToArray();
            return(result);
        }
示例#2
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);
        }
示例#3
0
        // TODO< overhaul so it returns RefererOrInterval >
        public TermOrCompoundTermOrVariableReferer right(CompoundAndTermContext compoundAndTermContext)
        {
            TermTuple dereferencedCompoundTuple = compoundAndTermContext.accessTermTupleByIndex(termTupleIndex);

            Debug.Assert(dereferencedCompoundTuple.refererOrIntervals.Length == 2, "only valid for binary compounds");
            Debug.Assert(dereferencedCompoundTuple.refererOrIntervals[1].isReferer);
            return(dereferencedCompoundTuple.refererOrIntervals[1].referer);
        }
示例#4
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);
        }
示例#5
0
        public uint getComponentLength(CompoundAndTermContext compoundAndTermContext)
        {
            TermTuple dereferencedCompoundTuple = compoundAndTermContext.accessTermTupleByIndex(termTupleIndex);

            return((uint)dereferencedCompoundTuple.refererOrIntervals.Length);
        }
示例#6
0
        public RefererOrInterval getComponentByIndex(CompoundAndTermContext compoundAndTermContext, uint index)
        {
            TermTuple dereferencedCompoundTuple = compoundAndTermContext.accessTermTupleByIndex(termTupleIndex);

            return(dereferencedCompoundTuple.refererOrIntervals[index]);
        }