~tpt/string-search

OCaml module for efficient string searching from a provided source
Consolidate license text
61f90067 — djosifovic 4 years ago
Initial commit.

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~tpt/string-search
read/write
git@git.sr.ht:~tpt/string-search

You can also use your local clone with git send-email.

#String search module

An OCaml module for efficient string searching from a provided source. Idea behind is to supply the string source as an one line CSV list. The source will be indexed based on first characters of the words which will be used for searching.

Should not be used for anything serious, I am learning the language.

#Usage

In order to use the example script string source must be a single line CSV file named source.txt and should be located next to the script.

First compile the sources and start the REPL.

# compile
.\search_compile.ps1

# start the REPL
ocaml

In REPL:

#use "example.ml";;

At that point source will be imported as val source and indexes will be created as val index. They can be used for searching:

let result = find "any" source index;;

val result : string list =
  ["anywhere"; "anyway"; "anything"; "anyone"; "anybody"]

To import and index another source:

let new_source = to_source (read_file "new_source.txt");;

let new_source_index = index new_source;;

#License

Copyright (C) 2023. Dejan Josifović, The Paranoid Times

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.