Skip to content

Commit

Permalink
ilo nanpa Scaling o lon
Browse files Browse the repository at this point in the history
  • Loading branch information
gregdan3 committed Apr 23, 2024
1 parent 7d7bc51 commit 0725e04
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/otokipona/Scorers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ class Scaling(Scorer):
In other words, filter order matters, weighing earlier listed filters higher than later ones.
"""

@classmethod
def __score(cls, token: str, filters: List[Type[Filter]], scale: int):
for i, f in enumerate(filters):
if f.filter(token):
return scale - i
return 0

@classmethod
@override
def score(cls, tokens: List[str], filters: List[Type[Filter]]) -> Number:
total_score = 0
len_tokens = len(tokens)
max_scale = len_tokens - 1
max_score = max_scale * len_tokens
for token in tokens:
total_score += cls.__score(token, filters, max_scale)
return total_score / max_score if max_score else 0


class Logarithmic(Scorer): ...

Expand Down

0 comments on commit 0725e04

Please sign in to comment.