Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
grew
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
grew
grew
Commits
37a24ca2
Commit
37a24ca2
authored
Sep 08, 2017
by
Bruno Guillaume
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add option old_grs
parent
cc9d91ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
8 deletions
+56
-8
src/grew_args.ml
src/grew_args.ml
+4
-2
src/grew_corpus.ml
src/grew_corpus.ml
+50
-4
src/grew_gtk.ml
src/grew_gtk.ml
+1
-1
src/grew_main.ml
src/grew_main.ml
+1
-1
No files found.
src/grew_args.ml
View file @
37a24ca2
...
...
@@ -14,7 +14,7 @@ open Libgrew
module
Grew_args
=
struct
type
mode
=
Gui
|
Corpus
|
Filter
|
Det
|
Full
|
Grep
|
Test
type
mode
=
Gui
|
Corpus
|
Filter
|
Transform
|
Full
|
Grep
|
Test
let
mode
=
ref
Gui
type
html_mode
=
...
...
@@ -25,6 +25,7 @@ module Grew_args = struct
let
grs
=
ref
None
let
gr
=
ref
None
let
gui_doc
=
ref
false
let
old_grs
=
ref
false
let
input_data
=
ref
""
let
output_dir
=
ref
None
...
...
@@ -57,7 +58,7 @@ module Grew_args = struct
let
args
=
[
"-corpus"
,
Unit
(
fun
()
->
mode
:=
Corpus
)
,
" enable corpus mode"
;
"-det"
,
Unit
(
fun
()
->
mode
:=
Det
)
,
" enable det mode: rewrite a corpus with a deterministric grs"
;
"-det"
,
Unit
(
fun
()
->
mode
:=
Transform
)
,
" enable det mode: rewrite a corpus with a deterministric grs"
;
"-full"
,
Unit
(
fun
()
->
mode
:=
Full
)
,
" enable full mode: rewrite a corpus (conll output)"
;
"-filter"
,
Unit
(
fun
()
->
mode
:=
Filter
)
,
" enable filter mode"
;
"-grep"
,
Unit
(
fun
()
->
mode
:=
Grep
)
,
" enable grep mode"
;
...
...
@@ -67,6 +68,7 @@ module Grew_args = struct
(* options for all modes *)
"-grs"
,
String
(
fun
s
->
grs
:=
Some
s
)
,
"<grs_file> chose the grs file to load"
;
"-old_grs"
,
Unit
(
fun
()
->
old_grs
:=
true
)
,
" Use old grs parser"
;
"-strat"
,
String
(
fun
s
->
strat
:=
s
)
,
"<strat> set the module strategy to use"
;
"-seq"
,
String
(
fun
s
->
strat
:=
s
)
,
"<strat> [DEPRECATED] replaced by -strat option"
;
"-timeout"
,
Float
(
fun
f
->
timeout
:=
Some
f
;
Rewrite
.
set_timeout
(
Some
f
))
,
"<float> set a timeout on rewriting"
;
...
...
src/grew_corpus.ml
View file @
37a24ca2
...
...
@@ -181,7 +181,7 @@ let multi_conll () =
)
()
(* -------------------------------------------------------------------------------- *)
let
det
()
=
let
obsolete_
det
()
=
handle
(
fun
()
->
if
!
Grew_args
.
input_data
=
""
then
(
Log
.
message
"No input data specified: use -i option"
;
exit
1
);
...
...
@@ -274,6 +274,54 @@ let full () =
)
()
(* -------------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------------- *)
let
transform
()
=
handle
(
fun
()
->
if
!
Grew_args
.
input_data
=
""
then
(
Log
.
message
"No input data specified: use -i option"
;
exit
1
);
match
(
!
Grew_args
.
grs
,
!
Grew_args
.
input_data
,
!
Grew_args
.
output_file
)
with
|
(
None
,_,_
)
->
Log
.
message
"No grs filespecified: use -grs option"
;
exit
1
|
(
_
,
""
,_
)
->
Log
.
message
"No input data specified: use -i option"
;
exit
1
|
(
_
,_,
None
)
->
Log
.
message
"No output specified: use -f option"
;
exit
1
|
(
Some
grs_file
,
input
,
Some
output_file
)
->
let
out_ch
=
open_out
output_file
in
let
grs
=
Grs
.
load
grs_file
in
let
domain
=
Grs
.
domain
grs
in
(* get the list of files to rewrite *)
let
graph_array
=
Corpus
.
get_graphs
?
domain
input
in
let
len
=
Array
.
length
graph_array
in
Array
.
iteri
(
fun
index
(
id
,
gr
)
->
Counter
.
print
index
len
id
;
match
Rewrite
.
simple_rewrite
~
gr
~
grs
~
strat
:!
Grew_args
.
strat
with
|
[
one
]
->
fprintf
out_ch
"%s
\n
"
(
Graph
.
to_conll_string
?
domain
one
)
|
l
->
List
.
iteri
(
fun
i
gr
->
let
conll
=
Graph
.
to_conll
?
domain
gr
in
let
conll_new_id
=
Conll
.
set_sentid
(
sprintf
"%s_%d"
id
i
)
conll
in
fprintf
out_ch
"%s
\n
"
(
Conll
.
to_string
conll_new_id
)
)
l
)
graph_array
;
close_out
out_ch
;
Counter
.
finish
()
)
()
(* -------------------------------------------------------------------------------- *)
let
grep
()
=
handle
(
fun
()
->
...
...
@@ -285,7 +333,7 @@ let full () =
let
domain
=
match
!
Grew_args
.
grs
with
|
None
->
None
|
Some
grs_file
->
Old_grs
.
get_domain
(
Old_grs
.
load
grs_
file
)
in
|
Some
file
->
Grs
.
domain
(
if
!
Grew_args
.
old_grs
then
Grs
.
load_old
file
else
Grs
.
load
file
)
in
let
pattern
=
Pattern
.
load
?
domain
pattern_file
in
...
...
@@ -339,5 +387,3 @@ let full () =
fprintf
out_ch
"%s"
(
Buffer
.
contents
buff
);
close_out
out_ch
)
()
src/grew_gtk.ml
View file @
37a24ca2
...
...
@@ -81,7 +81,7 @@ module Resources = struct
|
None
->
()
|
Some
file
->
Log
.
fmessage
"Loading grs file: '%s'"
file
;
current_grs
:=
Some
(
Grs
.
load
file
)
current_grs
:=
Some
(
if
!
Grew_args
.
old_grs
then
Grs
.
load_old
file
else
Grs
.
load
file
)
(* -------------------------------------------------------------------------------- *)
let
domain
()
=
match
!
current_grs
with
...
...
src/grew_main.ml
View file @
37a24ca2
...
...
@@ -26,7 +26,7 @@ let _ =
match
!
Grew_args
.
mode
with
|
Grew_args
.
Gui
->
Grew_gtk
.
init
()
|
Grew_args
.
Corpus
->
Grew_corpus
.
init
()
|
Grew_args
.
Det
->
Grew_corpus
.
det
()
|
Grew_args
.
Transform
->
Grew_corpus
.
transform
()
|
Grew_args
.
Full
->
Grew_corpus
.
full
()
|
Grew_args
.
Filter
->
Grew_corpus
.
multi_conll
()
|
Grew_args
.
Grep
->
Grew_corpus
.
grep
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment