hanifhefaz/elm-tf-idf/1.0.0

TfIdf

#Term Frequency TF

tf : String -> List String -> Float
Calculate Term Frequency (TF) for a given term in a document.


The term frequency is the number of times a term appears in a document 
divided by the total number of terms in that document.


## Parameters
- `term`: The term for which the frequency is to be calculated.
- `document`: The list of terms (words) in the document.


## Returns
A float representing the term frequency (TF) of the term in the document.

#Inverse Document Frequency IDF

idf : String -> List (List String) -> Float
Calculate Inverse Document Frequency (IDF) for a given term across multiple documents.


The inverse document frequency measures how important a term is by 
determining how many documents contain the term.


## Parameters
- `term`: The term for which the IDF is to be calculated.
- `documents`: A list of documents, where each document is represented as a list of terms.


## Returns
A float representing the inverse document frequency (IDF) of the term.

#Calculate the TF-IDF score for a given term in a specific document

tfidf : String -> List String -> List (List String) -> Float
Calculate the TF-IDF score for a given term in a specific document 
based on the set of documents.


The TF-IDF score is a measure of how relevant a term is to a document 
within a collection of documents.


## Parameters
- `term`: The term for which the TF-IDF score is to be calculated.
- `document`: The list of terms (words) in the document.
- `documents`: A list of documents to compute the IDF.


## Returns
A float representing the TF-IDF score of the term in the document.

#Calculate the TF-IDF score for a term across all documents.

calculateTfidfForTerm : String -> List (List String) -> List Float
Calculate the TF-IDF score for a term across all documents.


This function applies the TF-IDF calculation to each document in the 
provided list of documents.


## Parameters
- `term`: The term for which the TF-IDF scores are to be calculated.
- `docs`: A list of documents, where each document is represented as a list of terms.


## Returns
A list of floats representing the TF-IDF scores for the term in each document.