Exemplo n.º 1
0
            /// <exception cref="System.Exception"/>
            public virtual bool Call()
            {
                IDictionary <string, IDictionary <int, ICollection <E> > > tempPatternsForTokens = new Dictionary <string, IDictionary <int, ICollection <E> > >();
                int numSentencesInOneCommit = 0;

                foreach (string id in this.sentIds)
                {
                    DataInstance sent = this.sents[id];
                    if (!this._enclosing.constVars.storePatsForEachToken.Equals(ConstantsAndVariables.PatternForEachTokenWay.Memory))
                    {
                        tempPatternsForTokens[id] = new Dictionary <int, ICollection <E> >();
                    }
                    IDictionary <int, ICollection <E> > p = (IDictionary)PatternFactory.GetPatternsAroundTokens(this._enclosing.constVars.patternType, sent, ConstantsAndVariables.GetStopWords());
                    //to save number of commits to the database
                    if (!this._enclosing.constVars.storePatsForEachToken.Equals(ConstantsAndVariables.PatternForEachTokenWay.Memory))
                    {
                        tempPatternsForTokens[id] = p;
                        numSentencesInOneCommit++;
                        if (numSentencesInOneCommit % 1000 == 0)
                        {
                            this.patsForEach.AddPatterns(tempPatternsForTokens);
                            tempPatternsForTokens.Clear();
                            numSentencesInOneCommit = 0;
                        }
                    }
                    else
                    {
                        //          patsForEach.addPatterns(id, p);
                        this.patsForEach.AddPatterns(id, p);
                    }
                }
                //For the remaining sentences
                if (!this._enclosing.constVars.storePatsForEachToken.Equals(ConstantsAndVariables.PatternForEachTokenWay.Memory))
                {
                    this.patsForEach.AddPatterns(tempPatternsForTokens);
                }
                return(true);
            }