module Matrix: sig
.. end
Converting raw text to matrix (list of list) of strings (words) and vice-versa.
type
t = string list list
A (word structured) text is a matrix of strings.
type
filter = t -> t
A text matrix filter is a function from and to string list lists.
val of_string : ?squeeze:bool -> ?d:char -> string -> string list list
Convert a raw text in a matrix of words.
By default the word delimiter is the char
d=' '
and
squeeze=true
.
Example:
# Text.Matrix.of_string (Unix.shell "ls -i -w1 /etc/ssh/") ;;
: string list list =
[["98624"; "moduli"]; ["98625"; "ssh_config"]; ["98626"; "sshd_config"];
["274747"; "ssh_host_dsa_key"]; ["274748"; "ssh_host_dsa_key.pub"];
["274712"; "ssh_host_key"]; ["274713"; "ssh_host_key.pub"];
["274750"; "ssh_host_rsa_key"]; ["274751"; "ssh_host_rsa_key.pub"]]
val to_string : ?d:string -> StringExtra.Extra.line list list -> StringExtra.Extra.line
Convert a matrix of words in a raw text.
By default the word delimiter is the string
d=" "
.
# let m = Text.Matrix.of_string (Unix.shell "ls -l /etc/ssh/")
in print_string (Text.Matrix.to_string m);;
total 164
-rw------- 1 root root 132839 2006-11-11 00:12 moduli
-rw-r--r-- 1 root root 2517 2006-11-11 00:12 ssh_config
-rw-r----- 1 root root 3474 2006-11-11 00:12 sshd_config
-rw------- 1 root root 668 2006-11-20 12:50 ssh_host_dsa_key
-rw-r--r-- 1 root root 600 2006-11-20 12:50 ssh_host_dsa_key.pub
-rw------- 1 root root 525 2006-11-20 12:50 ssh_host_key
-rw-r--r-- 1 root root 329 2006-11-20 12:50 ssh_host_key.pub
-rw------- 1 root root 887 2006-11-20 12:50 ssh_host_rsa_key
-rw-r--r-- 1 root root 220 2006-11-20 12:50 ssh_host_rsa_key.pub
: unit = ()