dpalmasan / TRUNAJOD2.0

An easy-to-use library to extract indices from texts.

Home Page:https://trunajod20.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add type hints to discourse markers

dpalmasan opened this issue · comments

Add type hints to discourse markers features. This can be found in the following source code:

https://github.com/dpalmasan/TRUNAJOD2.0/blob/master/src/TRUNAJOD/discourse_markers.py

For example, the function find_matches (which already has a docstring specifying types):

def find_matches(text, list):
    """Return matches of words in list in a target text.
    Given a text and a list of possible matches (in this module, discourse
    markers list), returns the number of matches found in text. This ignores
    case.
    .. hint:: For non-Spanish users
       You could use this function with your custom list of discourse markers
       in case you need to compute this metric. In that case, the way to call
       the funcion would be: ``find_matches(YOUR_TEXT, ["dm1", "dm2", etc])``
    :param text: Text to be processed
    :type text: string
    :param list: list of discourse markers
    :type list: Python list of strings
    :return: Number of ocurrences
    :rtype: int
    """
    counter = 0
    for w in list:
        results = re.findall(r"\b%s\b" % w, text, re.IGNORECASE)
        counter += len(results)
    return counter

Could be updated to:

def find_matches(text: str, list: List[str]) -> int:

PR addressing this was merged. Closing.