File: metrics.py

package info (click to toggle)
python-wn 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,100 kB
  • sloc: python: 8,429; xml: 566; sql: 238; makefile: 12
file content (12 lines) | stat: -rw-r--r-- 267 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
from wn._core import Synset, Word

# Word-based Metrics


def ambiguity(word: Word) -> int:
    return len(word.synsets())


def average_ambiguity(synset: Synset) -> float:
    words = synset.words()
    return sum(len(word.synsets()) for word in words) / len(words)