Exemplo n.º 1
0
        //Index one entity's sti series
        public void indexEntitySTIs(int eIdx, ref int index, ref int[] relStat, List <int> tonceptIds)
        {
            List <SymbolicTimeInterval> tisList = entityTISs[entitiesVec[eIdx]];

            for (int ti1Idx = 0; ti1Idx < tisList.Count; ti1Idx++)
            {
                SymbolicTimeInterval firsTis = tisList.ElementAt(ti1Idx);
                if (tonceptIds == null || tonceptIds.Contains(firsTis.symbol))
                {
                    addToncept(eIdx, firsTis, ref index); // update toncept entity support
                    //karma..
                    for (int ti2Idx = ti1Idx + 1; ti2Idx < tisList.Count; ti2Idx++)
                    {
                        SymbolicTimeInterval secondTis = tisList.ElementAt(ti2Idx);
                        if (tonceptIds == null || tonceptIds.Contains(secondTis.symbol))
                        {
                            //if (firsTis.symbol != secondTis.symbol)
                            //{
                            addToncept(eIdx, secondTis, ref index);     // DONT update toncept entity support
                            int relation = KLC.WhichRelation(firsTis, secondTis, epsilon, max_gap, relations_style);
                            if (relation > -1)
                            {
                                relStat[relation]++;
                                indexTISPair(firsTis, secondTis, relation, eIdx);
                            }
                            else
                            {
                                break;
                            }
                            //}
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Runs karma for all entites up to a certain entity id
        /// </summary>
        /// <param name="to_eIdx">Entity id max non-inclusive</param>
        public void RunKarma(int to_eIdx)
        {
            int index = 0;

            int[] countOfEachRelation = new int[7];
            for (int eIdx = 0; eIdx < to_eIdx && eIdx < entityTISs.Count() && eIdx < entitieSize; eIdx++)
            {
                List <SymbolicTimeInterval> tisList = entityTISs[entitiesVec[eIdx]];
                for (int ti1Idx = 0; ti1Idx < tisList.Count; ti1Idx++) // time interval 1
                {
                    SymbolicTimeInterval firsTis = tisList.ElementAt(ti1Idx);
                    AddSymbol(eIdx, firsTis, ref index);                            // update symbol entity support
                    for (int ti2Idx = ti1Idx + 1; ti2Idx < tisList.Count; ti2Idx++) // time interval 2
                    {
                        SymbolicTimeInterval secondTis = tisList.ElementAt(ti2Idx);
                        //if (firsTis.symbol != secondTis.symbol)
                        //{
                        AddSymbol(eIdx, secondTis, ref index);     // DONT update symbol entity support
                        int relation = KLC.WhichRelation(firsTis, secondTis, epsilon, max_gap, relations_style);
                        if (relation > -1)
                        {
                            countOfEachRelation[relation]++;
                            karma.AddStiToTindexRelationEntryBySymbols(Symbols[firsTis.symbol].SymbolINDEX, Symbols[secondTis.symbol].SymbolINDEX, relation, eIdx, firsTis, secondTis);
                        }
                        else
                        {
                            break;
                        }
                        //}
                    }
                }
            }
        }
Exemplo n.º 3
0
        private int KarmaEntity(int eIdx, ref int[] relStat)
        {
            int allGapCnt = 0, counter = 0;
            List <SymbolicTimeInterval> tisList = entityTISs[entitiesKarmaVec[eIdx].entityID];
            double allGap = tisList.ElementAt(tisList.Count - 1).startTime - tisList.ElementAt(0).endTime;

            if (allGap > 365)
            {
                allGapCnt++;
            }
            for (int ti1Idx = 0; ti1Idx < tisList.Count; ti1Idx++)
            {
                addToncept(eIdx, tisList.ElementAt(ti1Idx), ref toncepts);//, true); // update toncept entity support
                for (int ti2Idx = ti1Idx + 1; ti2Idx < tisList.Count; ti2Idx++)
                {
                    //if (tisList.ElementAt(ti1Idx).symbol != tisList.ElementAt(ti2Idx).symbol)
                    //{
                    //addToncept(eIdx, tisList.ElementAt(ti2Idx), ref toncepts);//, false); // DONT update toncept entity support
                    int relation = KLC.WhichRelation(tisList.ElementAt(ti1Idx), tisList.ElementAt(ti2Idx), epsilon, max_gap, relations_style);
                    if (relation > -1)
                    {
                        relStat[relation]++;
                        indexTISPair(tisList.ElementAt(ti1Idx), tisList.ElementAt(ti2Idx), relation, eIdx);
                        counter++;
                        if (relation == 0)
                        {
                            ti2Idx++;
                            while (ti2Idx < tisList.Count)
                            {
                                relation = KLC.WhichRelation(tisList.ElementAt(ti1Idx), tisList.ElementAt(ti2Idx), epsilon, max_gap, relations_style);
                                double gap = tisList.ElementAt(ti2Idx).startTime - tisList.ElementAt(ti1Idx).endTime;
                                if (gap >= max_gap || relation == -1)
                                {
                                    ti2Idx = tisList.Count;
                                    break;
                                }
                                //if (tisList.ElementAt(ti1Idx).symbol != tisList.ElementAt(ti2Idx).symbol)
                                {
                                    //addToncept(eIdx, tisList.ElementAt(ti2Idx), ref toncepts);//, false); // DONT update toncept entity support
                                    relStat[relation]++;
                                    indexTISPair(tisList.ElementAt(ti1Idx), tisList.ElementAt(ti2Idx), relation, eIdx);
                                    counter++;
                                }
                                ti2Idx++;
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                    //}
                }
            }
            if (allGap > 365)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }