From e2fe5882ad434b433bfba4529abdd2666d9c3d99 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Thu, 14 Jan 2021 01:14:27 +0800 Subject: A temporary bug fix There are more bugs unfortunately. --- suffix tree/LCS.el | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'suffix tree/LCS.el') diff --git a/suffix tree/LCS.el b/suffix tree/LCS.el index 989c25e..41bcec0 100644 --- a/suffix tree/LCS.el +++ b/suffix tree/LCS.el @@ -24,9 +24,15 @@ ;;;###autoload (defun lcs-edge-length (node str-lens) "Return the length of the edge going into NODE. -Unlike `gst-edge-length', this does not need to know about POSITION -and NUM, since it is assumed that the tree is already built -before calling this function." + +Unlike `gst-edge-length', this does not need to know about +POSITION and NUM, since it is assumed that the tree is already +built before calling this function. + +If the node is a leaf, its end is denoted by infty, and we +wouldn't know the exact length if we don't know the length of the +string it corresponds to, so we need the argument STR-LENS to +provide that information." (let ((start (car (cdr node))) (end (cond ((eq (car (cdr (cdr node))) 'infty) @@ -47,7 +53,11 @@ before calling this function." ;;;###autoload (defun lcs-get-env (node str-lens) - "Return the information we want to keep on the stack." + "Return the information we want to keep from NODE on the stack. + +STR-LENS is here to provide information about the ending index of +NODE if it is a lead. See the documentation for `lcs-edge-length' +for more." (let ((num (car node)) (start (car (cdr node))) (end (cond @@ -93,7 +103,10 @@ before calling this function." ;;;###autoload (defun lcs-pretty-stack (stack) - "Prettify a stack." + "Prettify STACK. + +Apply `lcs-pretty-stack-element' to each element, and concatenate +them in a clean way." (concat "[ " (mapconcat #'lcs-pretty-stack-element @@ -146,7 +159,7 @@ Of course, without STRS, we don't even know what our strings are." "Return the longest common substring of a list STRS of strings. If JUST-LENGTH is non-nil, then this only returns the length of the -longest common substring. Otherwise, it returns the length as well as the +longest common substring. Otherwise, it returns the length as well as the longest common substring itself." (let* ((strs (mapcar (lambda (str) (vconcat str (list -1))) @@ -223,9 +236,9 @@ longest common substring itself." current-children) temp) ;; An alternative - ;; (apply #'logior - ;; (mapcar (lambda (num) - ;; (gethash num bits-table)) + ;; (apply #'logior + ;; (mapcar (lambda (num) + ;; (gethash num bits-table)) ;; (hash-table-values current-children))) )) (setq temp nil) -- cgit v1.2.3-18-g5258