Commit 9c590695 authored by Gérard Huet's avatar Gérard Huet

Minor cleanups

parent 15455ae9
...@@ -34,37 +34,38 @@ VPATH=$(ZEN) ...@@ -34,37 +34,38 @@ VPATH=$(ZEN)
# CORE package - utilities, transducers, sanskrit and french lexers, dico spec # CORE package - utilities, transducers, sanskrit and french lexers, dico spec
CORE=$(DISTR_CORE) paths.ml CORE=$(DISTR_CORE) paths.ml
DISTR_CORE = control.ml version.ml date.ml canon.ml transduction.ml \ DISTR_CORE = control.ml version.ml date.ml canon.ml transduction.ml \
encode.ml order.ml padapatha.ml sanskrit.mli \ encode.ml order.ml padapatha.ml sanskrit.mli \
sanskrit.ml skt_lexer.ml test_stamp.ml dir.mli dir.ml sanskrit.ml skt_lexer.ml test_stamp.ml dir.mli dir.ml
# GRAM package - phonetics, morphology, segmentation and tagging engines # GRAM package - phonetics, morphology, segmentation and tagging engines
GRAM=index.ml phonetics.ml int_sandhi.ml skt_morph.mli morphology.mli naming.ml \ GRAM = index.ml phonetics.ml int_sandhi.ml skt_morph.mli morphology.mli \
inflected.mli inflected.ml sandhi.ml sandhier.ml pada.ml nouns.mli nouns.ml \ naming.ml inflected.mli inflected.ml sandhi.ml sandhier.ml pada.ml \
verbs.mli verbs.ml parts.ml conj_infos.mli morpho_string.ml morpho.ml \ nouns.mli nouns.ml verbs.mli verbs.ml parts.ml conj_infos.mli \
declension.ml conjugation.ml indexer.ml indexerd.ml phases.ml lemmatizer.ml \ morpho_string.ml morpho.ml declension.ml conjugation.ml indexer.ml \
auto.mli load_transducers.ml dispatcher.mli dispatcher.ml segmenter.ml \ indexerd.ml phases.ml lemmatizer.ml auto.mli load_transducers.ml \
load_morphs.ml lexer.mli lexer.ml rank.ml scl_parser.ml \ dispatcher.mli dispatcher.ml segmenter.ml load_morphs.ml lexer.mli \
reader.ml parser.ml constraints.mli constraints.ml multilingual.ml \ lexer.ml rank.ml scl_parser.ml reader.ml parser.ml constraints.mli \
paraphrase.mli paraphrase.ml bank_lexer.ml regression.ml \ constraints.ml multilingual.ml paraphrase.mli paraphrase.ml \
checkpoints.ml graph_segmenter.ml automaton.ml interface.mli interface.ml \ bank_lexer.ml regression.ml checkpoints.ml graph_segmenter.ml \
user_aid.ml reset_caches.ml params.mli params.ml automaton.ml interface.mli interface.ml user_aid.ml reset_caches.ml \
params.mli params.ml
# WEB package - HTML, HTTP, CGI utilities for Web interface # WEB package - HTML, HTTP, CGI utilities for Web interface
WEB=html.ml web.ml css.ml cgi.ml morpho_html.ml chapters.ml morpho_scl.ml \ WEB = html.ml web.ml css.ml cgi.ml morpho_html.ml chapters.ml morpho_scl.ml \
mk_index_page.ml mk_grammar_page.ml mk_reader_page.ml mk_sandhi_page.ml \ mk_index_page.ml mk_grammar_page.ml mk_reader_page.ml mk_sandhi_page.ml \
mk_corpus_page.ml mk_corpus_page.ml
# CORPUS package - corpus manager # CORPUS package - corpus manager
CORPUS = corpus.mli corpus.ml web_corpus.mli web_corpus.ml \ CORPUS = corpus.mli corpus.ml web_corpus.mli web_corpus.ml \
corpus_manager.mli corpus_manager.ml corpus_manager_cgi.ml \ corpus_manager.mli corpus_manager.ml corpus_manager_cgi.ml \
save_corpus_params.mli save_corpus_params.ml save_corpus_cgi.ml \ save_corpus_params.mli save_corpus_params.ml save_corpus_cgi.ml \
mkdir_corpus_params.mli mkdir_corpus_params.ml \ mkdir_corpus_params.mli mkdir_corpus_params.ml \
mkdir_corpus_cgi.ml mk_corpus.ml mkdir_corpus_cgi.ml mk_corpus.ml
# extra file SCLpaths.ml for SCL interfacing - not distributed. # extra file SCLpaths.ml for SCL interfacing - not distributed.
# TREE package - tree bank manager and syntax analyser - legacy # TREE package - tree bank manager and syntax analyser - legacy
TREE=parse_tree.ml parse_apte.ml stemmer.ml tag_tree.ml tag_apte.ml TREE = parse_tree.ml parse_apte.ml stemmer.ml tag_tree.ml tag_apte.ml
DEBUG=debug.ml DEBUG=debug.ml
......
...@@ -66,16 +66,16 @@ value decode_url s = ...@@ -66,16 +66,16 @@ value decode_url s =
strip_heading_and_trailing_spaces (copy_decode_in s1 0 0) strip_heading_and_trailing_spaces (copy_decode_in s1 0 0)
else s; else s;
(* ça convertit une chaine venant de l'URL en une a-list; la chaine est (* converts a string coming from the URL into an a-list; the string is
une suite de paires clé=valeur séparées par des ; ou des \& *) a sequence of pairs key=vallue separated by ; or \& *)
value create_env s = value create_env s =
let rec get_assoc beg i = let rec get_assoc beg i =
if i == Bytes.length s then if i == Bytes.length s then
if i == beg then [] else [Bytes.sub s beg (i - beg)] if i == beg then [] else [ Bytes.sub s beg (i - beg) ]
else if s.[i] == ';' || s.[i] == '&' then else if s.[i] == ';' || s.[i] == '&' then
let next_i = succ i in let next_i = succ i in
[Bytes.sub s beg (i - beg) :: get_assoc next_i next_i] [ Bytes.sub s beg (i - beg) :: get_assoc next_i next_i ]
else get_assoc beg (succ i) in else get_assoc beg (succ i) in
let rec separate i s = let rec separate i s =
if i = Bytes.length s then (s, "") if i = Bytes.length s then (s, "")
...@@ -105,18 +105,13 @@ value url_encode s = ...@@ -105,18 +105,13 @@ value url_encode s =
(* Unreserved characters *) (* Unreserved characters *)
[ 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '-' | '.' | '_' | '~' as c -> [ 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '-' | '.' | '_' | '~' as c ->
String.make 1 c String.make 1 c
(* Special case of the space character *) (* Special case of the space character *)
| ' ' -> "+" | ' ' -> "+"
(* Reserved characters *) (* Reserved characters *)
| c -> "%" ^ hexa_str c | c -> "%" ^ hexa_str c
] ] in
in
let char_of_string s = let char_of_string s =
if String.length s = 1 then s.[0] else failwith "char_of_string" if String.length s = 1 then s.[0] else failwith "char_of_string" in
in
let subst s = s |> Str.matched_string |> char_of_string |> url_encode in let subst s = s |> Str.matched_string |> char_of_string |> url_encode in
let any_char = Str.regexp ".\\|\n" in let any_char = Str.regexp ".\\|\n" in
Str.global_substitute any_char subst s Str.global_substitute any_char subst s
...@@ -128,8 +123,7 @@ value url ?query ?fragment path = ...@@ -128,8 +123,7 @@ value url ?query ?fragment path =
let opt_part prefix = fun let opt_part prefix = fun
[ None -> "" [ None -> ""
| Some part -> prefix ^ part | Some part -> prefix ^ part
] ] in
in
let query_part = opt_part "?" query in let query_part = opt_part "?" query in
let fragment_part = opt_part "#" fragment in let fragment_part = opt_part "#" fragment in
path ^ query_part ^ fragment_part path ^ query_part ^ fragment_part
......
...@@ -18,9 +18,9 @@ open Web; ...@@ -18,9 +18,9 @@ open Web;
type gap = { start : int; stop : int } type gap = { start : int; stop : int }
; ;
(* The following functions assume that the given list is sorted in (* The following functions assume that the given list is sorted in
increasing order and represents a subset of positive integers. In increasing order and represents a subset of positive integers.
particular, the lowest bound of a gap is at least [1] and the In particular, the lowest bound of a gap is at least [1] and the
greatest at most [max_int]). We call "group" a list of consecutive greatest at most [max_int]). We call "group" a list of consecutive
integers. *) integers. *)
value max_gap = { start = 1; stop = max_int } value max_gap = { start = 1; stop = max_int }
...@@ -230,8 +230,6 @@ value body dir permission = ...@@ -230,8 +230,6 @@ value body dir permission =
|> pl |> pl
; close_page_with_margin () ; close_page_with_margin ()
} }
| Web_corpus.Sentences sentences -> | Web_corpus.Sentences sentences ->
let groups = group_sentences dir sentences in let groups = group_sentences dir sentences in
do do
...@@ -243,7 +241,6 @@ value body dir permission = ...@@ -243,7 +241,6 @@ value body dir permission =
groups |> List.map (htmlify_group dir permission) |> List.iter pl groups |> List.map (htmlify_group dir permission) |> List.iter pl
; close_page_with_margin () ; close_page_with_margin ()
} }
| Web_corpus.Sections sections -> | Web_corpus.Sections sections ->
do do
{ center_begin |> pl { center_begin |> pl
......
...@@ -55,8 +55,8 @@ module Machine = Dispatch Transducers Lemmas ...@@ -55,8 +55,8 @@ module Machine = Dispatch Transducers Lemmas
; ;
open Machine (* [cache_phase] *) open Machine (* [cache_phase] *)
; ;
(* At this point we have a Finite Eilenberg machine ready to instantiate the (* At this point we have a Finite Eilenberg machine ready to instantiate *)
Eilenberg component of the Segment module. *) (* the Eilenberg component of the Segment module. *)
(* Viccheda sandhi splitting *) (* Viccheda sandhi splitting *)
...@@ -520,15 +520,14 @@ value quit_button corpmode corpdir sentno = ...@@ -520,15 +520,14 @@ value quit_button corpmode corpdir sentno =
match corpmode with match corpmode with
[ Annotator -> "Abort" [ Annotator -> "Abort"
| Reader | Manager -> "Continue reading" | Reader | Manager -> "Continue reading"
] ])
) and permission = Web_corpus.string_of_permission corpmode in
in
center_begin ^ center_begin ^
cgi_begin (Cgi.url corpus_manager_cgi ~fragment:sentno) "" ^ cgi_begin (Cgi.url corpus_manager_cgi ~fragment:sentno) "" ^
hidden_input Params.corpus_dir corpdir ^ hidden_input Params.corpus_dir corpdir ^
hidden_input Params.corpus_permission (Web_corpus.string_of_permission corpmode) ^ hidden_input Params.corpus_permission permission ^
submit_input submit_button_label ^ submit_input submit_button_label ^
cgi_end ^ cgi_end ^
center_end center_end
; ;
(* Main body of graph segmenter cgi *) (* Main body of graph segmenter cgi *)
...@@ -611,7 +610,7 @@ value graph_engine () = do ...@@ -611,7 +610,7 @@ value graph_engine () = do
] in ] in
let word_len = find_word_len 1 chunks in let word_len = find_word_len 1 chunks in
let new_chunk_len = Word.length (Encode.switch_code translit revised) in let new_chunk_len = Word.length (Encode.switch_code translit revised) in
let diff = new_chunk_len - word_len in let diff = new_chunk_len-word_len in
let revised_check = let revised_check =
let revise (k,sec,sel) = let revise (k,sec,sel) =
(if k<word_off then k else k+diff,sec,sel) in (if k<word_off then k else k+diff,sec,sel) in
...@@ -629,25 +628,19 @@ value graph_engine () = do ...@@ -629,25 +628,19 @@ value graph_engine () = do
graph_cgi ^ "?" ^ text ^ graph_cgi ^ "?" ^ text ^
";cpts=" ^ (string_points checkpoints) ^ "\";}\n</script>") ";cpts=" ^ (string_points checkpoints) ^ "\";}\n</script>")
else () else ()
(* Save sentence button *) (* Save sentence button *)
; if corpus_permission = Web_corpus.Annotator then ; if corpus_permission = Web_corpus.Annotator then
(* TODO: use [segment_all] to compute the nb of sols instead of (* TODO: use [segment_all] to compute the nb of sols instead of
passing 0 to [nb_sols]. *) passing 0 to [nb_sols]. *)
save_button query (Num.num_of_int 0) |> pl save_button query (Num.num_of_int 0) |> pl
else else ()
()
; html_break |> pl ; html_break |> pl
(* Quit button: continue reading (reader mode) or quit without (* Quit button: continue reading (reader mode) or quit without
saving (annotator mode). *) saving (annotator mode). *)
; if sentence_no <> "" then ; if sentence_no <> "" then
quit_button corpus_permission quit_button corpus_permission
(Cgi.decode_url corpus_dir) (Cgi.decode_url sentence_no) |> pl (Cgi.decode_url corpus_dir) (Cgi.decode_url sentence_no) |> pl
else else ()
()
; close_page_with_margin () ; close_page_with_margin ()
; page_end lang True ; page_end lang True
} }
......
...@@ -4590,8 +4590,8 @@ value record_ppp_abs_stems entry rstem ppstems = ...@@ -4590,8 +4590,8 @@ value record_ppp_abs_stems entry rstem ppstems =
else ((* taken care of as Tia *)) else ((* taken care of as Tia *))
; (* abs -ya computed whether set or anit *) ; (* abs -ya computed whether set or anit *)
match entry with match entry with
[ "av" -> record_abs_ya entry rstem rstem (* -avya *) [ "av" -> record_abs_ya entry rstem (revcode "aav") (* -aavya *)
| _ -> record_abs_ya entry rstem w | _ -> record_abs_ya entry rstem w
] ]
} }
| Tia w -> let (ita,itvaa) = if entry="grah" then ("iita","iitvaa") | Tia w -> let (ita,itvaa) = if entry="grah" then ("iita","iitvaa")
......
...@@ -8,4 +8,4 @@ ...@@ -8,4 +8,4 @@
(**************************************************************************) (**************************************************************************)
(* Generated by make version - see main Makefile *) (* Generated by make version - see main Makefile *)
value version="3.02" and version_date="2017-10-19"; value version="3.02" and version_date="2017-10-26";
VERSION='3.02' VERSION='3.02'
DATE='2017-10-19' DATE='2017-10-26'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment