emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/elisa 9ad7827337 70/98: Fix semantic split with single


From: ELPA Syncer
Subject: [elpa] externals/elisa 9ad7827337 70/98: Fix semantic split with single chunk
Date: Wed, 17 Jul 2024 18:58:05 -0400 (EDT)

branch: externals/elisa
commit 9ad7827337cb9e3dc326c47e4882f45ea5231da7
Author: Sergey Kostyaev <kostyaev.sergey2@wb.ru>
Commit: Sergey Kostyaev <kostyaev.sergey2@wb.ru>

    Fix semantic split with single chunk
---
 elisa.el | 61 +++++++++++++++++++++++++++++++------------------------------
 1 file changed, 31 insertions(+), 30 deletions(-)

diff --git a/elisa.el b/elisa.el
index 00f93a465c..72fe45f604 100644
--- a/elisa.el
+++ b/elisa.el
@@ -589,36 +589,37 @@ ARGS contains keys for fine control.
 :threshold-amount K -- K is a breakpoint threshold amount.
 
 than T, it will be packed into single semantic chunk."
-  (when-let* ((func (or (plist-get args :function) 
elisa-semantic-split-function))
-             (k (or (plist-get args :threshold-amount) 
elisa-breakpoint-threshold-amount))
-             (chunks (funcall func))
-             (embeddings (cl-remove-if
-                          #'not
-                          (mapcar (lambda (s)
-                                    (when (length> (string-trim s) 0)
-                                      (llm-embedding elisa-embeddings-provider 
s)))
-                                  chunks)))
-             (distances (elisa--distances embeddings))
-             (threshold (elisa-calculate-threshold k distances))
-             (current (car chunks))
-             (tail (cdr chunks)))
-    (let* ((result nil))
-      (mapc
-       (lambda (el)
-        (if (<= el threshold)
-            (setq current (concat current (car tail)))
-          (push current result)
-          (setq current (car tail)))
-        (setq tail (cdr tail)))
-       distances)
-      (push current result)
-      (cl-remove-if
-       #'string-empty-p
-       (mapcar (lambda (s)
-                (if s
-                    (string-trim s)
-                  ""))
-              (nreverse result))))))
+  (if-let* ((func (or (plist-get args :function) 
elisa-semantic-split-function))
+           (k (or (plist-get args :threshold-amount) 
elisa-breakpoint-threshold-amount))
+           (chunks (funcall func))
+           (embeddings (cl-remove-if
+                        #'not
+                        (mapcar (lambda (s)
+                                  (when (length> (string-trim s) 0)
+                                    (llm-embedding elisa-embeddings-provider 
s)))
+                                chunks)))
+           (distances (elisa--distances embeddings))
+           (threshold (elisa-calculate-threshold k distances))
+           (current (car chunks))
+           (tail (cdr chunks)))
+      (let* ((result nil))
+       (mapc
+        (lambda (el)
+          (if (<= el threshold)
+              (setq current (concat current (car tail)))
+            (push current result)
+            (setq current (car tail)))
+          (setq tail (cdr tail)))
+        distances)
+       (push current result)
+       (cl-remove-if
+        #'string-empty-p
+        (mapcar (lambda (s)
+                  (if s
+                      (string-trim s)
+                    ""))
+                (nreverse result))))
+    (list (buffer-substring-no-properties (point-min) (point-max)))))
 
 (defun elisa--gitignore-to-elisp-regexp (pattern)
   "Convert a .gitignore PATTERN to an Emacs Lisp regexp."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]