Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add type hints #49

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion docs/api_reference/ttr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Type Token Ratios
.. automodule:: TRUNAJOD.ttr
:members:

.. bibliography:: ttr.bib
.. bibliography:: ttr.bib
4 changes: 1 addition & 3 deletions src/TRUNAJOD/ttr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
tend to 0. This measurement is not recommended if analyzing texts of different
lengths, as when the number of tokens increases, the TTR tends flatten.
"""
import math
from collections import defaultdict
from typing import Dict
from typing import List
Expand Down Expand Up @@ -139,7 +140,6 @@ def yule_k(doc: Doc) -> float:
rs[value] += 1

return 1e-4 * sum(r ** 2 * vr - N for r, vr in rs.items()) / N ** 2
<<<<<<< HEAD


def d_estimate(
Expand Down Expand Up @@ -201,5 +201,3 @@ def d_estimate(
y = ttrs ** 2
d = np.linalg.lstsq(A, y, rcond=None)[0]
return d[0]
=======
>>>>>>> bd81ddf (remove g index from this branch)
7 changes: 0 additions & 7 deletions tests/ttr_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"""TRUNAJOD ttr tests."""
<<<<<<< HEAD
import string
=======
>>>>>>> bd81ddf (remove g index from this branch)
from collections import namedtuple

import numpy as np
Expand Down Expand Up @@ -58,7 +55,6 @@ def test_yule_k(test_doc):
4: 1,
}
expected_k = 1e-4 * sum(r ** 2 * vr - n for r, vr in rs.items()) / n ** 2
<<<<<<< HEAD
assert ttr.yule_k(test_doc) == expected_k


Expand Down Expand Up @@ -94,6 +90,3 @@ def test_d_estimate():

np.random.seed(0)
assert ttr.d_estimate(doc) == 119.4468681409897
=======
assert ttr.yule_k(doc) == expected_k
>>>>>>> bd81ddf (remove g index from this branch)