wn.ili¶
Interlingual Indices
This module provides classes and functions for inspecting Interlingual Index (ILI) objects, both existing and proposed and including their definitions and any metadata, for synsets and lexicons.
Note
See Interlingual Queries for background and usage information about ILIs.
Functions for Getting ILI Objects¶
The following functions are for getting individual ILI and
ProposedILI objects from ILI identifiers or synsets, respectively, or
to list all such known objects.
- wn.ili.get(id: str) ILI | None¶
Get the ILI object with the given id.
The id argument is a string ILI identifier. If id does not match a known ILI,
Noneis returned. Note that aNonevalue does not necessarily mean that there is no such ILI, but rather that no resource declaring that ILI has been loaded into Wn's database.Example:
>>> from wn import ili >>> ili.get("i12345") ILI('i12345') >>> ili.get("i0") is None True
- wn.ili.get_all(*, status: ILIStatus | str | None = None, lexicon: str | None = None) list[ILI]¶
Get the list of all matching ILI objects.
The status argument may be a string matching a single
ILIStatus, or a union of one or moreILIStatusvalues. The lexicon argument is a space-separated string of lexicon specifiers. All ILIs with a matching status and lexicon will be returned.Example:
>>> from wn import ili >>> len(ili.get_all()) 117442
- wn.ili.get_proposed(synset: Synset) ProposedILI | None¶
Get a proposed ILI for synset if it exists.
The synset itself does not give a good indication if it has an associated proposed ILI. The
wn.Synset.ilivalue will beNone, but this is also true if there is no ILI at all. In most cases it is easier to list the proposed ILIs for a lexicon usingget_all_proposed(), then to retrieve their associated synsets.Example:
>>> import wn >>> from wn import ili >>> en = wn.Wordnet("oewn:2024") >>> en.synset("oewn-00002935-r").ili is None True >>> ili.get_proposed(en.synset("oewn-00002935-r")) ProposedILI(_synset='oewn-00002935-r', _lexicon='oewn:2024')
- wn.ili.get_all_proposed(lexicon: str | None = None) list[ProposedILI]¶
Get the list of all proposed ILI objects.
The lexicon argument is a space-separated string of lexicon specifiers. Proposed ILIs matching the lexicon will be returned.
Example:
>>> from wn import ili >>> proposed = ili.get_all_proposed("oewn:2024") >>> proposed[0] ProposedILI(_synset='oewn-00002935-r', _lexicon='oewn:2024') >>> proposed[0].synset() Synset('oewn-00002935-r')
ILI Status¶
The status of an ILI object (ILI.status or ProposedILI.status)
indicates what is known about its validity. Explicit information about ILIs can
be added to Wn with wn.add() (e.g., wn.add("cili")), but without
it Wn can only make a guess.
If a lexicon has synsets referencing some ILI identifier and no ILI file has
been loaded, that ILI would have a status of ILIStatus.PRESUPPOSED. If
an ILI file has been loaded that lists the identifier, it would have a status of
ILIStatus.ACTIVE, whether or not a lexicon has been added that uses
the ILI. Both of these cases use ILI objects.
A synset in the WN-LMF format may also propose a new ILI. It won't have an
identifier, but it should have a definition. These have the status of
ILIStatus.PROPOSED. The ProposedILI is used for these objects,
and that is the only status they have.
The ILIStatus.UNKNOWN status is just a default (e.g., when manually
creating an ILI object) and won't be encountered in normal scenarios.
ILI Classes¶
- class wn.ili.ILI(id: str = <property object>, status: ILIStatus = ILIStatus.UNKNOWN, _definition_text: str | None = None, _definition_metadata: Metadata | None = None)¶
A class for interlingual indices.
- definition(*, data: bool = False) str | ILIDefinition | None¶
Return the ILI's definition.
If the data argument is
False(the default), the definition is returned as astrtype. If it isTrue, awn.ILIDefinitionobject is used instead.Note that
ILIobjects will not have definitions unless an ILI resource has been added, butProposedILIobjects will have definitions if one is provided by the proposing lexicon.
- class wn.ili.ProposedILI(_synset: 'str', _lexicon: 'str', _definition_text: 'str | None' = None, _definition_metadata: 'Metadata | None' = None)¶
- property id: Literal[None]¶
Always return
None.Proposed ILIs do not have identifiers. This method is kept for interface consistency.
- property status: Literal[ILIStatus.PROPOSED]¶
Always return
ILIStatus.PROPOSED.Proposed ILI objects are only used for ILIs that are proposed.
- definition(*, data: bool = False) str | ILIDefinition | None¶
Return the ILI's definition.
If the data argument is
False(the default), the definition is returned as astrtype. If it isTrue, awn.ILIDefinitionobject is used instead.Note that
ILIobjects will not have definitions unless an ILI resource has been added, butProposedILIobjects will have definitions if one is provided by the proposing lexicon.
ILI Definitions¶
Most likely someone inspecting the definition of an ILI or
ProposedILI only cares about the definition text, but for
completeness' sake the ILIDefinition object models the text
along with any metadata that may have appeared in the WN-LMF lexicon
file. ILI files do not currently model metadata.