public List <string> tokenAnalyzer(List <string> filepattern, string path, string queryString,string categories)
 {
     bool recursive_flag = false, partial_flag = false, full_flag = false,text_search=false, metadata_search=false;
     List<string> tokenize = new List<string>(), textquery = new List<string>(), metaquery = new List<string>();
     string input = queryString,pattern = "(/)";
     string[] substrings = Regex.Split(input, pattern);    // Split on hyphens 
     for (int i = 1,k=0; i < substrings.Length - 1; i++)
     {
         tokenize.Add(substrings[i] + substrings[i + 1]);
         i++; k++;
     }
     foreach (string str in tokenize)
     {
         if (str.StartsWith("/T"))
         {
             textquery.Add(str);
             text_search = true;       //setting the flag for text search if the query has /T switch
         }
        if (str.StartsWith("/M"))
         {
             string stringsplitter=str.Remove(0,2);
             string []temparray=stringsplitter.Split(',');
             foreach (string tempstring in temparray)
             {
                 metaquery.Add(tempstring);
             }
             metadata_search = true;   //setting the flag for text search if the query has /T switch
         }
         if (str.StartsWith("/A"))
          full_flag = true;        //setting the flag for full search if the query has /A switch 
         if (str.StartsWith("/O"))  
          partial_flag = true;     //setting the flag for partial search if the queey has /O flag  
     }//foreach
     TextSearch TS = new TextSearch();
     MetadataSearch MS= new MetadataSearch();
     List<string> resultfilelist = new List<string>();
     if (text_search)      //based on switches calling the appropriate function and passing the query and flags
     {
             resultfilelist = TS.non_recursivesearch(filepattern, path, textquery, full_flag, partial_flag, categories);
     }
     else
         if(metadata_search)
            resultfilelist= MS.XMLSearch(filepattern,path, metaquery, recursive_flag,categories);
    return resultfilelist;
 }
Esempio n. 2
0
    }//func

        //test stub function for testing the individual class
#if TESTING_TEXT_SEARCH

        public static void Main(string[] args)
        {
            List<string> pattern = new List<string>();
            pattern.Add("*.txt");
            string categories="Source"
            List<string> textquery = new List<string>();
            textquery.Add("/Tvoid");
            string path = "../../testfiles";
            TextSearch TS = new TextSearch();
            Console.Write("\nI m testing Text Search");
            TS.recursivesearch(pattern, path, textquery,false, true,categories);
            //Console.Write("n  path = {0}\n  file pattern = {1}\n query string = {2}", path, pattern, queryString);
        }