• Post Reply Bookmark Topic Watch Topic
  • New Topic

Boolean Retrieval Model  RSS feed

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

My Prof given me an assignment to work on Boolean retrieval model.
I really don't know code .
 
Knute Snortum
Sheriff
Posts: 4279
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Just a tip: you aren't going to get many replies if you don't Show Some Effort to solve the problem yourself. It looks like you were given a program to write and you did nothing. If that's not the case, put the code you have written between Code Tags and Ask A Specific Question.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch. keerthana.

keerthana ch wrote:My Prof given me an assignment to work on Boolean retrieval model...

I actually had to look that one up. Perhaps you could explain what he (or she) actually wants you to do, rather than using terms like "boolean retrieval model".

And then, as Knute says, show us what you've done to try and DO it. What I see is basically a skeleton class with no code. ShowSomeEffort, and we'll be more than happy to help.

Otherwise, if you're having problems even getting started, then explain precisely what it is that's troubling you, and again, you're much more likely to get answers.

Winston
 
jessina gi young
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • 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;

}

}
 
Junilu Lacar
Sheriff
Posts: 11490
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags ←click
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!