changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/lib/nlp/tests.lisp

changeset 698: 96958d3eb5b0
parent: 16bb4464adcb
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 (defpackage :nlp/tests
2  (:use :cl :std :rt :nlp))
3 
4 (in-package :nlp/tests)
5 
6 (defsuite :nlp)
7 (in-suite :nlp)
8 
9 (defvar *test-docs* (make-instance 'document-collection))
10 
11 (deftest tokenize ()
12  (is (= 3 (length (word-tokenize "foo bar baz"))))
13  (is (= 2 (length (sentence-tokenize "This is the first second. Now the second")))))
14 
15 (deftest sections ()
16  (is (typep (extract-sections "Testing 1 2 3") 'document-collection)))
17 
18 (deftest porter-stem ()
19  (is (string= (stem "hacking") "hack")))
20 
21 (deftest docs ()
22  (let ((doc (make-instance 'document :string-contents "test test test")))
23  (is (= 3 (nlp/doc:term-count
24  doc "test")))
25  (is (= 1.0 (nlp/doc:term-frequency
26  doc "test")))))
27 
28 (deftest textrank ()
29  (is
30  (typep (summarize-text "This is a test which will be summarized by the 'SUMMARIZE-TEXT' function. Yada yada. Test 1 2 3.")
31  'list)))