Terrier Users :  Terrier Forum terrier.org
General discussion about using/developing applications using Terrier 
Searching term in collection
Posted by: nadhem7 ()
Date: December 06, 2017 10:51AM

Hi everyone,

I went through the [terrier.org] tutorial corpus and then I run the code of What documents does term Z occur in, and at what position?" below:

public class WordSearch {

public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub

// Configure Terrier
System.setProperty("terrier.home", "/home/nadhem/pfeFinalFinalFinal/terrier-core-4.2"winking smiley;
System.setProperty("terrier.etc", "/home/nadhem/pfeFinalFinalFinal/terrier-core-4.2/etc"winking smiley;
ApplicationSetup.bootstrapInitialisation();
ApplicationSetup.setProperty("indexer.meta.forward.keys", "docno"winking smiley;
ApplicationSetup.setProperty("indexer.meta.forward.keylens", "5000"winking smiley;

Index index = Index.createIndex();
PostingIndex inv = index.getInvertedIndex();
Lexicon<String> lex = index.getLexicon();
LexiconEntry le = lex.getLexiconEntry( "query" );
IterablePosting postings = inv.getPostings((BitIndexPointer) le);
while (postings.next() != IterablePosting.EOL) {
System.out.println(postings.getId() + " with frequency " + postings.getFrequency());
}

}

}

I got the following error:

11:13:04 DEBUG [main] - [Index]- Attempting to load structure direct
Exception in thread "main" java.lang.NullPointerException
at org.terrier.structures.bit.BitPostingIndex.getPostings(BitPostingIndex.java:183)
at myPFE.WordSearch.main(WordSearch.java:27)

Any idea why this is so?

Any help would be most appreciated.

thanks,
nadhem



Edited 4 time(s). Last edit at 12/06/2017 04:20PM by nadhem7.

Options: ReplyQuote
Re: Searching term in collection
Posted by: craigm ()
Date: December 07, 2017 06:13PM

I think: le is null.
This is because "query" was not found in the lexicon.
Probably, your index is stemmed. You need to stem the word "query"

Craig

Options: ReplyQuote


Sorry, only registered users may post in this forum.
This forum powered by Phorum.