Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
macaon2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexis Nasr
macaon2
Commits
d249131f
Commit
d249131f
authored
7 years ago
by
Alexis Nasr
Browse files
Options
Downloads
Patches
Plain Diff
modified maca_lexer so that it can take as input speakers and word duration (very ad hoc)!
parent
9151a419
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
maca_lexer/src/maca_lexer.c
+58
-15
58 additions, 15 deletions
maca_lexer/src/maca_lexer.c
with
58 additions
and
15 deletions
maca_lexer/src/maca_lexer.c
+
58
−
15
View file @
d249131f
...
...
@@ -38,7 +38,7 @@ int look_for_accept_state_in_path(trie *mwe_trie, int *states_array, int path_in
return
-
1
;
}
void
print_states_array
(
char
*
buffer
,
context
*
ctx
,
trie
*
mwe_trie
,
dico
*
d_mwe_tokens
,
int
*
states_array
,
int
*
symbols_array
,
int
path_index
)
void
print_states_array
(
char
*
buffer
,
context
*
ctx
,
trie
*
mwe_trie
,
dico
*
d_mwe_tokens
,
int
*
states_array
,
int
*
symbols_array
,
int
path_index
,
float
*
start_array
,
float
*
end_array
,
int
orfeo
,
char
*
spkr
)
{
int
i
;
if
(
path_index
==
0
)
return
;
...
...
@@ -54,18 +54,30 @@ void print_states_array(char *buffer, context *ctx, trie *mwe_trie, dico *d_mwe_
else
printf
(
"%s
\t
0
\n
"
,
dico_int2string
(
d_mwe_tokens
,
symbols_array
[
i
]));
}
}
if
(
i
>
0
&&
orfeo
){
printf
(
"
\t
%f
\t
%f
\t
%s"
,
start_array
[
0
],
end_array
[
accept_state_index
],
spkr
);
}
if
(
ctx
->
paste
)
if
(
accept_state_index
!=
-
1
)
printf
(
"
\n
"
);
/* all tokens in path s.t. accept_state_index < token_index < path_index do not form an mwe, they are just printed */
for
(
i
=
accept_state_index
+
1
;
i
<
path_index
;
i
++
){
if
(
ctx
->
paste
)
if
(
ctx
->
paste
){
if
(
orfeo
){
printf
(
"%s
\t
%f
\t
%f
\t
%s
\n
"
,
dico_int2string
(
d_mwe_tokens
,
symbols_array
[
i
]),
start_array
[
i
],
end_array
[
i
],
spkr
);
}
else
{
printf
(
"%s
\n
"
,
dico_int2string
(
d_mwe_tokens
,
symbols_array
[
i
]));
}
}
else
printf
(
"%s
\t
1
\n
"
,
dico_int2string
(
d_mwe_tokens
,
symbols_array
[
i
]));
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
char
buffer
[
10000
];
...
...
@@ -77,9 +89,15 @@ int main(int argc, char *argv[])
dico
*
d_mwe_tokens
=
NULL
;
int
states_array
[
100
];
/* an array in which we store the states we have traversed in the trie */
int
symbols_array
[
100
];
float
start_array
[
100
];
float
end_array
[
100
];
int
path_index
=
0
;
int
next_state
;
int
orfeo
=
1
;
char
form
[
1000
];
float
start
;
float
end
;
char
spkr
[
1000
];
ctx
=
context_read_options
(
argc
,
argv
);
maca_lexer_check_options
(
ctx
);
...
...
@@ -109,16 +127,29 @@ int main(int argc, char *argv[])
continue
;
}
buffer
[
strlen
(
buffer
)
-
1
]
=
'\0'
;
if
(
orfeo
){
sscanf
(
buffer
,
"%s
\t
%f
\t
%f
\t
%s"
,
form
,
&
start
,
&
end
,
spkr
);
/* look for code of form read */
form_code
=
dico_string2int
(
d_mwe_tokens
,
form
);
}
else
{
/* look for code of form read */
form_code
=
dico_string2int
(
d_mwe_tokens
,
buffer
);
}
if
(
form_code
==
-
1
){
/* if form has no code, it cannot be part of a mwe, print the potential mwe discovered so far */
print_states_array
(
buffer
,
ctx
,
mwe_trie
,
d_mwe_tokens
,
states_array
,
symbols_array
,
path_index
);
print_states_array
(
buffer
,
ctx
,
mwe_trie
,
d_mwe_tokens
,
states_array
,
symbols_array
,
path_index
,
start_array
,
end_array
,
orfeo
,
spkr
);
path_index
=
0
;
/* print the current form */
if
(
ctx
->
paste
)
if
(
ctx
->
paste
){
if
(
orfeo
)
printf
(
"%s
\t
%f
\t
%f
\t
%s
\n
"
,
form
,
start
,
end
,
spkr
);
else
printf
(
"%s
\n
"
,
buffer
);
}
else
printf
(
"%s
\t
1
\n
"
,
buffer
);
continue
;
...
...
@@ -130,12 +161,16 @@ int main(int argc, char *argv[])
if
(
next_state
!=
0
){
/* the path is growing */
symbols_array
[
path_index
]
=
form_code
;
if
(
orfeo
){
start_array
[
path_index
]
=
start
;
end_array
[
path_index
]
=
end
;
}
states_array
[
path_index
]
=
next_state
;
path_index
++
;
continue
;
}
/* print the potential mwe discovered so far */
print_states_array
(
buffer
,
ctx
,
mwe_trie
,
d_mwe_tokens
,
states_array
,
symbols_array
,
path_index
);
print_states_array
(
buffer
,
ctx
,
mwe_trie
,
d_mwe_tokens
,
states_array
,
symbols_array
,
path_index
,
start_array
,
end_array
,
orfeo
,
spkr
);
if
(
path_index
!=
0
)
/* if there was a path that aborted, see if there is a valid transition from state 0 with form */
...
...
@@ -145,14 +180,22 @@ int main(int argc, char *argv[])
if
(
next_state
){
/* such a transition exists */
symbols_array
[
path_index
]
=
form_code
;
if
(
orfeo
){
start_array
[
path_index
]
=
start
;
end_array
[
path_index
]
=
end
;
}
states_array
[
path_index
]
=
next_state
;
path_index
++
;
continue
;
}
/* such a transition does not exist, just print the form */
if
(
ctx
->
paste
)
if
(
ctx
->
paste
){
if
(
orfeo
)
printf
(
"%s
\t
%f
\t
%f
\t
%s
\n
"
,
form
,
start
,
end
,
spkr
);
else
printf
(
"%s
\n
"
,
buffer
);
}
else
printf
(
"%s
\t
1
\n
"
,
buffer
);
}
...
...
@@ -160,7 +203,7 @@ int main(int argc, char *argv[])
if
(
path_index
!=
0
){
/* there is something in states array */
/* print the potential mwe discovered so far */
print_states_array
(
buffer
,
ctx
,
mwe_trie
,
d_mwe_tokens
,
states_array
,
symbols_array
,
path_index
);
print_states_array
(
buffer
,
ctx
,
mwe_trie
,
d_mwe_tokens
,
states_array
,
symbols_array
,
path_index
,
start_array
,
end_array
,
orfeo
,
spkr
);
path_index
=
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment