Commit 07ca5211 authored by Idir Lankri's avatar Idir Lankri

Add CGI save_corpus

The HTML page produced by the CGI is wrong at the moment.
parent f84d47e0
......@@ -5,7 +5,6 @@
*.o
# Executables
ML/add_corpus
ML/conjugation
ML/css
ML/declension
......@@ -23,6 +22,7 @@ ML/reader
ML/regression
ML/reset_caches
ML/sandhier
ML/save_corpus
ML/test_stamp
ML/user_aid
ZEN/dagify
......
......@@ -286,5 +286,5 @@ mk_sandhi_page.cmo : web.cmo html.cmo
mk_sandhi_page.cmx : web.cmx html.cmx
manager.cmo : web.cmo interfaceParams.cmi html.cmo dir.cmi cgi.cmo
manager.cmx : web.cmx interfaceParams.cmx html.cmx dir.cmx cgi.cmx
add_corpus.cmo : web.cmo html.cmo
add_corpus.cmx : web.cmx html.cmx
save_corpus.cmo : web.cmo interfaceParams.cmi interface.cmi html.cmo cgi.cmo
save_corpus.cmx : web.cmx interfaceParams.cmx interface.cmx html.cmx cgi.cmx
......@@ -52,7 +52,7 @@ user_aid.ml reset_caches.ml interfaceParams.mli interfaceParams.ml
# 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 \
mk_index_page.ml mk_grammar_page.ml mk_reader_page.ml mk_sandhi_page.ml \
manager.ml add_corpus.ml
manager.ml save_corpus.ml
# extra file SCLpaths.ml for SCL interfacing - not distributed.
# TREE package - tree bank manager and syntax analyser - legacy
......@@ -136,7 +136,7 @@ bank_lexer.cmo tag_tree.cmo tag_apte.cmo
(cat debug_apte.ml ; cat -) | ocaml -I +camlp4 -I . -I $(ZEN)
cgis: skt_morph.cmi auto.cmi indexer indexerd declension conjugation \
lemmatizer reader parser sandhier reader interface user_aid manager add_corpus
lemmatizer reader parser sandhier reader interface user_aid manager save_corpus
indexer: indexer.cmx
$(LINK) list2.cmx gen.cmx paths.cmx version.cmx date.cmx \
......@@ -223,9 +223,18 @@ manager: manager.cmx
SCLpaths.cmx web.cmx cgi.cmx dir.cmx \
interfaceParams.cmx $< -o $@
add_corpus: add_corpus.cmx
$(LINK) paths.cmx version.cmx date.cmx html.cmx SCLpaths.cmx \
web.cmx cgi.cmx $< -o $@
save_corpus: save_corpus.cmx
$(LINK) unix.cmxa list2.cmx gen.cmx paths.cmx version.cmx date.cmx \
control.cmx word.cmx canon.cmx zen_lexer.cmx phonetics.cmx transduction.cmx \
encode.cmx skt_lexer.cmx padapatha.cmx sanskrit.cmx deco.cmx lexmap.cmx \
inflected.cmx html.cmx SCLpaths.cmx web.cmx naming.cmx morpho_string.cmx morpho.cmx \
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 interfaceParams.cmx \
interface.cmx $< -o $@
# $(LINK) paths.cmx version.cmx date.cmx html.cmx SCLpaths.cmx \
# web.cmx cgi.cmx interfaceParams.cmx $< -o $@
css: css.cmx
$(LINK) gen.cmx paths.cmx version.cmx date.cmx html.cmx \
......@@ -322,7 +331,7 @@ clean:
rm -f *.cmo *.cmi *.cmx *.ppi *.ppo *.o
rm -f css indexer indexerd sandhier reader parser lemmatizer \
declension conjugation mk_index_page mk_grammar_page mk_reader_page regression \
mk_sandhi_page sandhi_test reset_caches interface user_aid manager add_corpus \
mk_sandhi_page sandhi_test reset_caches interface user_aid manager save_corpus \
parse_apte tag_apte
# make dico.cmi auto.cmi conj_infos.cmi # needed to get dependencies right
......
(* CGI script [add_corpus] for adding a sentence to the corpus. *)
(*i module Add_corpus = struct i*)
value make () =
let title = "TODO" in
let meta_title = Html.title title in
let style = Html.background Html.Chamois in
do
{ Web.http_header |> Web.pl
; Web.page_begin meta_title
; Html.body_begin style |> Web.pl
; Html.h1_title title |> Web.pl
; Web.page_end Html.default_language True }
;
(***************)
(* Entry point *)
(***************)
value main = make ()
;
(*i end; i*)
......@@ -90,6 +90,8 @@ value create_env s =
value get key alist default =
try List.assoc key alist with [ Not_found -> default ]
;
value decoded_get key alist default = decode_url (get key alist default)
;
value query_string () =
try Sys.getenv "QUERY_STRING" with [
Not_found -> assert False (* By RFC 3875 section 4.1.7 *)
......
......@@ -530,7 +530,7 @@ value graph_engine () = do
and sent_id = get "sentenceNumber" env "0"
and link_num = get "linkNumber" env "0" (* is there a better default? *)
and sol_num = get "allSol" env "0" in (* Needed for Validate mode *)
let outdir = Cgi.get InterfaceParams.outdir env "" in
let outdir = Cgi.get InterfaceParams.outdir env "" in
let outfile = Cgi.get InterfaceParams.outfile env "" in
let text = arguments translit lex cache st us cp url_encoded_input
url_encoded_topic abs sol_num corpus sent_id link_num
......@@ -595,6 +595,24 @@ value graph_engine () = do
graph_cgi ^ "?" ^ text ^
";cpts=" ^ (string_points checkpoints) ^ "\";}\n</script>")
else ()
(* Save sentence button *)
; Web.cgi_begin Web.save_corpus_cgi "" |> Web.pl
; Html.hidden_input InterfaceParams.outdir (Cgi.decode_url outdir) |> Web.pl
; Html.hidden_input InterfaceParams.outfile (Cgi.decode_url outfile)
|> Web.pl
; Html.hidden_input "text" input |> Web.pl
; Html.hidden_input "lex" lex |> Web.pl
; Html.hidden_input "cache" cache |> Web.pl
; Html.hidden_input "st" st |> Web.pl
; Html.hidden_input "us" us |> Web.pl
; Html.hidden_input "cp" cp |> Web.pl
; Html.hidden_input "t" translit |> Web.pl
(* TODO: Pass missing parameters like checkpoints. *)
(* ; Html.hidden_input "topic" url_encoded_topic |> Web.pl *)
; Html.submit_input "Save sentence" |> Web.pl
; Web.cgi_end |> Web.pl
; close_page_with_margin ()
; page_end lang True
}
......
(* CGI script [manager] for corpus management, i.e. for listing
sentences of the corpus and calling [add_corpus] to add a sentence to
the corpus. *)
(* CGI script [manager] for corpus management, i.e. for listing and
adding sentences of the corpus. *)
(*************)
(* Utilities *)
......@@ -21,7 +20,7 @@ value split file = Str.split (Str.regexp Filename.dir_sep) file
;
value rec first_gap = fun
[ [] -> 1
| [ h ] -> h
| [ h ] -> h + 1
| [ x ; y :: t ] -> if y = x + 1 then first_gap [ y :: t ] else x + 1
]
;
......@@ -90,7 +89,7 @@ value make () =
let style = Html.background Html.Chamois in
let query = Cgi.query_string () in
let env = Cgi.create_env query in
let dir = Cgi.decode_url (Cgi.get dir_param env "") in
let dir = Cgi.decoded_get dir_param env "" in
do
{ Web.http_header |> Web.pl
; Web.page_begin meta_title
......
......@@ -63,8 +63,8 @@ value reader_page () = do
(* Contextual information from past discourse *)
let topic_mark = decode_url url_encoded_topic
and text = decode_url url_encoded_input in
let outdir = Cgi.get InterfaceParams.outdir env "" in
let outfile = Cgi.get InterfaceParams.outfile env "" in do
let outdir = Cgi.decoded_get InterfaceParams.outdir env "" in
let outfile = Cgi.decoded_get InterfaceParams.outfile env "" in do
{ pl (body_begin back_ground)
; print_title (Some lang) reader_title
; pl center_begin
......
(* CGI script [save_corpus] for saving a sentence into the corpus. *)
value make () =
let style = Html.background Html.Chamois in
let query = Cgi.query_string () in
let env = Cgi.create_env query in
let outdir = Cgi.decoded_get InterfaceParams.outdir env "" in
let outfile = Cgi.decoded_get InterfaceParams.outfile env "" in
let file = Web.corpus_dir ^ outdir ^ outfile ^ ".html" in
let title = "File " ^ file ^ " created." in
let meta_title = Html.title title in
let write_file file =
do
{ Unix.putenv "QUERY_STRING" query
; Web.output_channel.val := open_out file
; Interface.Interface.safe_engine ()
; close_out Web.output_channel.val
; Web.output_channel.val := stdout }
in
let mk_page () =
do
{ Web.http_header |> Web.pl
; Web.page_begin meta_title
; Html.body_begin style |> Web.pl
; Html.h1_title title |> Web.pl
; Web.page_end Html.default_language True }
in
do
{ write_file file
; mk_page () }
;
(***************)
(* Entry point *)
(***************)
value main = make ()
;
......@@ -52,7 +52,7 @@ and graph_cgi = cgi_bin Paths.cgi_graph (* summarizer graphical interf
and user_aid_cgi = cgi_bin Paths.cgi_user_aid (* unknown chunks processing *)
and sandhier_cgi = cgi_bin Paths.cgi_sandhier (* sandhier *)
and manager_cgi = cgi_bin Paths.cgi_manager (* Corpus manager *)
and add_corpus_cgi = cgi_bin Paths.cgi_add_corpus
and save_corpus_cgi = cgi_bin Paths.cgi_save_corpus
;
(* Absolute paths on development site *)
value resources name = Paths.skt_resources_dir ^ name ^ "/"
......
......@@ -190,7 +190,7 @@ CGIUSER=sktuser$(CGIEXT)
CGIMANAGER = manager$(CGIEXT)
# CGI name under which the program that enriches the corpus is installed
# on the server.
CGIADDCORPUS = addcorpus$(CGIEXT)
CGISAVECORPUS = savecorpus$(CGIEXT)
# what mouse action to use for viewing lemmatization
MOUSEACTION=#MOUSEACTION
......@@ -250,7 +250,7 @@ ML/reset_caches.ml ML/interfaceParams.mli ML/InterfaceParams.ml
WEB=ML/html.ml ML/web.ml ML/css.ml ML/cgi.ml ML/morpho_html.ml ML/chapters.ml \
ML/mk_index_page.ml ML/mk_grammar_page.ml ML/mk_reader_page.ml \
ML/mk_sandhi_page.ml ML/morpho_scl.ml ML/compute_mw_links.ml ML/manager.ml \
ML/add_corpus.ml
ML/save_corpus.ml
# TREE package - tree bank manager and syntax analyser - deprecated
TREE=ML/stemmer.ml ML/parse_tree.ml ML/parse_apte.ml ML/tag_tree.ml \
......@@ -422,7 +422,7 @@ echo 'and cgi_sandhier = "$(CGISANDHI)"'; \
echo 'and cgi_graph = "$(CGIGRAPH)"'; \
echo 'and cgi_user_aid = "$(CGIUSER)"'; \
echo 'and cgi_manager = "$(CGIMANAGER)"'; \
echo 'and cgi_add_corpus = "$(CGIADDCORPUS)"'; \
echo 'and cgi_save_corpus = "$(CGISAVECORPUS)"'; \
echo 'and mouse_action = "$(MOUSEACTION)";') > ML/paths.ml
$(MAKE) version
......@@ -487,7 +487,7 @@ releasecgi:
$(MAKE) analyser
$(MAKE) sandhi
$(MAKE) manager
$(MAKE) addcorpus
$(MAKE) savecorpus
abrevs:
cp $(BOOK)/abrevs.pdf SITE # for documenting the Website with abbreviations
......@@ -577,9 +577,9 @@ indexers: ML/indexer ML/indexerd
manager: ML/manager
cp $< $(CGIDIR)$(CGIMANAGER)
.PHONY: addcorpus
addcorpus: ML/add_corpus
cp $< $(CGIDIR)$(CGIADDCORPUS)
.PHONY: savecorpus
savecorpus: ML/save_corpus
cp $< $(CGIDIR)$(CGISAVECORPUS)
#### Version Management and Distribution are now managed by Git ####
......
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