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
L
libcaml-grew
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
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
libcaml-grew
Commits
d924c424
Commit
d924c424
authored
Feb 01, 2018
by
Bruno Guillaume
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change function Graph.to_sentence to take into account deco info
parent
b2a8c8b8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
29 deletions
+62
-29
src/grew_fs.ml
src/grew_fs.ml
+6
-4
src/grew_fs.mli
src/grew_fs.mli
+1
-1
src/grew_graph.ml
src/grew_graph.ml
+51
-20
src/grew_graph.mli
src/grew_graph.mli
+1
-1
src/libgrew.ml
src/libgrew.ml
+2
-2
src/libgrew.mli
src/libgrew.mli
+1
-1
No files found.
src/grew_fs.ml
View file @
d924c424
...
...
@@ -296,10 +296,12 @@ module G_fs = struct
|
s
->
sprintf
"<TABLE BORDER=
\"
0
\"
CELLBORDER=
\"
0
\"
CELLSPACING=
\"
0
\"
>
\n
%s
\n
</TABLE>
\n
"
s
(* ---------------------------------------------------------------------- *)
let
to_word
?
main_feat
t
=
match
get_main
?
main_feat
t
with
|
(
None
,
_
)
->
"#"
|
(
Some
(
_
,
atom
)
,
_
)
->
string_of_value
atom
let
to_word
(
t
:
t
)
=
match
List_
.
sort_assoc
"phon"
t
with
|
Some
s
->
Some
(
string_of_value
s
)
|
None
->
match
List_
.
sort_assoc
"form"
t
with
|
Some
s
->
Some
(
string_of_value
s
)
|
None
->
None
(* ---------------------------------------------------------------------- *)
let
escape_sharp
s
=
...
...
src/grew_fs.mli
View file @
d924c424
...
...
@@ -47,7 +47,7 @@ module G_fs: sig
val
get_float_feat
:
string
->
t
->
float
option
val
to_gr
:
t
->
string
val
to_dot
:
?
decorated_feat
:
(
string
*
string
list
)
->
?
main_feat
:
string
->
t
->
string
val
to_word
:
?
main_feat
:
string
->
t
->
string
val
to_word
:
t
->
string
option
val
to_dep
:
?
decorated_feat
:
(
string
*
string
list
)
->
?
position
:
float
->
?
main_feat
:
string
->
?
filter
:
(
string
->
bool
)
->
t
->
string
val
to_conll_string
:
?
exclude
:
string
list
->
t
->
string
val
to_conll
:
?
exclude
:
string
list
->
t
->
(
string
*
string
)
list
...
...
src/grew_graph.ml
View file @
d924c424
...
...
@@ -756,29 +756,60 @@ module G_graph = struct
Buffer
.
contents
buff
(* -------------------------------------------------------------------------------- *)
let
to_sentence
?
main_feat
graph
=
let
fusion_item_space_after
fi
=
try
if
List
.
assoc
"SpaceAfter"
fi
.
efs
=
"No"
then
""
else
" "
with
Not_found
->
" "
let
space_after
gnode
=
match
G_fs
.
get_string_atom
"_MISC_SpaceAfter"
(
G_node
.
get_fs
gnode
)
with
|
Some
"No"
->
""
|
_
->
" "
let
esc
s
=
Str
.
global_replace
(
Str
.
regexp
"<"
)
"<"
s
let
to_sentence
?
main_feat
?
(
deco
=
G_deco
.
empty
)
graph
=
let
is_highlighted_gid
gid
=
List
.
mem_assoc
gid
deco
.
nodes
in
let
inside
fusion_item
gid
=
let
first
=
Gid_map
.
find
fusion_item
.
first
graph
.
map
in
let
last
=
Gid_map
.
find
fusion_item
.
last
graph
.
map
in
let
node
=
Gid_map
.
find
gid
graph
.
map
in
match
(
G_node
.
get_position
first
,
G_node
.
get_position
node
,
G_node
.
get_position
last
)
with
|
(
Ordered
f
,
Ordered
n
,
Ordered
l
)
when
f
<=
n
&&
n
<=
l
->
true
|
_
->
false
in
let
is_highlighted_fusion_item
fusion_item
=
List
.
exists
(
fun
(
gid
,_
)
->
inside
fusion_item
gid
)
deco
.
nodes
in
let
nodes
=
Gid_map
.
fold
(
fun
id
elt
acc
->
(
id
,
elt
)
::
acc
)
graph
.
map
[]
in
let
snodes
=
List
.
sort
(
fun
(
_
,
n1
)
(
_
,
n2
)
->
G_node
.
position_comp
n1
n2
)
nodes
in
let
words
=
List
.
map
(
fun
(
id
,
node
)
->
G_fs
.
to_word
?
main_feat
(
G_node
.
get_fs
node
)
)
snodes
in
List
.
fold_left
(
fun
acc
(
regexp
,
repl
)
->
Str
.
global_replace
(
Str
.
regexp_string
regexp
)
repl
acc
)
(
String
.
concat
" "
words
)
[
" -t-"
,
"-t-"
;
"_-_"
,
"-"
;
"_"
,
" "
;
"' "
,
"'"
;
" ,"
,
","
;
" ."
,
"."
;
"( "
,
"("
;
" )"
,
")"
;
"
\\\"
"
,
"
\"
"
;
]
let
rec
loop
skip
=
function
|
[]
->
""
|
(
gid
,
gnode
)
::
gtail
when
skip
=
None
->
begin
match
List
.
find_opt
(
fun
fusion_item
->
fusion_item
.
first
=
gid
)
graph
.
fusion
with
|
Some
fusion_item
->
(
if
is_highlighted_fusion_item
fusion_item
then
sprintf
"<span class=
\"
highlight
\"
>%s</span>"
(
esc
fusion_item
.
word
)
else
(
esc
fusion_item
.
word
))
^
(
fusion_item_space_after
fusion_item
)
^
(
loop
(
Some
fusion_item
.
last
)
gtail
)
|
None
->
match
G_fs
.
to_word
(
G_node
.
get_fs
gnode
)
with
|
None
->
(
loop
None
gtail
)
|
Some
text
->
(
if
is_highlighted_gid
gid
then
sprintf
"<span class=
\"
highlight
\"
>%s</span>"
(
esc
text
)
else
esc
(
text
))
^
(
space_after
gnode
)
^
(
loop
None
gtail
)
end
|
(
gid
,
gnode
)
::
gtail
when
skip
=
Some
gid
->
loop
None
gtail
|
(
gid
,
gnode
)
::
gtail
->
loop
skip
gtail
in
Sentence
.
fr_clean_spaces
(
loop
None
snodes
)
(* -------------------------------------------------------------------------------- *)
let
to_dep
?
domain
?
filter
?
main_feat
?
(
deco
=
G_deco
.
empty
)
graph
=
...
...
src/grew_graph.mli
View file @
d924c424
...
...
@@ -197,7 +197,7 @@ module G_graph: sig
(* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *)
val
to_gr
:
?
domain
:
Domain
.
t
->
t
->
string
val
to_dot
:
?
domain
:
Domain
.
t
->
?
main_feat
:
string
->
?
deco
:
G_deco
.
t
->
t
->
string
val
to_sentence
:
?
main_feat
:
string
->
t
->
string
val
to_sentence
:
?
main_feat
:
string
->
?
deco
:
G_deco
.
t
->
t
->
string
val
to_dep
:
?
domain
:
Domain
.
t
->
?
filter
:
(
string
->
bool
)
->
?
main_feat
:
string
->
?
deco
:
G_deco
.
t
->
t
->
string
val
to_conll
:
?
domain
:
Domain
.
t
->
t
->
Conll
.
t
val
to_conll_string
:
?
domain
:
Domain
.
t
->
t
->
string
...
...
src/libgrew.ml
View file @
d924c424
...
...
@@ -205,10 +205,10 @@ type t = Grew_graph.G_graph.t
let
to_conll_string
?
domain
graph
=
handle
~
name
:
"Graph.to_conll_string"
(
fun
()
->
Grew_graph
.
G_graph
.
to_conll_string
?
domain
graph
)
()
let
to_sentence
?
main_feat
gr
=
let
to_sentence
?
main_feat
?
deco
gr
=
handle
~
name
:
"Graph.to_sentence"
(
fun
()
->
Grew_graph
.
G_graph
.
to_sentence
?
main_feat
gr
Grew_graph
.
G_graph
.
to_sentence
?
main_feat
?
deco
gr
)
()
let
save_conll
?
domain
filename
graph
=
...
...
src/libgrew.mli
View file @
d924c424
...
...
@@ -87,7 +87,7 @@ module Graph : sig
val
of_pst
:
?
domain
:
Domain
.
t
->
string
->
t
val
sentence_of_pst
:
?
domain
:
Domain
.
t
->
string
->
string
val
to_sentence
:
?
main_feat
:
string
->
t
->
string
val
to_sentence
:
?
main_feat
:
string
->
?
deco
:
Deco
.
t
->
t
->
string
val
to_dot
:
?
domain
:
Domain
.
t
->
?
main_feat
:
string
->
?
deco
:
Deco
.
t
->
t
->
string
...
...
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