Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. while (tokenIterator.hasNext()) {
  2.  
  3. IToken token = tokenIterator.next();
  4.  
  5. //Unknown tokens, i.e not in the lexicon.
  6. //Adding new PostingList, newValue in lexicon, and new Posting to said postingList
  7. if(lexicon.lookup(token.getValue())==lexicon.INVALID){
  8. lexicon.addValue(token.getValue());
  9. invertedIndex.add(lexicon.lookup(token.getValue()), new PostingList());
  10. invertedIndex.get(lexicon.lookup(token.getValue())).appendPosting(new Posting(documentId,token.getPosition()));
  11. }else{
  12. //The term is already in the invertedIndex, i.e adding new positions
  13. if(invertedIndex.get(lexicon.lookup(token.getValue())).getLastPosting().getDocumentId()==documentId){
  14. invertedIndex.get(lexicon.lookup(token.getValue())).getLastPosting().appendPosition(token.getPosition());
  15. }else{
  16. invertedIndex.get(lexicon.lookup(token.getValue())).appendPosting(new Posting(documentId,token.getPosition()));
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement