Author: ksprotte Date: Sun Jul 1 15:51:08 2007 New Revision: 8
Modified: trunk/src/morphologie.lisp Log: added doc
Modified: trunk/src/morphologie.lisp ============================================================================== --- trunk/src/morphologie.lisp (original) +++ trunk/src/morphologie.lisp Sun Jul 1 15:51:08 2007 @@ -107,6 +107,7 @@
(define-ompw primo-passo ((lista nil) (n 1)) + "prende n elementi di una lista" :non-generic t (let ((f nil)) (dotimes (x n) (push (nth x lista) f)) @@ -114,6 +115,7 @@
(define-ompw scom ((lista1 nil) &optional (n nil)) + "Scompone la lista1 in funzione delle lunghezze indicate nella n" :non-generic t (let ((ris nil)) (cond @@ -133,6 +135,8 @@
(define-ompw pattern-ridond ((lista nil) &optional (n nil)) + "Restituisce tutte le ripetizioni di tutti i sotto-pattern in + cui può essere scomposta la sequenza in lista." :non-generic t (let ((ris nil) (x (scom lista n)) y) (loop :while x :do @@ -141,6 +145,7 @@
(define-ompw ptrn-recogn ((list (1 2 3 1 2 3 1 2 1 2))) + "restituisce..." :non-generic t (let* ((ris nil) (ros nil) @@ -154,11 +159,15 @@
(define-ompw rispero ((lista (1 2)) (n 0)) + "E' come spero solo che divide la + lista in base al valore messo in n" :non-generic t (scom lista n))
(define-ompw risperiamo ((lista nil) (n 0)) + "E' molto simile a speriamo : trova i pattern di n lunghezza + all'interno della lista" :non-generic t (let ((ris nil)) (dolist (x (rispero lista n) (nreverse ris)) @@ -166,6 +175,9 @@
(define-ompw ptrn-ridond-ctrl-prov ((lista nil) (n nil)) + "Restituisce tutti i sotto-pattern che compaiono almeno + due volte (ridondanza) e le cui length sono decise da + noi in N." :non-generic t (let ((ris nil) (x (risperiamo lista n)) y) (loop :while x :do (if (find (setf y (pop x)) x :test 'equal) (push y ris))) @@ -223,6 +235,10 @@
(define-ompw ptrn-reson ((list (a b c a b c b b b b a a)) (windw 5) &optional (step nil) (set nil)) + "Avance dans la sequence <list> avec avec une taille de fenetre <windw> +et un pas d'avancement (optionnel) <step> . +Renvoie pour chaque fenêtre le nombre d'occurrences d'un élément. +L'entrée optionnelle <set> specifie les segments recherches dans <list>." :non-generic t (count-ptrn-win list windw step set))
@@ -260,6 +276,9 @@ result-not-sorted)))))))
(define-ompw ptrn-smooth ((list (a b c d b b))) + "It returns the list <list> without local repetitions. + For example : list equal to (a a b c a b b c d c c) + it reurns (a b c a b c d c))" :non-generic t (let ((l nil)) (loop for x from 0 to (1- (length list)) do @@ -315,6 +334,21 @@
(define-ompw find-permut ((seq nil) (output "permut") &optional (length nil) (ptrn nil)) + "Renvoie les permutations de deux elements de la sequence <seq>. + deux modes : <permutation> renvoie les segments d'elements permutes, <position> renvoie + les segments d'elements et leurs positions dans la sequence. +optionnels : +- <length> : longueur des segments. 2 par defaut. +- <ptrn> : segment dont les permutations sont recherchés. +tous par défaut. desactive <length>. + +Returns all permutations of two elements in <seq> with +their respective positions in seq. +Optional inputs : +<length>, length or list of lengths of segments to be permuted +(if 'nil, length = 2); +<ptrn> : pattern of which permutations are looking for. + If not empty (nil), desactivates <length>." :non-generic t :menu (output ("pos" "positions") ("permut" "permutations")) (assert (listp ptrn)) @@ -330,6 +364,16 @@ (define-ompw ldl-distance ((l-seq ((a b c) (a b b) (a b c))) (change 1.0) (ins/sup 1.0) (inex 0.0) (scale "abs") (result "short")) + "Estimates the distances between lists of symbols. +INPUT +l-seq : list of lists of symbols; +change : cost when changing a symbol; +ins/sup : cost when inserting or deleting a symbol; +inex : added cost when the edition is made on a symbol not actual in the other list; +scale : scaling of the distance (ABSOLUTE / RELATIVE), default : ABSOLUTE; +result : output mode - list of list (short), easy-to-read mode (extended) or save to file (save). +OUTPUT +A matrix of distances" :non-generic t :menu (scale ("rel" "relative") ("abs" "absolute")) :menu (result ("short" "short") ("ext" "extended") ("save" "save")) @@ -565,6 +609,7 @@
(define-ompw concatstrings ((lofstrings nil)) + "Concantenates list of strings into one string." :non-generic t (let ((concatenated (make-string (apply #'+ (mapcar #'length lofstrings)) :initial-element @@ -581,6 +626,7 @@ (string-to-symbol (mc-to-name midiseq approx)))
(define-ompw midiseq->alpha ((midiseq nil) (approx 0)) + "Converts midicents values into symboles." :non-generic t (midiseq->alpha1 midiseq approx))
@@ -659,6 +705,24 @@
(define-ompw structure-1 ((seq nil) &optional (alpha? "alpha") (smooth? "yes") (result "extend") (levels 1) (smth2? "no")) + "Donne toutes les structures possibles d'une séquence de nombres ou de symboles +selon une segmentation contrastive, et ce de manière récursive. + +INPUT +seq : séquence de symboles ou nombres (liste); +alpha? : résultat en mode alphabétique ou numérique (YES NO), optional; +lisse? : optional <yes> : suppression des elements repetes immediatements dans seq . +result : menu déroulant, quatre possibilités : + short = liste des critères de segmentation et leur segmentation respective; + exten = analyse détaillée; + + save = analyse détaillée écrite en un fichier texte. + +OUTPUT +en mode short, pour le traitement de l'analyse, liste de liste selon le format : + +((critères de segmentation) +(forme selon critère)...)" :non-generic t :menu (alpha? ("alpha" "alpha") ("num" "num")) :menu (smooth? ("yes" "yes") ("no" "no")) @@ -997,6 +1061,12 @@
(define-ompw rma-1 ((seq nil) (smoo1 1) (levels 1) &optional (smoo2 0) (alpha? 1) (result 0)) + " +même fonction que structure-1, mais récursive : +s'applique aussi aux structures trouvées, avec <levels> + comme niveau de recursion. +memes caractéristiques que structure-1 +Recursive Mark Analysis. Returns only found structures." :non-generic t (when (< levels 1) (format t "Recursion error : levels must be >= 1 !~%") @@ -1149,6 +1219,7 @@ (setf (car lcs) (list (make-string 1 :initial-element (car lcs)) (cadr lcs))))
(define-ompw rma-1-scores ((structures nil)) + "Returns the score of each structure, level by level of the rma-1 analysis." :non-generic t (let ((types (mapcar 'test-eq-l structures)) (scores nil) (s nil)) (setf (car types) (mapcar #'remove-duplicates (car types))) @@ -1300,6 +1371,20 @@
(define-ompw ins-ptrn ((seq (1 2 3 4 1 2 5 3 4)) (ptrn ((1 2 3 4) (1 2))) &optional (prof 1) (set nil) (marg 0)) + "Finds the pattern(s) <ptrn> in list seq with or without +up to a number prof inserted items; +Return each pattern and its start positions. +Doesn't permit cross-overing of a pattern on itself. +Optional-1: + A set (list) of elements which can be inserted in the patterns. + If set empty, no constraint. + When seq is a list of values, permits a list of 'domains' + defined by a list of min and max values. +Optional-2: + If seq is a list of values, definition of a margin around the values, + more and less the value specified in set (+-); + only more the value in set (+); + or only less the value in set (-)." :non-generic t :menu (marg (3 "+-") (1 " + ") (2 " - ")) (let ((val 0) (p 0) (pos nil) (long 0) (r nil) (set2 0)) @@ -1379,6 +1464,27 @@
(define-ompw structure-2 ((seq nil) (n-max 10) (alpha? 1) (result 0) &optional (length nil) (seuil 10)) + "INPUT +seq = sequence of nums or symbols; +n-max = maximum number of patterns accepted in structure of seq; +alpha = alpha or num representation of the resulting structures; +result = type of output of analysis + extended -> detailed analysis; + struct -> returns score, structure and corresponding patterns as list of lists; + pos -> returns only the positions of the patterns; + mat -> return the list of pattern and the associated binary matrix; + p-score -> returns the score of structure completion for each structure; + save -> save all analysis into a file. +&OPTIONAL +length = value or list of minimum and maximum values for length of patterns. + If nil, lengths of patterns are set up to the half-lenght of the sequence; +seuil = minimum completion percentage of the structure taken in account; + +OUTPUT +Returns an analysis of seq according to the repetition criterium to segment. + +Note : if out-of memory, try successives computations with a smaller value +of n-max (max number of patterns combined in each structure" :non-generic t :menu (alpha? (1 "alpha") (0 "num")) :menu (result (0 "extended") (5 "struct") (1 "pos") (2 "mat") (3 "p-score") @@ -1525,6 +1631,7 @@ run-time))
(define-ompw aver-class ((seq nil) (class nil)) + "Return the average center of classes (one dimension)." :non-generic t (let ((r nil) (rt nil) (length (remove-duplicates class))) (dotimes (n (length length)) @@ -1541,6 +1648,8 @@
(define-ompw quantize-1 ((seq nil) (class nil)) + "Returns the quantization of elements in list according to the classification +defined in class (one dimension)" :non-generic t (let ((r nil) (rt nil) (length (remove-duplicates class))) (dotimes (n (length length)) @@ -1559,6 +1668,7 @@
(define-ompw l-matrix ((list nil)) + "Makes a matrix from a list of lists." :non-generic t (let ((mat (if (not (listp (car list))) (make-array (list (length list) 2)) @@ -1682,6 +1792,10 @@ (setf (aref g 0 i) (float (/ sum m))))))
(define-ompw matrix-center ((matrix nil)) + "Donne les coordonnées du centre de gravité d'une matrice + des coordonnées de points en n-dimensions (utiliser l-matrix +pour convertir une liste de coordonnées de points en matrice). +" :non-generic t (let (sum g @@ -1722,6 +1836,8 @@ (multiply-two-matrices (transpose matrix) matrix)))
(define-ompw dist-euclidienne ((matrix nil)) + "input = matrix of coordinates of points in a d-space; + output = upper-matrix of euclidian distances." :non-generic t (let (k temp @@ -1739,6 +1855,8 @@
(define-ompw euclidian-d ((matrix nil)) + "input = matrix of coordinates of points in a d-space; + output = upper-matrix of euclidian distances." (let (k temp mat-dist @@ -1807,6 +1925,10 @@ (dotimes (d *n*) (setf (aref centres b d) (aref tc 0 d))))))
(define-ompw class-center ((matrix nil) (classes nil)) + "input = matrix of points in d-dimensions + liste of classes founded for each point (line in matrix); + Classes must be in numerical representation. + output = matrix of classes centers." :non-generic t (let (nuage point @@ -1910,6 +2032,8 @@
(define-ompw meta-class1 ((matrix nil) (n 2) (iter 1) &optional alpha? centers verbose) + "Does n iterations of class-1 algorithm. +The classes designation is normalized." :non-generic t :menu (alpha? ("alpha" "alpha") ("num" "num")) :menu (verbose ("no" "no") ("yes" "yes")) @@ -1945,6 +2069,10 @@ (t (push (- (1- (length set)) (pos (nth c classes) set)) r))))))
(define-ompw norm-class ((classes nil)) + "reordonne les classes de class-1. +L'ordre de la classe étant le numéro de sa première occurence dans la liste des classes. +Se connecte typiquement après class-1 ou meta-class1. +IN : string or list (of symbols or lists or strings)." :non-generic t (if (or (stringp classes) (not (listp (car classes)))) (normalize-class classes) @@ -1977,6 +2105,7 @@ (push (aref mat i j) c))))))
(define-ompw p-class ((clusters nil)) + "Give the probability for each to be element of class #" :non-generic t (prob-class clusters))
@@ -1995,6 +2124,7 @@ (if (= val? 0) (push cl r) (push (list cl p) r)))))
(define-ompw res-class ((proba nil) (val? 0)) + "Affects each point i of the matrix prob to the class (j) with higher probability." :non-generic t :menu (val? (0 "classes") (1 "proba")) (resume-class proba val?)) @@ -2008,6 +2138,7 @@ (mapcar #'(lambda (n) (nth n clusters)) (pos2 e entropies)))))
(define-ompw e-test ((clusters nil) (test "min") &optional (out "clust")) + "Returns the clusters which have the minimum or maximum entropy." :non-generic t :menu (test ("min" "min") ("max" "max")) :menu (out ("clust" "clust") ("nth" "nth")) @@ -2219,6 +2350,25 @@ (6000 4000 5600 4700 4100 5900 6400 7800 7400 6300 6800 8300 5900)) (result 1) &optional (d-cte nil)) + "analyse une sequence en detectant trois formes primitives: +minima: element précédé et suivi par un élément +de valeur plus grande. +maxima: element précédé et suivi par un élément +de valeur plus petite +flex: element précédé et suivi par un élément +de valeur égale + +ex : (10 8 8 6 6 5 2 2 2 1) +OM->(pure-flex- (8 2) (6 2) (2 3)) +le premier chiffre indique la valeur répétée + et le deuxième terme de la liste indique son nombre d'occurrences. +la deuxième entrée est un menu <which> qui permet de selectionner + les informations: +prim: succession des primitives +prof: succession des primitives et profondeur en nombre d'éléments de +chaque primitive +vals: idem que prof + valeur correspondant à chaque primitive +every: idem que vals + position de chaque primitive" :non-generic t :menu (result (1 "prim") (2 "prof") (3 "vals") (4 "every")) (let ((primitives (find-primitives seq))) @@ -2242,6 +2392,9 @@
(define-ompw 1-0-1-reconst ((list nil)) + "fonction dx->x d'OM : +renvoie une liste de points depuis une liste + d'intervalles . commence à zero" :non-generic t (OM::dx->x 0 list))
@@ -2266,6 +2419,12 @@
(define-ompw reconstitute ((list nil) (which 1) (start 0)) + "reconstitue le profil original. +avec optionnels: +prim : n'utilise que l'analyse primitive +prof : utilise l'analyse primitive et la profondeur. +vals : utilise l'analyse primitive, la profondeur et la valeur. +every : utilise l'analyse primitive, la profondeur, la valeur et la position " :non-generic t :menu (which (1 "prim") (2 "prof") (3 "vals") (4 "every")) (case which @@ -2297,6 +2456,8 @@
(define-ompw reconst-prim+prof ((list nil)) + "Ricostruisce la lista usando min, max, flex + più eventualmente l'indice di profondità" :non-generic t (let ((ris nil) (start 0)) (dolist