Skip to content

Commit

Permalink
Fixed type hint and added example of label vector for build_word_freq…
Browse files Browse the repository at this point in the history
…uency() method (#198)
  • Loading branch information
BeneHTWG authored Dec 6, 2024
1 parent 0cc44dd commit f4977b5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/htwgnlp/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from collections import defaultdict

import numpy as np
import numpy.typing as npt


class CountVectorizer:
Expand All @@ -31,12 +32,13 @@ def __init__(self):
raise NotImplementedError("This method needs to be implemented.")

def build_word_frequencies(
self, tweets: list[list[str]], labels: np.ndarray
self, tweets: list[list[str]], labels: npt.NDArray[np.int_]
) -> None:
"""Builds a dictionary of word frequencies by counting the number of occurrences of each word in each class.
The key is a tuple of the word and the class, the value is the frequency of the word in the class.
For example, the key ('happi', 1) refers to the word 'happi' in the positive class,
while ('happi', 0) refers to 'happi' in the negative class,
and the value it holds is the number of times the word 'happi' occurs in the positive class.
Example:
Expand All @@ -47,8 +49,7 @@ def build_word_frequencies(
Args:
tweets (list[list[str]]): a list of tokenized tweets
labels (list[str]): a list of corresponding class labels
labels (npt.NDArray[np.int_]): a column vector of corresponding class labels , e.g. `np.array([[1], [0], [1], [0]]`)
"""
# TODO ASSIGNMENT-2: implement this method
raise NotImplementedError("This method needs to be implemented.")
Expand Down

0 comments on commit f4977b5

Please sign in to comment.