Advertisement
Guest User

Document Ranking Algorithm

a guest
Apr 26th, 2013
1,205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. //then, we look at relative occurrences
  2. //herein lies the most disgusting code i've ever written           
  3. for(int i = 0; i < toSearch.length; i++){
  4.  
  5.     //find the line we need in results
  6.     //j is irrelevant, just trying to find the correct results line
  7.     for(int j = 0; j < results.size(); j++){
  8.         if(results.get(j).split(":")[0].equals(toSearch[i].toLowerCase())){
  9.             //we got it
  10.             //look through and populate the array
  11.  
  12.             String curSplit[] = results.get(j).split(":");
  13.             //for each relevent document, add its array spot
  14.             //k is current array spot
  15.             for(int k = 1; k < curSplit.length; k++){
  16.                
  17.                 String curEntry = curSplit[k];
  18.                 String curDoc = curEntry.split("->")[0];
  19.                
  20.                 if(debug){
  21.                     System.out.println(curEntry.split("->")[0] + " is relevant at array spot " + k);
  22.                 }
  23.                
  24.                 //find relevant document's name
  25.                 for(int l = 0; l < docNames.size(); l++){
  26.                     if(docNames.get(l).equals(curDoc)){
  27.                         Integer curNum = docs.get(docNames.get(l));
  28.                        
  29.                         if(debug){
  30.                             System.out.println("curNum = " + curNum);
  31.                         }
  32.                        
  33.                         curNum += k;
  34.                         if(debug){
  35.                             System.out.println(docNames.get(l) + "'s current relevancy: " + curNum);
  36.                         }
  37.                        
  38.                         docs.put(docNames.get(l), curNum);
  39.                         break;
  40.                     }
  41.                 }
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement