Bookmark Topic Watch Topic
  • New Topic

Implement boolean retrieval using skiplist  RSS feed

 
jessina gi young
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello Everyone!

Boolean retrieval model using skiplist. I don't know how to code it. I have modified it but I'm not sure it work out. Please let me know what are the modifications I can made.

/**My requirement is to implement two methods for Boolean Retrieval:
● index(String dir)
○ index()supposed to go over all files under ‘dir’. There will be no subdirectories
inside it.
● retrieve()
○ retrieve() supposed to return name of all the documents under ‘dir’ that
satisfies the given query. Note that, only basename of the files are to be returned,
not the full path.
○ Query can be of two forms:
■ OR: returned doc should contain at least one term from the query.
■ AND: returned doc should contain all the terms from the query. **/


import java.util.HashSet;

import java.util.Vector;


public class BooleanRetrievalModel implements DocSearch {


// begin private class

private class SkipList {

// Node in skip-list

class SkipNode

{

int element;

SkipNode right;

SkipNode down;



/* Constructor */

public SkipNode(int x)

{

this(x, null, null);

}

/* Constructor */

public SkipNode(int x, SkipNode rt, SkipNode dt)

{

element = x;

right = rt;

down = dt;

}


}

// constructor


class SkipList

{

private SkipNode header;

private int infinity;

private SkipNode bottom = null;

private SkipNode tail = null;



/* Constructor */

public SkipList(int inf)

{

infinity = inf;

bottom = new SkipNode(0);

bottom.right = bottom.down = bottom;

tail = new SkipNode(infinity);

tail.right = tail;

header = new SkipNode(infinity, tail, bottom);

}


}


public String toString() {




return null;

}


// Implement all other methods needed to implement index() &
// retrieve() below.
}


// Constructor

public BooleanRetrievalModel() {

}


public void index(String dir) throws Exception {
File file=new File(dir);
int fileno = file.listFiles().length;
int pos = 0;
File[] allSubFiles=file.listFiles();
String doc = "";
ArrayList<String> words = new ArrayList<String>();

// Implement index to create index made up of SkipList.
//I dont know what exactly to write here
}


public HashSet<String> retrieve(Vector<String> query,
DocSearch.SearchType op) throws Exception {

// Implement retrieve up of SkipList.
HashSet<String> answer;
if (op == SearchType.AND)
{
String ele = query.get(0);
answer = invertedIndex.get(ele);
finalList = new HashSet<String>(answer);
for (int i =0; i<query.size(); i++)
{
answer = invertedIndex.get(query.get(i));
finalList.retainAll(answer);
}
}
else if (op == SearchType.OR)
{
for (String word: query)
{
answer = invertedIndex.get(word);
finalList.addAll(answer);
}
}
return finalList;
}
.

return null;

}

// tokenize

private Vector><String> tokenizeADoc(String infile) throws Exception {


return null;

}

}
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Report post to moderator
You already have a thread for this: http://www.coderanch.com/t/640821/java/java/Boolean-Retrieval-Model

Lets keep the discussion in one place. And it would help if you read the responses and click the links provided to you.

Closing this thread.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!