lingpy package¶
Subpackages¶
- lingpy.algorithm package
- lingpy.align package
- Submodules
- lingpy.align.multiple module
Multiple
Multiple.align()
Multiple.get_local_peaks()
Multiple.get_pairwise_alignments()
Multiple.get_peaks()
Multiple.get_pid()
Multiple.iterate_all_sequences()
Multiple.iterate_clusters()
Multiple.iterate_orphans()
Multiple.iterate_similar_gap_sites()
Multiple.lib_align()
Multiple.prog_align()
Multiple.sum_of_pairs()
Multiple.swap_check()
mult_align()
- lingpy.align.pairwise module
- lingpy.align.sca module
- Module contents
- lingpy.basic package
- Submodules
- lingpy.basic.ops module
- lingpy.basic.parser module
- lingpy.basic.tree module
- lingpy.basic.wordlist module
BounceAsID
Wordlist
Wordlist.add_entries()
Wordlist.calculate()
Wordlist.coverage()
Wordlist.export()
Wordlist.from_cldf()
Wordlist.get_dict()
Wordlist.get_distances()
Wordlist.get_etymdict()
Wordlist.get_list()
Wordlist.get_paps()
Wordlist.get_tree()
Wordlist.iter_cognates()
Wordlist.iter_rows()
Wordlist.output()
Wordlist.renumber()
from_cldf()
get_wordlist()
- Module contents
- lingpy.compare package
- Submodules
- lingpy.compare.lexstat module
- lingpy.compare.partial module
- lingpy.compare.phylogeny module
PhyBo
PhyBo.analyze()
PhyBo.get_ACS()
PhyBo.get_AVSD()
PhyBo.get_CVSD()
PhyBo.get_GLS()
PhyBo.get_IVSD()
PhyBo.get_MLN()
PhyBo.get_MSN()
PhyBo.get_PDC()
PhyBo.get_edge()
PhyBo.get_stats()
PhyBo.plot_ACS()
PhyBo.plot_GLS()
PhyBo.plot_MLN()
PhyBo.plot_MLN_3d()
PhyBo.plot_MSN()
PhyBo.plot_concept_evolution()
PhyBo.plot_two_concepts()
TreBor
get_gls()
- lingpy.compare.sanity module
- lingpy.compare.strings module
- lingpy.compare.util module
- Module contents
- lingpy.convert package
- lingpy.data package
- lingpy.evaluate package
- lingpy.meaning package
- lingpy.read package
- lingpy.sequence package
- Submodules
- lingpy.sequence.generate module
- lingpy.sequence.ngrams module
- lingpy.sequence.profile module
- lingpy.sequence.smoothing module
- lingpy.sequence.sound_classes module
- Module contents
- lingpy.thirdparty package
Submodules¶
lingpy.basictypes module¶
- lingpy.basictypes.integer(x)¶
lingpy.cache module¶
Implements the lingpy cache.
Some operations in lingpy may be time consuming, so we provide a mechanism to cache the results of these operations.
- lingpy.cache.dump(data, filename, d=PosixPath('/home/mattis/.cache/lingpy/2.6.13'))¶
- lingpy.cache.load(filename, d=PosixPath('/home/mattis/.cache/lingpy/2.6.13'))¶
- lingpy.cache.path(filename, d=PosixPath('/home/mattis/.cache/lingpy/2.6.13'))¶
lingpy.cli module¶
- class lingpy.cli.Command¶
Bases:
object
Base class for subcommands of the lingpy command line interface.
- help = None¶
- output(args, content)¶
- classmethod subparser(parser)¶
Hook to define subcommand arguments.
- class lingpy.cli.CommandMeta(name, bases, dct)¶
Bases:
type
A metaclass which keeps track of subclasses, if they have all-lowercase names.
- lingpy.cli.add_align_method_option(p)¶
- lingpy.cli.add_cognate_identifier_option(p, default)¶
- lingpy.cli.add_format_option(p, default, choices)¶
- lingpy.cli.add_method_option(p, default, choices, spec='')¶
- lingpy.cli.add_mode_option(p, choices)¶
- lingpy.cli.add_option(parser, name_, default_, help_, short_opt=None, **kw)¶
- lingpy.cli.add_strings_option(p, n)¶
- lingpy.cli.add_tree_calc_option(p)¶
- class lingpy.cli.alignments¶
Bases:
Command
Carry out alignment analysis of a wordlist file with readily detected cognates.
- classmethod subparser(p)¶
Hook to define subcommand arguments.
- lingpy.cli.get_parser()¶
- class lingpy.cli.help¶
Bases:
Command
Show help for commands.
- classmethod subparser(parser)¶
Hook to define subcommand arguments.
- class lingpy.cli.lexstat¶
Bases:
Command
- classmethod subparser(p)¶
Hook to define subcommand arguments.
- lingpy.cli.main(*args)¶
LingPy command line interface.
- class lingpy.cli.multiple¶
Bases:
Command
Multiple alignment console interface for LingPy.
- classmethod subparser(p)¶
Hook to define subcommand arguments.
- class lingpy.cli.pairwise¶
Bases:
Command
Run pairwise analyses from command line in LingPy
Notes
Currently, the following options are supported:
run normal analyses without sound class strings
run sound-class based analyses
Furthermore, input output is handled as follows:
define user input using psa-formats in lingpy
define user output (stdout, file)
- classmethod subparser(p)¶
Hook to define subcommand arguments.
- class lingpy.cli.profile¶
Bases:
Command
- classmethod subparser(p)¶
Hook to define subcommand arguments.
lingpy.config module¶
Configuration management for lingpy.
Various aspects of lingpy can be configured and customized by the user. This is done with configuration files in the user’s config dir.
- class lingpy.config.Config(name, default=None, **kw)¶
Bases:
RawConfigParser
lingpy.log module¶
Logging utilities
- class lingpy.log.CustomFilter(name='')¶
Bases:
Filter
- filter(record)¶
Determine if the specified record is to be logged.
Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.
- class lingpy.log.Logging(level=10, logger=None)¶
Bases:
object
A context manager to execute a block of code at a specific logging level.
- lingpy.log.debug(msg, **kw)¶
- lingpy.log.deprecated(old, new)¶
- lingpy.log.error(msg, **kw)¶
- lingpy.log.file_written(fname, logger=None)¶
- lingpy.log.get_level()¶
- lingpy.log.get_logger(config_dir=None, force_default_config=False, test=False)¶
Get a logger configured according to the lingpy log config file.
Note: If no logging configuration file exists, it will be created.
- Parameters:
config_dir – Directory in which to look for/create the log config file.
force_default_config – Configure the logger using the default config.
test – Force reconfiguration of the logger.
- Returns:
A logger.
- lingpy.log.info(msg, **kw)¶
- lingpy.log.missing_module(name, logger=None)¶
- lingpy.log.warning(msg)¶
lingpy.settings module¶
Module handels all global parameters used in a LingPy session.
- lingpy.settings.rc(rval=None, rcParams_=None, **keywords)¶
Function changes parameters globally set for LingPy sessions.
- Parameters:
rval : string (default=None)
Use this keyword to specify a return-value for the rc-function.
schema : {“ipa”, “asjp”}
Change the basic schema for sequence comparison. When switching to “asjp”, this means that sequences will be treated as sequences in ASJP code, otherwise, they will be treated as sequences written in basic IPA.
rcParams_ : Allow passing in a plain dict for testing.
Notes
This function is the standard way to communicate with the rcParams dictionary which is not imported as a default. If you want to see which parameters there are, you can load the rcParams dictonary directly:
>>> from lingpy.settings import rcParams
However, be careful when changing the values. They might produce some unexpected behavior.
Examples
Import LingPy:
>>> from lingpy import *
Switch from IPA transcriptions to ASJP transcriptions:
>>> rc(schema="asjp")
You can check which “basic orthography” is currently loaded:
>>> rc(basic_orthography) 'asjp' >>> rc(schema='ipa') >>> rc(basic_orthography) 'fuzzy'
lingpy.util module¶
- lingpy.util.as_string(obj, pprint=False)¶
- lingpy.util.charstring(id_, char='X', cls='-')¶
- lingpy.util.combinations2(iterable)¶
Convenience shortcut
- lingpy.util.data_path(*comps)¶
- lingpy.util.dotjoin(*args, **kw)¶
Convenience shortcut. Strings to be joined do not have to be passed as list or tuple.
Notes
An implicit conversion of objects to strings is performed as well.
- lingpy.util.identity(x)¶
- lingpy.util.join(sep, *args, **kw)¶
Convenience shortcut. Strings to be joined do not have to be passed as list or tuple.
Notes
An implicit conversion of objects to strings is performed as well.
- lingpy.util.lines_to_text(lines)¶
- lingpy.util.lingpy_path(*comps)¶
- lingpy.util.multicombinations2(iterable)¶
Convenience shortcut, for the name, see the Wikipedia article on Combination.
https://en.wikipedia.org/wiki/Combination#Number_of_combinations_with_repetition
- lingpy.util.nexus_slug(s)¶
Converts a string to a nexus “safe” representation (i.e. removes many unicode characters and removes some punctuation characters).
- Parameters:
s : str
A string to convert to a nexus safe format.
- Returns:
s : str
A string containing a nexus safe label.
- lingpy.util.random_choices(population, weights=None, cum_weights=None, k=1)¶
Return a population sample from weighted elements.
In particular, return a k sized list of elements chosen from population with replacement and according to a list of weights. If a weights sequence is specified, selections are made according to the relative weights. Alternatively, if a cum_weights sequence is given, the selections are made according to the cumulative weights. For example, the relative weights [10, 5, 30, 5] are equivalent to the cumulative weights [10, 15, 45, 50]. Internally, the relative weights are converted to the cumulative weights before making selections, so supplying the cumulative weights saves work.
This function is compatible with the random.choices() function available in Python’s standard library from version 3.6 on. It can be replaced by the standard implementation once the version requirement is updated.
- Parameters:
population: list :
A list of elements from which the element(s) will be drawn.
weights: list :
A list of any numeric type with the relative weight of each element. Either weights or cum_weights must be provided.
cum_weights: list :
A list of any numeric type with the accumulated weight of each element. Either weights or cum_weights must be provided.
k: int :
The number of elements to be drawn, with replacement.
- Returns:
sample: list :
A list of elements randomly drawn according to the specified weights.
- lingpy.util.read_config_file(path, **kw)¶
Read lines of a file ignoring commented lines and empty lines.
- lingpy.util.read_text_file(path, normalize=None, lines=False)¶
Read a text file encoded in utf-8.
- Parameters:
path : { Path, str }
File-system path of the file.
normalize : { None, “NFC”, “NFC” }
If not None a valid unicode normalization mode must be passed.
lines : bool (default=False)
Flag signalling whether to return a list of lines (without the line-separation character).
- Returns:
file_content : { list, str }
File content as unicode object or list of lines as unicode objects.
Notes
The whole file is read into memory.
- lingpy.util.setdefaults(d, **kw)¶
Shortcut for a common idiom, setting multiple default values at once.
- Parameters:
d : dict
Dictionary to be updated.
kw : dict
Dictionary with default values.
- lingpy.util.tabjoin(*args, **kw)¶
Convenience shortcut. Strings to be joined do not have to be passed as list or tuple.
Notes
An implicit conversion of objects to strings is performed as well.
- lingpy.util.write_text_file(path, content, normalize=None, log=True)¶
Write a text file encoded in utf-8.
- Parameters:
path : {str, Path}
File-system path of the file.
content : str
The text content to be written.
normalize : { None, “NFC”, “NFD” } (default=False)
If not None a valid unicode normalization mode must be passed.
log : bool (default=True)
Indicate whether you want to log the result of the file writing process.
Module contents¶
LingPy package for quantitative tasks in historical linguistics.
Documentation is available in the docstrings. Online documentation is available at http://lingpy.org