Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
23
Task/Inverted-index/EchoLisp/inverted-index-1.echolisp
Normal file
23
Task/Inverted-index/EchoLisp/inverted-index-1.echolisp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
;; set of input files
|
||||
(define FILES {T0.txt T1.txt T2.txt})
|
||||
;; store name for permanent inverted index
|
||||
(define INVERT "INVERTED-INDEX")
|
||||
|
||||
;; get text for each file, and call (action filename text)
|
||||
(define (map-files action files)
|
||||
(for ((file files))
|
||||
(file->string action file)))
|
||||
|
||||
;; create store
|
||||
(local-make-store INVERT)
|
||||
|
||||
; invert-word : word -> set of files
|
||||
(define (invert-word word file store)
|
||||
(local-put-value word
|
||||
(make-set (cons file (local-get-value word store))) store))
|
||||
|
||||
; parse file text and invert each word
|
||||
(define (invert-text file text)
|
||||
(writeln 'Inverting file text)
|
||||
(let ((text (text-parse text)))
|
||||
(for ((word text)) (invert-word (string-downcase word) file INVERT))))
|
||||
11
Task/Inverted-index/EchoLisp/inverted-index-2.echolisp
Normal file
11
Task/Inverted-index/EchoLisp/inverted-index-2.echolisp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
;; usage : (inverted-search w1 w2 ..)
|
||||
(define-syntax-rule (inverted-search w ...)
|
||||
(and-get-invert (quote w )))
|
||||
|
||||
;; intersects all sets referenced by words
|
||||
;; returns the intersection
|
||||
(define (and-get-invert words)
|
||||
(foldl
|
||||
(lambda(word res)
|
||||
(set-intersect res (local-get-value word INVERT)))
|
||||
FILES words))
|
||||
9
Task/Inverted-index/EchoLisp/inverted-index-3.echolisp
Normal file
9
Task/Inverted-index/EchoLisp/inverted-index-3.echolisp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(map-files invert-text FILES)
|
||||
(inverted-search is it)
|
||||
[0]→ { T0.txt T1.txt T2.txt }
|
||||
(inverted-search is banana)
|
||||
[1]→ { T2.txt }
|
||||
(inverted-search is what)
|
||||
[2]→ { T0.txt T1.txt }
|
||||
(inverted-search boule)
|
||||
[3]→ null
|
||||
Loading…
Add table
Add a link
Reference in a new issue