File: _metadata.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 (41 lines) | stat: -rw-r--r-- 960 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from typing import Protocol, TypedDict


class Metadata(TypedDict, total=False):
    # For these, see https://globalwordnet.github.io/schemas/dc/
    contributor: str
    coverage: str
    creator: str
    date: str
    description: str
    format: str
    identifier: str
    publisher: str
    relation: str
    rights: str
    source: str
    subject: str
    title: str
    type: str
    # Additional WN-LMF metadata
    status: str
    note: str
    confidenceScore: float


class HasMetadata(Protocol):
    @property
    def _metadata(self) -> Metadata | None:
        return None

    def metadata(self) -> Metadata:
        """Return the associated metadata."""
        return self._metadata if self._metadata is not None else Metadata()

    def confidence(self) -> float:
        """Return the confidence score.

        If the confidenceScore metadata is available, return it. If not,
        use a default confidence value.
        """
        ...