---
# System prepended metadata

title: Untitled

---

```java

class Document {
    String DocumentNumber;
    tokenFrequency: HashMap<Token, Frequency>;
    
    int tf(Token token) {
        tokenFrequency.get(token); // or 0
    }
}

// Pre-processing (one doccument at a time), also filters the text
//Takes: "file handle / file name"
//Returns: Document class

// For use with queries
// static fn
// Takes: "string value"
//Returns: HashMap<Token, Frequency>
class PreProcessor {

static public Document[] processFile(String fileName){ // Given a file, will return an array of each doccument within the file.
    
}

static public Document tokenize(String docNum, String text){ // Given a document number and the text of a doccument, will return a doccument
    
}

// Indexing
//Takes: List<Document>
//Returns: HashMap<Term, List<Document>> as Index

class Indexer {
static HashMap<String, List<Document>> index(List<Documemnt> docs);
// Optionally, create a start() fn, void process(Document), and Index getIndex() functions instead
}

// Querying
//Takes: Index, Query
//Returns: List<Document, Score>
class Search {
    Search(HashMap<String, List<Document>> index); // Initialize
    
    List<Document, Score> query(HashMap<Token, Frequency> query);
}



// For each doccument passed, create a dicitonary (Ryan)
// where tokens[chrome] = number of times chrome occurs in doccument.
HashMap<String, Int> tokenize(document: string);

    
// finding cosine similarity

queryTokens = tokenize(query)

document: Array<HashMap<String, Int>>


idf[word] = log2(NUM_DOCUMENTS / len(index[word]))
    

int score = compare(tokenize(query), index[word], idf[word]);



```