Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (tokenIterator.hasNext()) {
- IToken token = tokenIterator.next();
- //Unknown tokens, i.e not in the lexicon.
- //Adding new PostingList, newValue in lexicon, and new Posting to said postingList
- if(lexicon.lookup(token.getValue())==lexicon.INVALID){
- lexicon.addValue(token.getValue());
- invertedIndex.add(lexicon.lookup(token.getValue()), new PostingList());
- invertedIndex.get(lexicon.lookup(token.getValue())).appendPosting(new Posting(documentId,token.getPosition()));
- }else{
- //The term is already in the invertedIndex, i.e adding new positions
- if(invertedIndex.get(lexicon.lookup(token.getValue())).getLastPosting().getDocumentId()==documentId){
- invertedIndex.get(lexicon.lookup(token.getValue())).getLastPosting().appendPosition(token.getPosition());
- }else{
- invertedIndex.get(lexicon.lookup(token.getValue())).appendPosting(new Posting(documentId,token.getPosition()));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement