Previous Up Next

class Lexique



module lexique

This class is used for all of the computations of partitions, partitionings and HMM analysis.

A lexique is a set of descriptors. The prediction functions, used for all the computations, are defined by the descriptors.

Optionaly, some values can be put for the transitions between the descriptors: these values are used for HMM computations.

Construction

__init__
Optional keywords:
fic=f
builds from filename f, using read_nf;
fprop=f
builds from filename f of Lproportion, using read_Lprop;
str=s
builds from string s, using read_str;
alpha=a
uses the letters of string a, in use with option str (see input);


read_nf
builds from a filename and optionaly a string of letters (see input);
read_str
builds from a string and optionaly another string of letters (see input).
read_prop
builds from a Proportion, using loglex. For efficiency considerations, the proportions priors and posteriors are translated differently (see descriptors):

read_Lprop
builds from a Lproportion, each Proportion being translated as in read_prop, and the transitions between descriptors are valued by the logarithms of the transitions proportions.

Handling

is_empty
returns True if there is no descriptor, False otherwise;
__len__
returns the number of descriptors;
ls_num
returns the list of the numbers of the descriptors;
met_au_net
removes repetitions in patterns of descriptors (like ACAC cleaned in AC) and repetitions of descriptors (like A A cleaned in A);
__iter__
iterates over the descriptors, using for d in lx;
__delitem__
removes the descriptor of a given number;
__setitem__
adds a descriptor given its number, or a descriptor pattern given a tuple. Given numbers must not have been previously used.

For example:
>>> import lexique
>>> l=lexique.Lexique(str="1:A  2,3:BC")
>>> print l
3,2:CB  1:A     

>>> l[2]
'2:B'
>>> l[4]='D'
>>> print l
4:D     3,2:CB  1:A     

>>> l[3,5]='EF'
Bad descriptor number  3  already used
>>> l[6,5]='EF'
>>> print l
5,6:FE  4:D     3,2:CB  1:A     

>>> del l[4]
>>> l[4]='F'
>>> print l
4:F     5,6:FE  3,2:CB  1:A     

>>> del l[2]
>>> print l
4:F     5,6:FE  3:C     1:A     



prediction
computes the best prediction on a data, without using between-descriptors transitions;

Optional keywords:
deb=d
sets the first position of the segment on which the prediction is computed (default: 0);
fin=f
sets the last position of the segment on which the prediction is computed (default: last position-1);

If deb>fin, it returns 0.

ls_evalue
returns the dictionnary of tuple of (the pattern of) numbers of descriptors, prediction of this (pattern of) descriptor on the data, for all descriptors, on a given data.

Optional keywords:
deb=d
sets the first position of the segment on which the predictions are computed (default: 0);
fin=f
sets the last position of the segment on which the predictions are computed (default: last position -1 );

If deb>fin, it returns 0.

windows
computes the list of the best predictions on the data in a sliding window of a given size and with steps of a given length;

Input-Output

Here are the syntax and the computation methods of descriptors and Lexique.


Previous Up Next