Esempio n. 1
0
        private bool TryMergeLogData(Log log, out LogTemplate result)
        {
            result = null;
            if (this.UnmatchedLogPool.ContainsKey(log.Words.Length))
            {
                var pool = this.UnmatchedLogPool[log.Words.Length];
                foreach (var unmatchedLog in pool)
                {
                    if (TemplateCorrection.TryMerge(log.Words, unmatchedLog.Words, this.LcsThreshold, this.LcsTokensOnly, out result))
                    {
                        pool.Remove(unmatchedLog);
                        result.LogIds = new List <int> {
                            log.LogId, unmatchedLog.LogId
                        };

                        return(true);
                    }
                }
            }
            else
            {
                this.UnmatchedLogPool.Add(log.Words.Length, new List <Log>());
            }

            this.UnmatchedLogPool[log.Words.Length].Add(log);
            return(false);
        }
Esempio n. 2
0
        private bool TryMergeTemplate(LogTemplate template, out LogTemplate result)
        {
            result = null;
            if (this.LengthIndexer.ContainsKey(template.Length))
            {
                var list = this.LengthIndexer[template.Length];
                foreach (var tryTemplateId in list)
                {
                    if (TemplateCorrection.TryMerge(template.Sequence, this.Templates[tryTemplateId].Sequence, this.LcsThreshold, this.LcsTokensOnly, out result))
                    {
                        result.LogIds = template.LogIds
                                        .Concat(this.Templates[tryTemplateId].LogIds)
                                        .ToList();

                        //this.Templates[templateId].EmergedId = result.TemplateId;
                        this.RemoveTemplate(tryTemplateId);

                        return(true);
                    }
                }
            }
            return(false);
        }