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
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):Could be updated to: