The pair to be searched
예제 #1
0
파일: QueryStream.cs 프로젝트: sadit/natix
        public IEnumerable<CommandQuery> Iterate()
        {
            foreach (var _line in commands) {
                var line = _line.Trim ();
                if (line == "-0") {
                    break;
                }
                if (line.Length == 0) {
                    continue;
                }
                CommandQuery cmd;
                cmd = new CommandQuery (line, Math.Abs (this.queryArg), this.queryArg >= 0);
                yield return cmd;
                --this.maxQueries;
                if (this.maxQueries == 0) {
                break;
                }

            }
        }
예제 #2
0
 public IEnumerable<CommandQuery> Iterate()
 {
     foreach (var line in commands) {
         if (line == "-0") {
             break;
         }
         CommandQuery cmd;
         string[] s = line.Split (sep1, 2);
         if (s [0].StartsWith ("search")) {
             var m = s [0].Split (sep2);
             if (m.Length != 3) {
                 throw new ArgumentOutOfRangeException ("search cmd must be 'search {knn|range}' arg");
             }
             var qtype = m [1];
             var qarg = double.Parse(m [2]);
             var qraw = s [1];
             cmd = new CommandQuery (qraw, qarg, qtype.CompareTo ("range") == 0);
         } else {
             var qarg = double.Parse (s [0]);
             cmd = new CommandQuery (s [1], Math.Abs (qarg), qarg >= 0);
         }
         yield return cmd;
     }
 }
예제 #3
0
        public static IResult SearchAudio(CommandQuery qname,AudioSpace aspace,HammingMLSC I)
        {
            ResultTies Respuesta = new ResultTies(candidatos,false);
            var Rfull = new ResultTies(100,false);
            List<IResult> res_list = new List<IResult>();
            var qext = BinaryHammingSpace.ParseAndLoadFromFile(qname.QRaw,false);

            foreach(var idx in I.Indexes){
                Console.WriteLine("XXXXXX: {0}",qname.QRaw);

                int numqgrams = (qext.Count - aspace.Q) / aspace.SymbolSize;
                double probabilidad = 0.05;
                var acc = new Dictionary<int, double>();

                Rfull = Search1(qext,acc,numqgrams,idx,probabilidad);
                res_list.Add(Rfull);

                int count=0;
                double panterior = -1;
                foreach(var p in Rfull){

                    if(count > 0){
                        if(p.dist - panterior > 10){
                            break;
                        }
                    }
                    count++;
                    panterior = p.dist;

                }

                if(count < 10){
                    foreach(var p in Rfull){
                        Respuesta.Push(p.docid,p.dist);
                        count--;
                        if(count==0)
                            return Respuesta;
                    }
                }
            }

            return Respuesta;    //Eliminar esto para que todo quede normal

            if(Respuesta.Count==0){
                Dictionary<int,double> rcc = new Dictionary<int,double>();
                foreach(var rl in res_list){
                    double dist;
                    foreach(var respair in rl){
                        if(!rcc.TryGetValue(respair.docid,out dist)){
                            rcc[respair.docid] = -1;
                        }
                        else{
                            rcc[respair.docid]--;
                        }
                    }
                }
                Rfull = new ResultTies(100,false);
                foreach(var pair in rcc){
                    Rfull.Push(pair.Key,pair.Value);
                }

                var RFinal = new Result(100, false);

                foreach (var pair in Rfull){
                    var audio = aspace.GetAudio (pair.docid);
                    var dist = BinaryHammingSpace.DistMinHamming (audio, qext,aspace.SymbolSize);
                    RFinal.Push (pair.docid, dist);
                }

                var error = (qext.Count/aspace.SymbolSize * 24) * perror;
                //Console.WriteLine ("Error: {0}",error);

                foreach(var p in RFinal){
                    if(p.dist < error){
                        Respuesta.Push(p.docid,p.dist);
                    }
                    else{
                        break;
                    }

                }

            }
            return Respuesta;
        }