Exemple #1
0
def rc(rval=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.

    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'

    """
    from lingpy import log

    if rval:
        return rcParams[rval]

    for key in keywords:
        if key == "schema":
            if keywords[key] in ["qlc", 'ipa']:
                diacritics, vowels, tones = load_dvt(path='')
                rcParams['asjp'] = Model('asjp')
                rcParams['sca'] = Model('sca')
                rcParams['dolgo'] = Model('dolgo')
                rcParams['art'] = Model('art')
                rcParams['diacritics'] = diacritics
                rcParams['vowels'] = vowels
                rcParams['tones'] = tones
                rcParams['_color'] = Model('color')
                rcParams['combiners'] = '\u0361\u035c'
                rcParams['breaks'] = '.-'
                rcParams['stress'] = "ˈˌ'"
                rcParams['merge_vowels'] = True
                rcParams['basic_orthography'] = 'fuzzy'

                # reset basic model to sca
                rcParams['model'] = rcParams['sca']

            elif keywords[key] in ['evolaemp', 'el', 'asjp']:
                diacritics, vowels, tones = load_dvt(path='el')
                rcParams['asjp'] = Model('asjp_el')
                rcParams['sca'] = Model('sca_el')
                rcParams['dolgo'] = Model('dolgo_el')
                rcParams['art'] = Model('art_el')
                rcParams['jaeger'] = Model('jaeger_el')
                rcParams['diacritics'] = diacritics
                rcParams['vowels'] = vowels
                rcParams['tones'] = tones
                rcParams['_color'] = Model('color_el')
                rcParams['combiners'] = '\u0361\u035c'
                rcParams['breaks'] = '.-'
                rcParams['stress'] = "ˈˌ'"
                rcParams['merge_vowels'] = False
                rcParams['basic_orthography'] = 'asjp'

                # reset the basic model to the asjp model
                rcParams['model'] = rcParams['asjp']

        if key in alias:
            rcParams[alias[key]] = keywords[key]
        else:
            rcParams[key] = keywords[key]
    log.info("Successfully changed parameters.")
Exemple #2
0
# *-* coding: utf-8 *-*
"""
Module handels all global parameters used in a LingPy session.
"""
from __future__ import print_function, division, unicode_literals

from lingpy._settings import rcParams
from lingpy.data.model import Model, load_dvt

# load diacritics, vowels, tones
diacritics, vowels, tones = load_dvt()

# these are lexstat-specific parameters, all prefixed by "lexstat"
lexstat = dict(lexstat_transform={
    'A': 'C',
    'B': 'C',
    'C': 'C',
    'L': 'c',
    'M': 'c',
    'N': 'c',
    'X': 'V',
    'Y': 'V',
    'Z': 'V',
    'T': 'T',
    '_': '_'
},
               lexstat_runs=1000,
               lexstat_modes=[("global", -2, 0.5), ("local", -1, 0.5)],
               lexstat_rands=1000,
               lexstat_limit=10000,
               lexstat_scoring_method='shuffle',
Exemple #3
0
# *-* coding: utf-8 *-*
"""
Module handels all global parameters used in a LingPy session.
"""
from __future__ import print_function, division, unicode_literals

from lingpy._settings import rcParams
from lingpy.data.model import Model, load_dvt

# load diacritics, vowels, tones
diacritics, vowels, tones = load_dvt()

# these are lexstat-specific parameters, all prefixed by "lexstat"
lexstat = dict(
    lexstat_transform={
        'A': 'C',
        'B': 'C',
        'C': 'C',
        'L': 'c',
        'M': 'c',
        'N': 'c',
        'X': 'V',
        'Y': 'V',
        'Z': 'V',
        'T': 'T',
        '_': '_'
    },
    lexstat_runs=1000,
    lexstat_modes=[("global", -2, 0.5), ("local", -1, 0.5)],
    lexstat_rands=1000,
    lexstat_limit=10000,
Exemple #4
0
def rc(rval=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.
    verbose : bool (default=False)
        Use this keyword in order to switch to verbose output. This will be
        useful when using complex methods, in order to understand what the
        program is actually doing.
    debug : bool (default=False)
        Use this keyword to switch to debug-mode. It will give specific,
        internal output that is much more technical than the output resulting
        from "verbose".

    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 *

    Change basic values. Switch to verbose output, for example:

    >>> rc(verbose=True)
    Successfully changed parameters.
    """
    from lingpy import log

    if rval:
        return rcParams[rval]

    for key in keywords:
        if key == "schema":
            if keywords[key] in ["qlc", 'ipa']:
                diacritics, vowels, tones = load_dvt(path='')
                rcParams['asjp'] = Model('asjp')
                rcParams['sca'] = Model('sca')
                rcParams['dolgo'] = Model('dolgo')
                rcParams['art'] = Model('art')
                rcParams['diacritics'] = diacritics
                rcParams['vowels'] = vowels
                rcParams['tones'] = tones
                rcParams['_color'] = Model('color')
                rcParams['combiners'] = '\u0361\u035c'
                rcParams['breaks'] = '.-'
                rcParams['stress'] = "ˈˌ'"
                rcParams['merge_vowels'] = True
                rcParams['basic_orthography'] = 'fuzzy'

                # reset basic model to sca
                rcParams['model'] = rcParams['sca']

            elif keywords[key] in ['evolaemp', 'el', 'asjp']:
                diacritics, vowels, tones = load_dvt(path='el')
                rcParams['asjp'] = Model('asjp_el')
                rcParams['sca'] = Model('sca_el')
                rcParams['dolgo'] = Model('dolgo_el')
                rcParams['art'] = Model('art_el')
                rcParams['jaeger'] = Model('jaeger_el')
                rcParams['diacritics'] = diacritics
                rcParams['vowels'] = vowels
                rcParams['tones'] = tones
                rcParams['_color'] = Model('color_el')
                rcParams['combiners'] = '\u0361\u035c'
                rcParams['breaks'] = '.-'
                rcParams['stress'] = "ˈˌ'"
                rcParams['merge_vowels'] = False
                rcParams['basic_orthography'] = 'asjp'

                # reset the basic model to the asjp model
                rcParams['model'] = rcParams['asjp']

        if key in alias:
            rcParams[alias[key]] = keywords[key]
        else:
            rcParams[key] = keywords[key]
    log.info("Successfully changed parameters.")
Exemple #5
0
def rc(rval=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.

    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'

    """
    from lingpy import log

    if rval:
        return rcParams[rval]

    for key in keywords:
        if key == "schema":
            if keywords[key] in ["qlc", 'ipa']:
                diacritics, vowels, tones = load_dvt(path='')
                rcParams['asjp'] = Model('asjp')
                rcParams['sca'] = Model('sca')
                rcParams['dolgo'] = Model('dolgo')
                rcParams['art'] = Model('art')
                rcParams['diacritics'] = diacritics
                rcParams['vowels'] = vowels
                rcParams['tones'] = tones
                rcParams['_color'] = Model('color')
                rcParams['combiners'] = '\u0361\u035c'
                rcParams['breaks'] = '.-'
                rcParams['stress'] = "ˈˌ'"
                rcParams['merge_vowels'] = True
                rcParams['basic_orthography'] = 'fuzzy'

                # reset basic model to sca
                rcParams['model'] = rcParams['sca']

            elif keywords[key] in ['evolaemp', 'el', 'asjp']:
                diacritics, vowels, tones = load_dvt(path='el')
                rcParams['asjp'] = Model('asjp_el')
                rcParams['sca'] = Model('sca_el')
                rcParams['dolgo'] = Model('dolgo_el')
                rcParams['art'] = Model('art_el')
                rcParams['jaeger'] = Model('jaeger_el')
                rcParams['diacritics'] = diacritics
                rcParams['vowels'] = vowels
                rcParams['tones'] = tones
                rcParams['_color'] = Model('color_el')
                rcParams['combiners'] = '\u0361\u035c'
                rcParams['breaks'] = '.-'
                rcParams['stress'] = "ˈˌ'"
                rcParams['merge_vowels'] = False
                rcParams['basic_orthography'] = 'asjp'

                # reset the basic model to the asjp model
                rcParams['model'] = rcParams['asjp']

        if key in alias:
            rcParams[alias[key]] = keywords[key]
        else:
            rcParams[key] = keywords[key]
    log.info("Successfully changed parameters.")