VIBE v5.1.6
Search Engine
Loading...
Searching...
No Matches
edu.usfca.cs272.InvertedIndex Class Reference
Inheritance diagram for edu.usfca.cs272.InvertedIndex:
edu.usfca.cs272.ThreadSafeInvertedIndex

Classes

class  Score
 

Public Member Functions

 InvertedIndex ()
 
Set< String > getWords ()
 
Map< String, Integer > getCounts ()
 
Set< Integer > getPositions (String word, String location)
 
Set< String > getLocations (String word)
 
boolean add (String stem, String path, int location)
 
boolean addAll (String path, Collection< String > stems)
 
boolean addIndex (InvertedIndex other)
 
boolean isEmpty ()
 
int size ()
 
int sizeOfCounts ()
 
int numOfLocations (String word)
 
int numOfPositions (String word, String location)
 
boolean hasWord (String word)
 
boolean hasLocation (String word, String location)
 
boolean hasPosition (String word, String location, int position)
 
boolean hasCount (String location)
 
ArrayList< Scoresearch (Set< String > queries, boolean partial)
 
ArrayList< ScoreexactSearch (Set< String > queries)
 
ArrayList< ScorepartialSearch (Set< String > queries)
 
void toJson (Path output) throws IOException
 
String toString ()
 

Detailed Description

Inverted Index Data Structure.

Author
Ravneet Singh Bhatia
Version
Spring 2024

Constructor & Destructor Documentation

◆ InvertedIndex()

edu.usfca.cs272.InvertedIndex.InvertedIndex ( )

Creates a new inverted index.

Member Function Documentation

◆ add()

boolean edu.usfca.cs272.InvertedIndex.add ( String stem,
String path,
int location )

adds a stem to the index. updates the count after adding the stem to the index.

Parameters
stemword stem
pathfile path
locationindex in stemList
Returns
true if added successfully.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ addAll()

boolean edu.usfca.cs272.InvertedIndex.addAll ( String path,
Collection< String > stems )

Add a collection of stems to Index.

Parameters
pathPath of file.
stemsCollection of stems
Returns
true if successful.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ addIndex()

boolean edu.usfca.cs272.InvertedIndex.addIndex ( InvertedIndex other)

Copies data from another inverted index into this index.

Parameters
othera different inverted index
Returns
true if the add is successful.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ exactSearch()

ArrayList< Score > edu.usfca.cs272.InvertedIndex.exactSearch ( Set< String > queries)

Performs exact search on a set of queries

Parameters
queriesset of queries.
Returns
ArrayList of Scores.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ getCounts()

Map< String, Integer > edu.usfca.cs272.InvertedIndex.getCounts ( )

Returns unmodifiable map of files and their stem counts.

Returns
unmodifiable map of files and their stem counts.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ getLocations()

Set< String > edu.usfca.cs272.InvertedIndex.getLocations ( String word)

returns the locations in which a word occurs

Parameters
wordstem to be searched
Returns
locations.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ getPositions()

Set< Integer > edu.usfca.cs272.InvertedIndex.getPositions ( String word,
String location )

Returns unmodifiable map where key is file path value is location of word.

Parameters
wordkey in the index.
locationthe file in which word is located.
Returns
unmodifiable map where key is file path value is location of word.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ getWords()

Set< String > edu.usfca.cs272.InvertedIndex.getWords ( )

Returns unmodifiable set of keys in the index.

Returns
unmodifiable set of keys in the index.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ hasCount()

boolean edu.usfca.cs272.InvertedIndex.hasCount ( String location)

checks if stem counts for a location is present.

Parameters
locationpath of file.
Returns
true if there is a stem count for the location.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ hasLocation()

boolean edu.usfca.cs272.InvertedIndex.hasLocation ( String word,
String location )

checks if the index has a location for the word.

Parameters
wordstem in the index.
locationlocation of the stem.
Returns
true if the stem has that location. false if the word or location is not in the index.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ hasPosition()

boolean edu.usfca.cs272.InvertedIndex.hasPosition ( String word,
String location,
int position )

Checks to see if a word is present in location at specified position

Parameters
wordstem to be checked
locationfile path
positionposition in file to be checked.
Returns
true if the word is found in the location at specified location.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ hasWord()

boolean edu.usfca.cs272.InvertedIndex.hasWord ( String word)

checks if word is in the index or not.

Parameters
wordstem to be looked up
Returns
true if word is in the index.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ isEmpty()

boolean edu.usfca.cs272.InvertedIndex.isEmpty ( )

Returns true if index is empty.

Returns
true if index is empty.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ numOfLocations()

int edu.usfca.cs272.InvertedIndex.numOfLocations ( String word)

Returns the number of locations where a word occurs.

Parameters
wordstem to be searched.
Returns
the number of locations where a word occurs.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ numOfPositions()

int edu.usfca.cs272.InvertedIndex.numOfPositions ( String word,
String location )

Returns the number of positions where a word occurs in a location.

Parameters
wordstem to be searched.
locationfile path.
Returns
the number of positions where the word occurs in location.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ partialSearch()

ArrayList< Score > edu.usfca.cs272.InvertedIndex.partialSearch ( Set< String > queries)

Performs partial search on index

Parameters
queriesset of queries
Returns
ArrayList of Scores

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ search()

ArrayList< Score > edu.usfca.cs272.InvertedIndex.search ( Set< String > queries,
boolean partial )

Method to determine if partial or exact search needs to be performed.

Parameters
queriesset of stems in the query.
partialpartial flag.
Returns
ArrayList of scores

◆ size()

int edu.usfca.cs272.InvertedIndex.size ( )

Returns the number of stems in the index.

Returns
the number of stems in the index.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ sizeOfCounts()

int edu.usfca.cs272.InvertedIndex.sizeOfCounts ( )

Returns the number of locations for which there is a stem count.

Returns
the number of locations for which there is a stem count.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ toJson()

void edu.usfca.cs272.InvertedIndex.toJson ( Path output) throws IOException

writes index in pretty Json to output file.

Parameters
outputPath of output file.
Exceptions
IOExceptionif path is invalid.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.

◆ toString()

String edu.usfca.cs272.InvertedIndex.toString ( )

Returns Inverted Index in pretty Json.

Returns
Inverted Index in pretty Json.

Reimplemented in edu.usfca.cs272.ThreadSafeInvertedIndex.


The documentation for this class was generated from the following file: