public static ResultTies Search1(IList<byte> qext, Dictionary<int,double> acc, int numqgrams, LSC<IList<byte>> I, double probabilidad) { Chronos time = new Chronos(); var aspace = (AudioSpace)I.MainSpace; int numsampleq = numqgrams; int skip = numqgrams/numsampleq; Random r = new Random(); time.Begin(); for(int sindex=0; sindex <numsampleq; sindex++){ int qindex = sindex * skip; BinQGram qgram = new BinQGram(qext, qindex * aspace.SymbolSize, aspace.Q); IResult R = new Result(int.MaxValue, false); if(r.NextDouble() > probabilidad){ continue; } I.KNNSearch(qgram,-1,R); HashSet<int> docId = new HashSet<int>(); foreach (var u in R){ docId.Add(aspace.GetDocIdFromBlockId(u.docid)); } foreach (var d in docId){ double dist; if(!acc.TryGetValue(d ,out dist)){ acc[d] = -1; } else{ acc[d]--; } } } time.End(); //time.PrintStats("Tiempo de busqueda"); var Rf = new ResultTies(100 , false); foreach (var u in acc){ Rf.Push(u.Key, u.Value); } return Rf; }
/// <summary> /// Indexer to retrieve an object /// </summary> public object this[int docid] { get { var start_index = this.LENS.Select1(docid+1); var last_index = this.LENS.Select1(docid+2); var len = last_index - start_index; var s = new BinQGram(this.DATA, start_index, len); return s; } }