Languoid data
All metadata related to a languoid (i.e. the content of the languoid’s INI file
and the classification - its relation to other languoids) is available from a
pyglottolog.languoids.Languoid
instance.
- class pyglottolog.languoids.Languoid(cfg, lineage=None, id_=None, directory=None, tree=None, _api=None)[source]
Info on languoids is encoded in the INI files and in the directory hierarchy of
pyglottolog.Glottolog.tree
. This class provides access to all of it.Languoid formatting:
- Variables:
_format_specs – A dict mapping custom format specifiers to conversion functions. Usage:
>>> l = Languoid.from_name_id_level(pathlib.Path('.'), 'N(a,m)e', 'abcd1234', 'language') >>> '{0:newick_name}'.format(l) 'N{a/m}e'
See also
https://www.python.org/dev/peps/pep-3101/#format-specifiers and https://www.python.org/dev/peps/pep-3101/#controlling-formatting-on-a-per-type-basis
- Parameters:
cfg (
clldutils.inifile.INI
) –lineage (
typing.Optional
[typing.List
[typing.Tuple
[str
,str
,str
]]]) –id_ (
typing.Optional
[str
]) –directory (
typing.Optional
[pathlib.Path
]) –tree (
typing.Optional
[pathlib.Path
]) –
Refer to the factory methods for typical use cases of instantiating a Languoid:
Languoid.from_id_name_level()
- Parameters:
cfg (
clldutils.inifile.INI
) – INI instance storing the languoid’s metadata.lineage (
typing.Optional
[typing.List
[typing.Tuple
[str
,str
,str
]]]) – list of ancestors (from root to this languoid).id – Glottocode for the languoid (or None, if directory is passed).
_api – Some properties require access to config data which is accessed through a Glottolog API instance.
id_ (
typing.Optional
[str
]) –directory (
typing.Optional
[pathlib.Path
]) –tree (
typing.Optional
[pathlib.Path
]) –
- classmethod from_dir(directory, nodes=None, _api=None, **kw)[source]
Create a Languoid from a directory, named with the Glottocode and containing md.ini.
This method is used by
pyglottolog.Glottolog
to read Languoid`s from the repository’s `languoids/tree directory.- Parameters:
directory (
pathlib.Path
) –
- classmethod from_name_id_level(tree, name, id, level, **kw)[source]
This method is used in pyglottolog.lff to instantiate Languoid s for new nodes encountered in “lff”-format trees.
- newick_node(nodes=None, template=None, maxlevel=None, level=0)[source]
Return a newick.Node representing the subtree of the Glottolog classification starting at the languoid.
- Parameters:
template – Python format string accepting the Languoid instance as single variable named l, used to format node labels.
- Return type:
newick.Node
- write_info(outdir=None)[source]
Write Languoid metadata as INI file to outdir/<INFO_FILENAME>.
- Parameters:
outdir (
typing.Optional
[pathlib.Path
]) –
- property glottocode
Alias for id
- property category
Languoid category.
Category name from
pyglottolog.config.LanguageType
for languoids of level “language”,“Family” or “Pseudo Family” for families,
“Dialect” for dialects.
- property isolate: bool
Flag signaling whether the languoid is an isolate, i.e. has level “language” and is not member of a family.
- property children: List[Languoid]
List of direct descendants of the languoid in the classification tree.
Note
Using this on many languoids can be slow, because the directory tree may be traversed and INI files read multiple times. To circumvent this problem, you may use a read-only
pyglottolog.Glottolog
instance, by passing cache=True at initialization.
- property ancestors: List[Languoid]
List of ancestors of the languoid in the classification tree, from root (i.e. top-level family) to parent node.
Note
Using this on many languoids can be slow, because the directory tree may be traversed and INI files read multiple times. To circumvent this problem, you may use a read-only
pyglottolog.Glottolog
instance, by passing cache=True at initialization.
- property parent: Languoid | None
Parent languoid or None.
Note
Using this on many languoids can be slow, because the directory tree may be traversed and INI files read multiple times. To circumvent this problem, you may use a read-only
pyglottolog.Glottolog
instance, by passing cache=True at initialization.
- property family: Languoid | None
Top-level family the languoid belongs to or None.
Note
Using this on many languoids can be slow, because the directory tree may be traversed and INI files read multiple times. To circumvent this problem, you may use a read-only
pyglottolog.Glottolog
instance, by passing cache=True at initialization.
- property names: Dict[str, list]
A dict mapping alternative name providers to list s of alternative names for the languoid by the given provider.
- property sources: List[Reference]
List of Glottolog references linked to the languoid
- Return type:
pyglottolog.references.Reference
- property endangerment: None | Endangerment
Endangerment information about the languoid.
- Return type:
- property classification_comment: None | ClassificationComment
Classification information about the languoid.
- Return type:
- property ethnologue_comment: None | EthnologueComment
Commentary about the classification of the languoid in Ethnologue.
- Return type:
- property links: List[Link]
Links to web resources related to the languoid
- property countries: List[Country]
Countries a language is spoken in.
- property name
The Glottolog mame of the languoid
- property latitude: None | float
The geographic latitude of the point chosen as representative coordinate of the languoid
- property longitude: None | float
The geographic longitude of the point chosen as representative coordinate of the languoid
- class pyglottolog.languoids.Glottocodes(fname)[source]
Registry keeping track of glottocodes that have been dealt out.
Some of the data available for languoids has enough internal structure to merit separate classes, simplyfying access.
- class pyglottolog.languoids.Reference(key, pages=None, trigger=None, endtag='**')[source]
A reference of a bibliographical record in Glottolog.
Method generated by attrs for class Reference.
- key
- pages
- class pyglottolog.languoids.Endangerment(status, source, comment, date)[source]
Info about the endangerment status of the languoid
- Parameters:
status (
pyglottolog.config.AES
) –source (
pyglottolog.config.AESSource
) –
Method generated by attrs for class Endangerment.
- Parameters:
status (
pyglottolog.config.AES
) –source (
pyglottolog.config.AESSource
) –
-
status:
pyglottolog.config.AES
-
source:
pyglottolog.config.AESSource
- comment
- date
Date when the endangerment status was assessed
- class pyglottolog.languoids.EthnologueComment(isohid, comment_type, ethnologue_versions='', comment=None)[source]
Commentary about the classification of the languoid according to Ethnologue
Method generated by attrs for class EthnologueComment.
- comment_type
Either
“spurious” meaning the comment is to explain why the languoid in question is spurious and in which Ethnologue (as below) that is/was
“missing” meaning the comment is to explain why the languoid in question is missing (as a language entry) and in which Ethnologue (as below) that is/was
- ethnologue_versions
Which Ethnologue version(s) from E16-E19 the comment pertains to, joined by /:s. E.g. E16/E17. In the case of comment_type=spurious, E16/E17 in the version field means that the code was spurious in E16/E17 but no longer spurious in E18/E19. In the case of comment_type=missing, E16/E17 would mean that the code was missing from E16/E17, but present in E18/E19. If the comment concerns a language where versions would be the empty string, instead the string ISO 639-3 appears.
- comment
- class pyglottolog.languoids.ISORetirement(code=None, name=None, change_request=None, effective=None, reason=None, change_to=_Nothing.NOTHING, remedy=None, comment=None)[source]
Information extracted from accepted ISO 639-3 change requests about retired ISO codes associated with the languoid.
Method generated by attrs for class ISORetirement.
- code
Retired ISO 639-3 code
- name
Name of the retired ISO language
- change_request
Number of the ISO change request
- effective
Date of acceptance of the change request
- reason
Reason to retire the ISO code
- change_to
List of ISO codes replacing the retired code
- remedy
What to do about the retired code
- comment
- class pyglottolog.languoids.ClassificationComment(sub=None, subrefs=_Nothing.NOTHING, family=None, familyrefs=_Nothing.NOTHING)[source]
Commentary on the classification of the languoid
Method generated by attrs for class ClassificationComment.
- sub
Commentary on the internal classification of the descendants of the languoid
-
subrefs:
typing.List
[pyglottolog.languoids.models.Reference
] References for the internal classification
- family
Commentary on the classification of the languoid within its family
-
familyrefs:
typing.List
[pyglottolog.languoids.models.Reference
] References for the family classification