Commit ed110b20 by Gérard Huet

Merge branch 'corpus-manager' into 'master'

Corpus manager

See merge request !9
parents da5f31a3 a3c85e34
##########################################################################
# #
# The Sanskrit Heritage Platform #
# #
# Idir Lankri #
......
##########################################################################
# #
# The Sanskrit Heritage Platform #
# #
# Idir Lankri #
......
/**************************************************************************/
/* */
/* The Sanskrit Heritage Platform */
/* */
/* Idir Lankri */
......
......@@ -229,18 +229,18 @@ automaton.cmo : web.cmo ../ZEN/trie.cmo ../ZEN/share.cmi phonetics.cmo \
automaton.cmx : web.cmx ../ZEN/trie.cmx ../ZEN/share.cmx phonetics.cmx \
../ZEN/list2.cmx ../ZEN/gen.cmx ../ZEN/deco.cmx canon.cmx auto.cmi
interface.cmi :
interface.cmo : ../ZEN/word.cmo web.cmo save_corpus_params.cmi sanskrit.cmi \
phases.cmo paths.cmo params.cmi nouns.cmi morphology.cmi morpho_html.cmo \
../ZEN/mini.cmo load_transducers.cmo load_morphs.cmo html.cmo \
graph_segmenter.cmo ../ZEN/gen.cmo encode.cmo dispatcher.cmi \
../ZEN/deco.cmo control.cmo checkpoints.cmo cgi.cmo canon.cmo \
automaton.cmo interface.cmi
interface.cmx : ../ZEN/word.cmx web.cmx save_corpus_params.cmx sanskrit.cmx \
phases.cmx paths.cmx params.cmx nouns.cmx morphology.cmi morpho_html.cmx \
../ZEN/mini.cmx load_transducers.cmx load_morphs.cmx html.cmx \
graph_segmenter.cmx ../ZEN/gen.cmx encode.cmx dispatcher.cmx \
../ZEN/deco.cmx control.cmx checkpoints.cmx cgi.cmx canon.cmx \
automaton.cmx interface.cmi
interface.cmo : ../ZEN/word.cmo web_corpus.cmi web.cmo \
save_corpus_params.cmi sanskrit.cmi phases.cmo paths.cmo params.cmi \
nouns.cmi morphology.cmi morpho_html.cmo ../ZEN/mini.cmo \
load_transducers.cmo load_morphs.cmo html.cmo graph_segmenter.cmo \
../ZEN/gen.cmo encode.cmo dispatcher.cmi ../ZEN/deco.cmo control.cmo \
checkpoints.cmo cgi.cmo canon.cmo automaton.cmo interface.cmi
interface.cmx : ../ZEN/word.cmx web_corpus.cmx web.cmx \
save_corpus_params.cmx sanskrit.cmx phases.cmx paths.cmx params.cmx \
nouns.cmx morphology.cmi morpho_html.cmx ../ZEN/mini.cmx \
load_transducers.cmx load_morphs.cmx html.cmx graph_segmenter.cmx \
../ZEN/gen.cmx encode.cmx dispatcher.cmx ../ZEN/deco.cmx control.cmx \
checkpoints.cmx cgi.cmx canon.cmx automaton.cmx interface.cmi
user_aid.cmo : ../ZEN/word.cmo web.cmo sanskrit.cmi phases.cmo paths.cmo \
morpho_html.cmo html.cmo ../ZEN/gen.cmo encode.cmo ../ZEN/deco.cmo \
control.cmo checkpoints.cmo cgi.cmo canon.cmo
......@@ -278,46 +278,48 @@ mk_index_page.cmo : web.cmo paths.cmo html.cmo
mk_index_page.cmx : web.cmx paths.cmx html.cmx
mk_grammar_page.cmo : web.cmo paths.cmo html.cmo
mk_grammar_page.cmx : web.cmx paths.cmx html.cmx
mk_reader_page.cmo : web.cmo paths.cmo params.cmi html.cmo control.cmo \
cgi.cmo
mk_reader_page.cmx : web.cmx paths.cmx params.cmx html.cmx control.cmx \
cgi.cmx
mk_reader_page.cmo : web_corpus.cmi web.cmo paths.cmo params.cmi html.cmo \
control.cmo cgi.cmo
mk_reader_page.cmx : web_corpus.cmx web.cmx paths.cmx params.cmx html.cmx \
control.cmx cgi.cmx
mk_sandhi_page.cmo : web.cmo html.cmo
mk_sandhi_page.cmx : web.cmx html.cmx
mk_corpus_page.cmo : web.cmo params.cmi html.cmo
mk_corpus_page.cmx : web.cmx params.cmx html.cmx
corpus.cmi : ../ZEN/word.cmo
corpus.cmo : ../ZEN/word.cmo sanskrit.cmi params.cmi ../ZEN/gen.cmo \
encode.cmo dir.cmi cgi.cmo corpus.cmi
corpus.cmx : ../ZEN/word.cmx sanskrit.cmx params.cmx ../ZEN/gen.cmx \
encode.cmx dir.cmx cgi.cmx corpus.cmi
web_corpus.cmi : web.cmo corpus.cmi
web_corpus.cmo : web.cmo paths.cmo params.cmi corpus.cmi cgi.cmo \
web_corpus.cmi
web_corpus.cmx : web.cmx paths.cmx params.cmx corpus.cmx cgi.cmx \
web_corpus.cmi
corpus_manager.cmi : web.cmo
mk_corpus_page.cmo : web_corpus.cmi web.cmo params.cmi html.cmo
mk_corpus_page.cmx : web_corpus.cmx web.cmx params.cmx html.cmx
corpus.cmi : ../ZEN/word.cmo html.cmo
corpus.cmo : ../ZEN/word.cmo sanskrit.cmi paths.cmo params.cmi html.cmo \
../ZEN/gen.cmo dir.cmi cgi.cmo canon.cmo corpus.cmi
corpus.cmx : ../ZEN/word.cmx sanskrit.cmx paths.cmx params.cmx html.cmx \
../ZEN/gen.cmx dir.cmx cgi.cmx canon.cmx corpus.cmi
web_corpus.cmi : corpus.cmi
web_corpus.cmo : paths.cmo corpus.cmi web_corpus.cmi
web_corpus.cmx : paths.cmx corpus.cmx web_corpus.cmi
corpus_manager.cmi : web_corpus.cmi
corpus_manager.cmo : web_corpus.cmi web.cmo paths.cmo params.cmi \
multilingual.cmo mkdir_corpus_params.cmi ../ZEN/list2.cmo html.cmo \
dir.cmi corpus.cmi control.cmo cgi.cmo canon.cmo corpus_manager.cmi
dir.cmi corpus.cmi cgi.cmo corpus_manager.cmi
corpus_manager.cmx : web_corpus.cmx web.cmx paths.cmx params.cmx \
multilingual.cmx mkdir_corpus_params.cmx ../ZEN/list2.cmx html.cmx \
dir.cmx corpus.cmx control.cmx cgi.cmx canon.cmx corpus_manager.cmi
corpus_manager_cgi.cmo : web.cmo params.cmi corpus_manager.cmi cgi.cmo
corpus_manager_cgi.cmx : web.cmx params.cmx corpus_manager.cmx cgi.cmx
dir.cmx corpus.cmx cgi.cmx corpus_manager.cmi
corpus_manager_cgi.cmo : web_corpus.cmi web.cmo params.cmi html.cmo \
corpus_manager.cmi control.cmo cgi.cmo
corpus_manager_cgi.cmx : web_corpus.cmx web.cmx params.cmx html.cmx \
corpus_manager.cmx control.cmx cgi.cmx
save_corpus_params.cmi :
save_corpus_params.cmo : save_corpus_params.cmi
save_corpus_params.cmx : save_corpus_params.cmi
save_corpus_cgi.cmo : web_corpus.cmi web.cmo save_corpus_params.cmi \
params.cmi html.cmo corpus_manager.cmi control.cmo cgi.cmo
sanskrit.cmi paths.cmo params.cmi html.cmo corpus_manager.cmi corpus.cmi \
control.cmo cgi.cmo
save_corpus_cgi.cmx : web_corpus.cmx web.cmx save_corpus_params.cmx \
params.cmx html.cmx corpus_manager.cmx control.cmx cgi.cmx
sanskrit.cmx paths.cmx params.cmx html.cmx corpus_manager.cmx corpus.cmx \
control.cmx cgi.cmx
mkdir_corpus_params.cmi :
mkdir_corpus_params.cmo : params.cmi mkdir_corpus_params.cmi
mkdir_corpus_params.cmx : params.cmx mkdir_corpus_params.cmi
mkdir_corpus_cgi.cmo : web_corpus.cmi web.cmo mkdir_corpus_params.cmi \
corpus_manager.cmi control.cmo cgi.cmo
html.cmo corpus_manager.cmi control.cmo cgi.cmo
mkdir_corpus_cgi.cmx : web_corpus.cmx web.cmx mkdir_corpus_params.cmx \
corpus_manager.cmx control.cmx cgi.cmx
mk_corpus.cmo : web.cmo paths.cmo params.cmi corpus.cmi
mk_corpus.cmx : web.cmx paths.cmx params.cmx corpus.cmx
html.cmx corpus_manager.cmx control.cmx cgi.cmx
mk_corpus.cmo : corpus.cmi
mk_corpus.cmx : corpus.cmx
......@@ -212,7 +212,7 @@ load_transducers.cmx pada.cmx phases.cmx dispatcher.cmx order.cmx \
chapters.cmx morpho_html.cmx bank_lexer.cmx cgi.cmx load_morphs.cmx \
int_sandhi.cmx nouns.cmx share.cmx minimap.cmx mini.cmx nums.cmxa \
graph_segmenter.cmx checkpoints.cmx automaton.cmx params.cmx \
save_corpus_params.cmx interface.cmx -o interface
save_corpus_params.cmx dir.cmx corpus.cmx web_corpus.cmx interface.cmx -o interface
user_aid: user_aid.cmx
$(LINK) str.cmxa list2.cmx gen.cmx paths.cmx version.cmx date.cmx \
......@@ -309,10 +309,7 @@ mk_grammar_page: mk_grammar_page.cmx
SCLpaths.cmx web.cmx mk_grammar_page.cmx -o mk_grammar_page
mk_reader_page: mk_reader_page.cmx
$(LINK) str.cmxa gen.cmx paths.cmx version.cmx date.cmx control.cmx \
html.cmx SCLpaths.cmx web.cmx cgi.cmx params.cmx \
mk_reader_page.cmx \
-o mk_reader_page
$(LINK) $(CORENATIVES) str.cmxa unix.cmxa control.cmx cgi.cmx date.cmx SCLpaths.cmx html.cmx web.cmx params.cmx dir.cmx corpus.cmx web_corpus.cmx mk_reader_page.cmx -o mk_reader_page
mk_nyaaya_page: mk_nyaaya_page.cmx
$(LINK) gen.cmx paths.cmx version.cmx date.cmx \
......@@ -323,8 +320,8 @@ mk_sandhi_page: mk_sandhi_page.cmx
SCLpaths.cmx web.cmx mk_sandhi_page.cmx -o mk_sandhi_page
mk_corpus_page: mk_corpus_page.cmx
$(LINK) str.cmxa gen.cmx paths.cmx version.cmx date.cmx \
html.cmx SCLpaths.cmx web.cmx params.cmx $< -o $@
$(LINK) $(CORENATIVES) str.cmxa unix.cmxa date.cmx \
html.cmx SCLpaths.cmx web.cmx params.cmx dir.cmx cgi.cmx corpus.cmx web_corpus.cmx $< -o $@
# site_pages must be recomputed after configuration and creation of DICO dir
# the style sheet must be recomputed, since it contains absolute URLs as well
......
......@@ -95,12 +95,10 @@ value decoded_get key default alist = decode_url (get key alist default)
value query_string_env_var = "QUERY_STRING"
;
value query_string () =
try Sys.getenv query_string_env_var with [
Not_found -> assert False (* By RFC 3875 section 4.1.7 *)
]
try Sys.getenv query_string_env_var with [ Not_found -> "" ]
;
value url_encode s =
let hexa_str c = Printf.sprintf "%X" (Char.code c) in
let hexa_str c = Printf.sprintf "%.2X" (Char.code c) in
(* Reference: RFC 3986 appendix A *)
let url_encode = fun
......
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......@@ -8,26 +9,54 @@
(* Operations on the corpus tree *)
module Heading : sig
module Section : sig
type t
;
value label : t -> string
;
end
;
module Analyzer : sig
type t = [ Graph ]
;
value path : t -> string
;
value relocatable_path : t -> string
;
end
;
module Analysis : sig
type t
;
value make : Analyzer.t -> Html.language -> string -> Num.num -> t
;
value analyzer : t -> Analyzer.t
;
value lang : t -> Html.language
;
value checkpoints : t -> string
;
value nb_sols : t -> Num.num
;
end
;
module Encoding : sig
type t = [ Velthuis | WX | KH | SLP1 | Devanagari | IAST ]
;
value to_string : t -> string
;
end
;
module Sentence : sig
type t
;
value make : int -> string -> list (string * string) -> t
value make : int -> list Word.word -> bool -> Analysis.t -> t
;
value id : t -> int
;
value analyzer : t -> string
;
value state : t -> list (string * string)
value text : Encoding.t -> t -> string
;
(* TODO: Determine all the fields. *)
type metadata = { text : list Word.word }
value analysis : t -> Analysis.t
;
end
;
......@@ -39,15 +68,15 @@ end
module type S = sig
(* Contents of a corpus subdirectory: either it is empty (constructor
[Empty]), otherwise we are on leaves of the tree (constructor
[Sentences]) or on branches (constructor [Headings]). *)
[Sentences]) or on branches (constructor [Sections]). *)
type contents =
[ Empty
| Headings of list Heading.t
| Sections of list Section.t
| Sentences of list Sentence.t
]
;
(* List the contents of the given corpus subdirectory. Note that the
returned elements are sorted according to [Heading.compare] or
returned elements are sorted according to [Section.compare] or
[Sentence.compare] depending on the case. Raise [Sys_error] when
an operating system error occurs. *)
value contents : string -> contents
......@@ -57,14 +86,14 @@ module type S = sig
exception Sentence_already_exists
;
(* Raise [Sentence_already_exists] if the sentence to be saved already
exists and [force] is [False], [Failure "save_sentence"] if the
given state is invalid and [Sys_error] when an operating system
error occurs. *)
value save_sentence : bool -> string -> list (string * string) -> unit
exists and [force] is [False] and [Sys_error] when an operating
system error occurs. *)
value save_sentence :
bool -> string -> int -> list Word.word -> bool -> Analysis.t -> unit
;
exception Heading_abbrev_already_exists of string
exception Section_already_exists of string
;
(* Raise [Heading_abbrev_already_exists] if the given corpus directory
(* Raise [Section_already_exists] if the given corpus directory
already exists and [Unix.Unix_error] when an operating system error
occurs. *)
value mkdir : string -> unit
......@@ -75,9 +104,23 @@ module type S = sig
exist. *)
value sentence : string -> int -> Sentence.t
;
value gobble_metadata : string -> Sentence.t -> Sentence.metadata
type mode = [ Reader | Annotator | Manager ]
;
value dump_metadata : string -> Sentence.t -> Sentence.metadata -> unit
value default_mode : mode
;
value string_of_mode : mode -> string
;
value mode_of_string : string -> mode
;
value url : string -> mode -> Sentence.t -> string
;
value relocatable_url : string -> mode -> Sentence.t -> string
;
(* [citation subdir id ]] returns an URL to the analysis
of the sentence whose number is [id] in the corpus
subdirectory [subdir]. Raise [Failure "citation"] if an
error occurs. *)
value citation : string -> int -> string
;
end
;
......
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......@@ -11,6 +12,7 @@
(* Generate the page displaying a view of the given corpus subdirectory.
The output channel is as always either [stdout] for CGI output or
a static HTML file (according to the "magic switch"
Web.output_channel). *)
value mk_page : string -> Web.corpus_mode -> unit
Web.output_channel). NB: No error handling is done by this
function. *)
value mk_page : string -> Web_corpus.mode -> unit
;
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......@@ -13,7 +14,14 @@ value main =
let env = Cgi.create_env (Cgi.query_string ()) in
let corpdir = Cgi.decoded_get Params.corpus_dir "" env in
let mode =
Web.corpus_mode_of_string (Cgi.decoded_get Params.corpus_mode "" env)
Web_corpus.mode_of_string (Cgi.decoded_get Params.corpus_mode "" env)
in
Corpus_manager.mk_page corpdir mode
try
Corpus_manager.mk_page corpdir mode
with
[ Sys_error msg -> Web.abort Html.default_language Control.sys_err_mess msg
| _ ->
Web.abort Html.default_language Control.fatal_err_mess
"Unexpected anomaly"
]
;
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......
......@@ -506,28 +506,30 @@ value append_cache entry gender =
; close_out cho
}
;
value save_button query =
Html.center_begin ^
Web.cgi_begin Web.save_corpus_cgi "" ^
Html.hidden_input Save_corpus_params.state (Html.escape query) ^
Html.submit_input "Save sentence" ^
Web.cgi_end ^
Html.center_end
value save_button query nb_sols =
center_begin ^
cgi_begin save_corpus_cgi "" ^
hidden_input Save_corpus_params.state (escape query) ^
hidden_input Save_corpus_params.nb_sols (nb_sols |> Num.string_of_num |> escape) ^
submit_input "Save" ^
cgi_end ^
center_end
;
value quit_button corpmode corpdir sentno =
let submit_button_label =
let submit_button_label = Web_corpus.(
match corpmode with
[ Web.Annotator -> "Abort"
| Web.Reader | Web.Manager -> "Continue reading"
[ Annotator -> "Abort"
| Reader | Manager -> "Continue reading"
]
)
in
Html.center_begin ^
Web.cgi_begin (Cgi.url Web.corpus_manager_cgi ~fragment:sentno) "" ^
Html.hidden_input Params.corpus_dir corpdir ^
Html.hidden_input Params.corpus_mode (Web.string_of_corpus_mode corpmode) ^
Html.submit_input submit_button_label ^
Web.cgi_end ^
Html.center_end
center_begin ^
cgi_begin (Cgi.url corpus_manager_cgi ~fragment:sentno) "" ^
hidden_input Params.corpus_dir corpdir ^
hidden_input Params.corpus_mode (Web_corpus.string_of_mode corpmode) ^
submit_input submit_button_label ^
cgi_end ^
center_end
;
(* Main body of graph segmenter cgi *)
value graph_engine () = do
......@@ -560,7 +562,7 @@ value graph_engine () = do
let corpus_mode =
url_enc_corpus_mode
|> Cgi.decode_url
|> Web.corpus_mode_of_string
|> Web_corpus.mode_of_string
in
let corpus_dir = Cgi.get Params.corpus_dir env "" in
let sentence_no = Cgi.get Params.sentence_no env "" in
......@@ -579,7 +581,7 @@ value graph_engine () = do
| g -> (guess_morph,g)
] in do
{ append_cache entry gender
; let cache_txt_file = Web.public_cache_txt_file in
; let cache_txt_file = public_cache_txt_file in
let cache = Nouns.extract_current_cache cache_txt_file in
make_cache_transducer cache
}
......@@ -629,19 +631,20 @@ value graph_engine () = do
else ()
(* Save sentence button *)
; if Web.corpus_manager_mode corpus_dir sentence_no &&
corpus_mode = Web.Annotator then
save_button query |> Web.pl
; if corpus_mode = Web_corpus.Annotator then
(* TODO: use segment_all to compute the nb of sols instead of
passing 0 as nb_sols. *)
save_button query (Num.num_of_int 0) |> pl
else
()
; Html.html_break |> Web.pl
; html_break |> pl
(* Quit button: continue reading (reader mode) or quit without
saving (annotator mode). *)
; if Web.corpus_mode corpus_dir sentence_no then
; if sentence_no <> "" then
quit_button corpus_mode
(Cgi.decode_url corpus_dir) (Cgi.decode_url sentence_no) |> Web.pl
(Cgi.decode_url corpus_dir) (Cgi.decode_url sentence_no) |> pl
else
()
......
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......@@ -47,17 +48,18 @@ value populate_corpus dirname file =
in
let rec aux i =
try
let line = input_line ch in
let state =
[ (Params.corpus_dir, dirname)
; (Params.sentence_no, string_of_int i)
; ("t", Paths.default_transliteration)
]
in
do
{ extract_citation state (Corp.save_sentence True Web.graph_cgi) line i
; aux (i + 1)
}
(* let line = input_line ch in *)
(* let state = *)
(* [ (Params.corpus_dir, dirname) *)
(* ; (Params.sentence_no, string_of_int i) *)
(* ; ("t", Paths.default_transliteration) *)
(* ] *)
(* in *)
failwith "TODO"
(* do *)
(* { extract_citation state (Corp.save_sentence True Web.graph_cgi) line i *)
(* ; aux (i + 1) *)
(* } *)
with
[ End_of_file -> () ]
in
......
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......@@ -8,37 +9,42 @@
(* This program produces the pages corpus.html (Corpus interface). *)
open Html;
open Web;
value mode_selection =
List.map (fun mode ->
let mode_str = Web.string_of_corpus_mode mode in
(String.capitalize mode_str, mode_str, mode = Web.Reader)
) Web.[ Reader; Annotator; Manager ]
let selection modes =
List.map (fun mode ->
let mode_str = Web_corpus.string_of_mode mode in
(String.capitalize mode_str, mode_str, mode = Web_corpus.Reader)
) modes
in
let read_only_modes = [ Web_corpus.Reader ] in
let other_modes = Web_corpus.[ Annotator; Manager ] in
let all_modes = read_only_modes @ other_modes in
selection (if corpus_read_only then read_only_modes else all_modes)
;
value make lang =
let title =
if Web.corpus_toggle then "Sanskrit Corpus" else "No corpus available"
in
let title_str = "Sanskrit Corpus" in
do
{ Web.open_html_file (Web.corpus_page lang) (Html.title title)
; Html.body_begin Html.Chamois_back |> Web.pl
; Web.open_page_with_margin 15
; Html.h1_title title |> Web.print_title (Some lang)
; Html.center_begin |> Web.pl
; if Web.corpus_toggle then
Web.cgi_begin Web.corpus_manager_cgi "" ^
"Mode: " ^
Html.option_select_default Params.corpus_mode mode_selection ^ " " ^
Html.submit_input "OK" ^
Web.cgi_end |> Web.pl
else ()
; Html.center_end |> Web.pl
; Web.close_page_with_margin ()
; Web.close_html_file lang True
{ open_html_file (corpus_page lang) (title title_str)
; body_begin Chamois_back |> pl
; open_page_with_margin 15
; h1_title title_str |> print_title (Some lang)
; center_begin |> pl
; cgi_begin corpus_manager_cgi "" ^
"Mode: " ^
option_select_default Params.corpus_mode mode_selection ^ " " ^
submit_input "OK" ^
cgi_end |> pl
; center_end |> pl
; close_page_with_margin ()
; close_html_file lang True
}
;
value main =
do
{ make Html.English
; make Html.French
{ make English
; make French
}
;
......@@ -49,7 +49,7 @@ value reader_page () = do
[ Some lang -> do
{ open_html_file (reader_page lang) reader_meta_title; (lang,"") }
| None -> do
{ reader_prelude ""; (Html.default_language, Sys.getenv "QUERY_STRING") }
{ reader_prelude ""; (default_language, Sys.getenv "QUERY_STRING") }
] in try
let env = create_env query in
let url_encoded_input = get "text" env ""
......@@ -71,12 +71,12 @@ value reader_page () = do
{ pl (body_begin back_ground)
; print_title (Some lang) reader_title
; Html.h3_begin Html.C3 |> Web.pl
; if Web.corpus_manager_mode corpus_dir sentence_no then
"Corpus annotator mode" |> Web.pl
; h3_begin C3 |> pl
; if Web_corpus.(mode_of_string corpus_mode = Annotator) then
"Corpus annotator mode - " ^ corpus_dir |> pl
else
()
; Html.h3_end |> Web.pl
; h3_end |> pl
; pl center_begin
; pl (cgi_reader_begin reader_cgi "convert")
; print_lexicon_select (lexicon_of lang)
......@@ -115,9 +115,9 @@ value reader_page () = do
(interaction_modes_default url_encoded_mode))
(* Corpus parameters *)
; Html.hidden_input Params.corpus_mode corpus_mode |> Web.pl
; Html.hidden_input Params.corpus_dir corpus_dir |> Web.pl
; Html.hidden_input Params.sentence_no sentence_no |> Web.pl
; hidden_input Params.corpus_mode corpus_mode |> pl
; hidden_input Params.corpus_dir corpus_dir |> pl
; hidden_input Params.sentence_no sentence_no |> pl
; pl html_break
; pl (submit_input "Read")
......@@ -127,7 +127,7 @@ value reader_page () = do
; match out_mode.val with
[ Some lang -> close_html_file lang True
| None ->
do { close_page_with_margin (); page_end Html.default_language True }
do { close_page_with_margin (); page_end default_language True }
]
}
with
......
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......@@ -8,6 +9,8 @@
(* CGI script [mkdir_corpus] for creating a new corpus subdirectory. *)
open Web;
value main =
let query = Cgi.query_string () in
let env = Cgi.create_env query in
......@@ -15,27 +18,31 @@ value main =
let parent_dir = Cgi.decoded_get Mkdir_corpus_params.parent_dir "" env in
let mode =
Cgi.decoded_get Mkdir_corpus_params.mode "" env
|> Web.corpus_mode_of_string
|> Web_corpus.mode_of_string
in
let error_page = Web.error_page "Corpus Manager" in
let error_page = error_page "Corpus Manager" in
match mode with
[ Web.Manager ->
[ Web_corpus.Manager ->
try
do
{ Web_corpus.mkdir (Filename.concat parent_dir dirname)
; Corpus_manager.mk_page parent_dir mode
}
with
[ Web_corpus.Heading_abbrev_already_exists abbrev ->
error_page "Already used heading abbreviation " abbrev
[ Web_corpus.Section_already_exists abbrev ->
error_page "Already existing section " abbrev
| Unix.Unix_error (err, func, arg) ->
let submsg =
Printf.sprintf "'%s' failed on '%s': %s"
func arg (Unix.error_message err)
in
error_page Control.sys_err_mess submsg
| _ ->
abort Html.default_language Control.fatal_err_mess "Unexpected anomaly"
]
| Web.Reader | Web.Annotator ->
Web.invalid_corpus_mode_page Web.Manager mode
| Web_corpus.Reader | Web_corpus.Annotator ->
let expected_mode = Web_corpus.(string_of_mode Manager) in
let current_mode = Web_corpus.string_of_mode mode in
invalid_corpus_mode_page expected_mode current_mode
]
;
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......
(**************************************************************************)
(* *)
(* The Sanskrit Heritage Platform *)
(* *)
(* Idir Lankri *)
......@@ -8,8 +9,11 @@
(* CGI script [save_corpus] for saving a sentence into the corpus. *)
open Html;
open Web;
value confirmation_page query =
let title = "Sanskrit Corpus" in
let title_str = "Sanskrit Corpus" in
let env = Cgi.create_env query in
let corpdir = Cgi.decoded_get Params.corpus_dir "" env in
let corpmode = Cgi.decoded_get Params.corpus_mode "" env in
......@@ -19,31 +23,51 @@ value confirmation_page query =
in
let specific_url path = Cgi.url path ~fragment:sentno in
do
{ Web.maybe_http_header ()
; Web.page_begin (Html.title title)
; Html.body_begin Html.Chamois_back |> Web.pl
; Web.open_page_with_margin 15
; Html.h1_title title |> Web.print_title (Some Html.default_language)
; Html.center_begin |> Web.pl
; Html.div Html.Latin16 confirmation_msg |> Web.pl
; Html.html_break |> Web.pl
; Web.cgi_begin (specific_url Web.save_corpus_cgi) "" |> Web.pl
; Html.hidden_input Save_corpus_params.state (Html.escape query) |> Web.pl
; Html.hidden_input Save_corpus_params.force (string_of_bool True) |> Web.pl
; Html.submit_input "Yes" |> Web.pl
; Web.cgi_end |> Web.pl
; Html.html_break |> Web.pl
; Web.cgi_begin (specific_url Web.corpus_manager_cgi) "" |> Web.pl
; Html.hidden_input Params.corpus_dir corpdir |> Web.pl
; Html.hidden_input Params.corpus_mode corpmode |> Web.pl
; Html.submit_input "No" |> Web.pl
; Web.cgi_end |> Web.pl
; Html.center_end |> Web.pl
; Web.close_page_with_margin ()
; Web.page_end Html.default_language True
{ maybe_http_header ()
; page_begin (title title_str)
; body_begin Chamois_back |> pl
; open_page_with_margin 15
; h1_title title_str |> print_title (Some default_language)
; center_begin |> pl
; div Latin16 confirmation_msg |> pl
; html_break |> pl
; cgi_begin (specific_url save_corpus_cgi) "" |> pl
; hidden_input Save_corpus_params.state (escape query) |> pl
; hidden_input Save_corpus_params.force (string_of_bool True) |> pl
; submit_input "Yes" |> pl
; cgi_end |> pl
; html_break |> pl
; cgi_begin (specific_url corpus_manager_cgi) "" |> pl
; hidden_input Params.corpus_dir corpdir |> pl
; hidden_input Params.corpus_mode corpmode |> pl
; submit_input "No" |> pl
;