diff --git a/maca_common/CMakeLists.txt b/maca_common/CMakeLists.txt index 4fb7f512c32d2bdb99945cd41b13499540f15e27..394e71f18c2252e2cb296a2e73c3804d2e528769 100644 --- a/maca_common/CMakeLists.txt +++ b/maca_common/CMakeLists.txt @@ -6,6 +6,8 @@ set(SOURCES src/util.c src/dico_vec.c src/feat_types.c src/form2pos.c + src/word.c + src/sentence.c ) #compiling library diff --git a/maca_trans_parser/src/sentence.h b/maca_common/include/sentence.h similarity index 100% rename from maca_trans_parser/src/sentence.h rename to maca_common/include/sentence.h diff --git a/maca_trans_parser/src/word.h b/maca_common/include/word.h similarity index 100% rename from maca_trans_parser/src/word.h rename to maca_common/include/word.h diff --git a/maca_trans_parser/src/sentence.c b/maca_common/src/sentence.c similarity index 100% rename from maca_trans_parser/src/sentence.c rename to maca_common/src/sentence.c diff --git a/maca_trans_parser/src/word.c b/maca_common/src/word.c similarity index 100% rename from maca_trans_parser/src/word.c rename to maca_common/src/word.c diff --git a/maca_trans_parser/CMakeLists.txt b/maca_trans_parser/CMakeLists.txt index 78c431c637d3715b615a2a08f03ffa6a96befd7c..7d07e332bbfcf44b087dd9a1285d1ec3611c37b9 100644 --- a/maca_trans_parser/CMakeLists.txt +++ b/maca_trans_parser/CMakeLists.txt @@ -1,22 +1,20 @@ set(SOURCES src/context.c src/feat_desc.c src/feature_table.c - src/movement.c + src/movement_parser.c src/movement_tagger.c - src/sentence.c src/feat_fct.c src/feat_vec.c src/global_feat_vec.c - src/oracle.c + src/oracle_parser.c src/oracle_tagger.c - src/simple_decoder.c + src/simple_decoder_parser.c src/simple_decoder_forrest.c src/simple_decoder_tagger.c src/cf_file.c src/feat_lib.c src/perceptron.c src/stack.c - src/word.c src/config2feat_vec.c src/depset.c src/feat_model.c @@ -31,10 +29,10 @@ add_library(transparse STATIC ${SOURCES}) #compiling, linking and installing executables -add_executable(maca_trans_parser_conll2cff_tagger ./src/maca_trans_parser_conll2cff_tagger.c) -target_link_libraries(maca_trans_parser_conll2cff_tagger transparse) -target_link_libraries(maca_trans_parser_conll2cff_tagger maca_common) -install (TARGETS maca_trans_parser_conll2cff_tagger DESTINATION bin) +add_executable(maca_trans_tagger_conll2cff ./src/maca_trans_tagger_conll2cff.c) +target_link_libraries(maca_trans_tagger_conll2cff transparse) +target_link_libraries(maca_trans_tagger_conll2cff maca_common) +install (TARGETS maca_trans_tagger_conll2cff DESTINATION bin) add_executable(maca_trans_parser_conll2fann ./src/maca_trans_parser_conll2fann.c) target_link_libraries(maca_trans_parser_conll2fann transparse) @@ -46,7 +44,7 @@ target_link_libraries(maca_trans_parser_conll2cff transparse) target_link_libraries(maca_trans_parser_conll2cff maca_common) install (TARGETS maca_trans_parser_conll2cff DESTINATION bin) -add_executable(maca_trans_parser ./src/decode.c) +add_executable(maca_trans_parser ./src/maca_trans_parser.c) target_link_libraries(maca_trans_parser transparse) target_link_libraries(maca_trans_parser maca_common) install (TARGETS maca_trans_parser DESTINATION bin) @@ -56,7 +54,7 @@ target_link_libraries(maca_trans_parser_forrest transparse) target_link_libraries(maca_trans_parser_forrest maca_common) install (TARGETS maca_trans_parser_forrest DESTINATION bin) -add_executable(maca_trans_tagger ./src/decode_tagger.c) +add_executable(maca_trans_tagger ./src/maca_trans_tagger.c) target_link_libraries(maca_trans_tagger transparse) target_link_libraries(maca_trans_tagger maca_common) install (TARGETS maca_trans_tagger DESTINATION bin) diff --git a/maca_trans_parser/src/beam.c b/maca_trans_parser/src/beam.c index 70ff2d2bf7ede7ec8084be62f63b338b7c828a02..6edd69fabc798407cfe10e3edda14a4250e34bf0 100644 --- a/maca_trans_parser/src/beam.c +++ b/maca_trans_parser/src/beam.c @@ -3,7 +3,7 @@ #include<string.h> #include"beam.h" #include"feat_fct.h" -#include"movement.h" +#include"movement_parser.h" #include"config2feat_vec.h" diff --git a/maca_trans_parser/src/cff_cutoff.c b/maca_trans_parser/src/cff_cutoff.c index 818cd26b1dbfb5fbba7b4b4a278620ed185cb8d1..5801501c9ca40a8525207df0d309b0ee9adafb8d 100644 --- a/maca_trans_parser/src/cff_cutoff.c +++ b/maca_trans_parser/src/cff_cutoff.c @@ -3,8 +3,8 @@ #include<string.h> #include<unistd.h> #include<getopt.h> -#include"movement.h" -#include"oracle.h" +#include"movement_parser.h" +#include"oracle_parser.h" #include"feature_table.h" #include"dico.h" #include"perceptron.h" diff --git a/maca_trans_parser/src/corpus.c b/maca_trans_parser/src/corpus.c deleted file mode 100644 index ecd26733cc7462ef42e4e81ba516bbd7364961b0..0000000000000000000000000000000000000000 --- a/maca_trans_parser/src/corpus.c +++ /dev/null @@ -1,67 +0,0 @@ -#include<stdio.h> -#include<stdlib.h> -#include<string.h> -#include"context.h" -#include"dico.h" - -void corpus_fill_all_dico(context *ctx) -{ - FILE *f = NULL; - char form[500]; - - char lemma[500]; - char cpos[100]; - char pos[100]; - char feats[100]; - int dep, gov; - char label[100]; - int n; - char buffer[10000]; - char mvt[100]; - int i; - - ctx->d_pos = dico_new("d_pos", 10); - dico_add(ctx->d_pos, "NULL"); - - ctx->d_cpos = dico_new("d_cpos", 10); - dico_add(ctx->d_cpos, "NULL"); - - ctx->d_feats = dico_new("d_feats", 10); - dico_add(ctx->d_feats, "NULL"); - - ctx->d_labels = dico_new("d_labels", 10); - dico_add(ctx->d_labels, "NULL"); - dico_add(ctx->d_labels, "ROOT"); - - ctx->d_mvt = dico_new("d_mvt", 10); - dico_add(ctx->d_mvt, "NULL"); - - f= fopen(ctx->conll_filename, "r"); - if(f == NULL){ - fprintf(stderr, "cannot open file %s\n", ctx->conll_filename); - exit(1); - } - - while(fgets(buffer, 10000, f)){ - if(feof(f)) break; - n = sscanf(buffer, "%d\t%s\t%s\t%s\t%s\t%s\t%d\t%s\t_\t_\n", &dep, form, lemma, cpos, pos, feats,&gov, label); - if(n != -1){ - dico_add(ctx->d_cpos, cpos); - dico_add(ctx->d_pos, pos); - dico_add(ctx->d_feats, feats); - dico_add(ctx->d_labels, label); - } - } - fclose(f); - - /* create the dictionnary for movements */ - dico_add(ctx->d_mvt, "S"); - for(i=0; i < ctx->d_labels->nbelem; i++){ - strcpy(mvt, "R_"); - strcat(mvt, ctx->d_labels->array[i]); - dico_add(ctx->d_mvt, mvt); - strcpy(mvt, "L_"); - strcat(mvt, ctx->d_labels->array[i]); - dico_add(ctx->d_mvt, mvt); - } -} diff --git a/maca_trans_parser/src/corpus.h b/maca_trans_parser/src/corpus.h deleted file mode 100644 index 20cb8af3ef3ecb193064730a72b7a29890d22fc4..0000000000000000000000000000000000000000 --- a/maca_trans_parser/src/corpus.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __CORPUS__ -#define __CORPUS__ - -#include"context.h" - -void corpus_fill_all_dico(context *ctx); - - -#endif diff --git a/maca_trans_parser/src/decode_forrest.c b/maca_trans_parser/src/decode_forrest.c index 1371c04d43c7af8c8d8f30cb0142222bffd118e7..ec3d199d6e79319caf88a956944961d796e26aab 100644 --- a/maca_trans_parser/src/decode_forrest.c +++ b/maca_trans_parser/src/decode_forrest.c @@ -4,8 +4,8 @@ #include<unistd.h> #include<getopt.h> #include"context.h" -#include"movement.h" -#include"oracle.h" +#include"movement_parser.h" +#include"oracle_parser.h" #include"feat_fct.h" #include"feature_table.h" #include"dico.h" diff --git a/maca_trans_parser/src/feat_vec.c b/maca_trans_parser/src/feat_vec.c index 4d650b09a7b87bef1c483c5c24ddf18d2e75a067..a8170567bb17042291d29fcedc8c7c3dc12f283b 100644 --- a/maca_trans_parser/src/feat_vec.c +++ b/maca_trans_parser/src/feat_vec.c @@ -5,11 +5,8 @@ #include "feat_types.h" #include "feat_model.h" - - void feat_vec_concat(feat_vec *fv1, feat_vec *fv2) { - int i; for(i=0; i < fv2->nb; i++) if(fv2->t[i] != -1) diff --git a/maca_trans_parser/src/decode.c b/maca_trans_parser/src/maca_trans_parser.c similarity index 97% rename from maca_trans_parser/src/decode.c rename to maca_trans_parser/src/maca_trans_parser.c index 6e749d156e73c8714d11145413bcc3c93a7dc654..51a7c7e3f70ecc747e175e7af51380961c800c7a 100644 --- a/maca_trans_parser/src/decode.c +++ b/maca_trans_parser/src/maca_trans_parser.c @@ -4,13 +4,13 @@ #include<unistd.h> #include<getopt.h> #include"context.h" -#include"movement.h" -#include"oracle.h" +#include"movement_parser.h" +#include"oracle_parser.h" #include"feat_fct.h" #include"feature_table.h" #include"dico.h" #include"beam.h" -#include"simple_decoder.h" +#include"simple_decoder_parser.h" /*#include"dnn_decoder.h"*/ #include"config2feat_vec.h" diff --git a/maca_trans_parser/src/maca_trans_parser_conll2cff.c b/maca_trans_parser/src/maca_trans_parser_conll2cff.c index 3ca37e8cc3b2ffc1ae25184e82d8c9653aefa15a..95399445ad5ae618e3c2751f21046a7be88678cb 100644 --- a/maca_trans_parser/src/maca_trans_parser_conll2cff.c +++ b/maca_trans_parser/src/maca_trans_parser_conll2cff.c @@ -3,13 +3,12 @@ #include<string.h> #include<unistd.h> #include<getopt.h> -#include"movement.h" -#include"oracle.h" +#include"movement_parser.h" +#include"oracle_parser.h" #include"feat_fct.h" #include"context.h" #include"feat_vec.h" #include"dico_vec.h" -#include"corpus.h" #include"word_emb.h" #include"config2feat_vec.h" diff --git a/maca_trans_parser/src/maca_trans_parser_conll2fann.c b/maca_trans_parser/src/maca_trans_parser_conll2fann.c index d71feea86fc9e5c16f832025885b9530223062dd..4c44bfefafd7c071c10e2134c4735fefc9c16b74 100644 --- a/maca_trans_parser/src/maca_trans_parser_conll2fann.c +++ b/maca_trans_parser/src/maca_trans_parser_conll2fann.c @@ -3,13 +3,12 @@ #include<string.h> #include<unistd.h> #include<getopt.h> -#include"movement.h" -#include"oracle.h" +#include"movement_parser.h" +#include"oracle_parser.h" #include"feat_fct.h" #include"context.h" #include"feat_vec.h" #include"dico_vec.h" -#include"corpus.h" #include"word_emb.h" #include"config2feat_vec.h" diff --git a/maca_trans_parser/src/decode_tagger.c b/maca_trans_parser/src/maca_trans_tagger.c similarity index 100% rename from maca_trans_parser/src/decode_tagger.c rename to maca_trans_parser/src/maca_trans_tagger.c diff --git a/maca_trans_parser/src/maca_trans_parser_conll2cff_tagger.c b/maca_trans_parser/src/maca_trans_tagger_conll2cff.c similarity index 99% rename from maca_trans_parser/src/maca_trans_parser_conll2cff_tagger.c rename to maca_trans_parser/src/maca_trans_tagger_conll2cff.c index 9aa8c060469b001badbbbf03bd21106f287f377a..a3acdbda342d3b47cd16ec4a4e2745592e8ede6e 100644 --- a/maca_trans_parser/src/maca_trans_parser_conll2cff_tagger.c +++ b/maca_trans_parser/src/maca_trans_tagger_conll2cff.c @@ -9,7 +9,6 @@ #include"context.h" #include"feat_vec.h" #include"dico_vec.h" -#include"corpus.h" #include"word_emb.h" #include"config2feat_vec.h" diff --git a/maca_trans_parser/src/movement.c b/maca_trans_parser/src/movement_parser.c similarity index 99% rename from maca_trans_parser/src/movement.c rename to maca_trans_parser/src/movement_parser.c index 288db3fbf2bba2eda2c8157497d67c5955f70d88..a2d5af021740903671c46ec4f59877640ca70486 100644 --- a/maca_trans_parser/src/movement.c +++ b/maca_trans_parser/src/movement_parser.c @@ -2,7 +2,7 @@ #include<stdlib.h> #include<string.h> #include"util.h" -#include"movement.h" +#include"movement_parser.h" #if 0 int movement_label(int mvt) diff --git a/maca_trans_parser/src/movement.h b/maca_trans_parser/src/movement_parser.h similarity index 100% rename from maca_trans_parser/src/movement.h rename to maca_trans_parser/src/movement_parser.h diff --git a/maca_trans_parser/src/oracle.c b/maca_trans_parser/src/oracle_parser.c similarity index 96% rename from maca_trans_parser/src/oracle.c rename to maca_trans_parser/src/oracle_parser.c index 0d8dddac8e119c66f62426d52615d913b557fb81..89cb0a82488af79e0d55e2060cfdd0aa2652f65b 100644 --- a/maca_trans_parser/src/oracle.c +++ b/maca_trans_parser/src/oracle_parser.c @@ -1,8 +1,8 @@ #include<stdio.h> #include<stdlib.h> #include<string.h> -#include"oracle.h" -#include"movement.h" +#include"oracle_parser.h" +#include"movement_parser.h" int check_all_dependents_of_word_in_ref_are_in_hyp(config *c, sentence *ref, int word_index) { diff --git a/maca_trans_parser/src/oracle.h b/maca_trans_parser/src/oracle_parser.h similarity index 100% rename from maca_trans_parser/src/oracle.h rename to maca_trans_parser/src/oracle_parser.h diff --git a/maca_trans_parser/src/simple_decoder_forrest.c b/maca_trans_parser/src/simple_decoder_forrest.c index f31d6623bf159f881708cc8496c6f9f5b702d714..52f1194ab3a56015e674923b4d34e0cca59404e2 100644 --- a/maca_trans_parser/src/simple_decoder_forrest.c +++ b/maca_trans_parser/src/simple_decoder_forrest.c @@ -4,8 +4,8 @@ #include<unistd.h> #include<getopt.h> #include"context.h" -#include"movement.h" -#include"oracle.h" +#include"movement_parser.h" +#include"oracle_parser.h" #include"feat_fct.h" #include"config2feat_vec.h" #include"feature_table.h" diff --git a/maca_trans_parser/src/simple_decoder.c b/maca_trans_parser/src/simple_decoder_parser.c similarity index 98% rename from maca_trans_parser/src/simple_decoder.c rename to maca_trans_parser/src/simple_decoder_parser.c index b43dcbeacfc2a6e587b8800961758191e98f5cfe..0459968cb14af10ec5f13e12f7c0b813da28e8d3 100644 --- a/maca_trans_parser/src/simple_decoder.c +++ b/maca_trans_parser/src/simple_decoder_parser.c @@ -4,8 +4,8 @@ #include<unistd.h> #include<getopt.h> #include"context.h" -#include"movement.h" -#include"oracle.h" +#include"movement_parser.h" +#include"oracle_parser.h" #include"feat_fct.h" #include"config2feat_vec.h" #include"feature_table.h" diff --git a/maca_trans_parser/src/simple_decoder.h b/maca_trans_parser/src/simple_decoder_parser.h similarity index 100% rename from maca_trans_parser/src/simple_decoder.h rename to maca_trans_parser/src/simple_decoder_parser.h diff --git a/maca_trans_parser/src/train.c b/maca_trans_parser/src/train.c index 6f3dd3b8db5dcf0b664773bca4c537e239a43b18..e084359b4ae9e6e25922cabcb00f959045f96b37 100644 --- a/maca_trans_parser/src/train.c +++ b/maca_trans_parser/src/train.c @@ -3,8 +3,8 @@ #include<string.h> #include<unistd.h> #include<getopt.h> -#include"movement.h" -#include"oracle.h" +#include"movement_parser.h" +#include"oracle_parser.h" #include"feat_fct.h" #include"feature_table.h" #include"dico.h" diff --git a/maca_trans_parser/src/train_perceptron.c b/maca_trans_parser/src/train_perceptron.c index e2b21bbdd951c1aa9e39b1ce560b93c3b76f16d4..52fb1bcbb23576c445be206fb0d7f40e9f1943f7 100644 --- a/maca_trans_parser/src/train_perceptron.c +++ b/maca_trans_parser/src/train_perceptron.c @@ -3,14 +3,13 @@ #include<string.h> #include<unistd.h> #include<getopt.h> -#include"movement.h" -#include"oracle.h" +#include"movement_parser.h" +#include"oracle_parser.h" #include"feat_fct.h" #include"context.h" #include"feat_vec.h" #include"feature_table.h" #include"dico_vec.h" -#include"corpus.h" #include"beam.h" #include"word_emb.h" #include"config2feat_vec.h" diff --git a/maca_trans_parser/src/tree.c b/maca_trans_parser/src/tree.c deleted file mode 100644 index bd58bc844be6cfba6569e22a4fd966987ff1bb5f..0000000000000000000000000000000000000000 --- a/maca_trans_parser/src/tree.c +++ /dev/null @@ -1,56 +0,0 @@ - -void node_print(node *root) -{ - node *child = NULL; - for(child = root->last_left_child; child; child = child->prec_sibling) - print_node(child); - printf("%s ", root->string_array[1]); - for(child = root->first_right_child; child; child = child->next_sibling) - print_node(child); -} - - -void node_add_right_child(node *gov, int label, node *dep) -{ - - dep->label = label; - dep->gov = gov; - if(gov->first_right_child == NULL){ - gov->first_right_child = gov->last_right_child = dep; - return; - } - - dep->prec_sibling = gov->last_right_child; - gov->last_right_child->next_sibling = dep; - gov->last_right_child = dep; -} - -void node_add_left_child(node *gov, int label, node *dep) -{ - dep->label = label; - dep->gov = gov; - if(gov->first_left_child == NULL){ - gov->first_left_child = gov->last_left_child = dep; - return; - } - - dep->prec_sibling = gov->last_left_child; - gov->last_left_child->next_sibling = dep; - gov->last_left_child = dep; -} - -node *node_new(word *w) -{ - int i; - node *n = (node *) memalloc(sizeof(node)); - - n->w = w; - - n->next_sibling = NULL; - n->prec_sibling = NULL; - n->first_right_child = NULL; - n->last_right_child = NULL; - n->first_left_child = NULL; - n->last_left_child = NULL; - return n; -} diff --git a/maca_trans_parser/src/tree.h b/maca_trans_parser/src/tree.h deleted file mode 100644 index 83a445f11210ca12a7891fd0fd4b911417bd5d42..0000000000000000000000000000000000000000 --- a/maca_trans_parser/src/tree.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __TREE__ -#define __TREE__ - -#include "word.h" - -typedef struct _node { - word *w; - struct _word *next_sibling; - struct _word *prec_sibling; - struct _word *gov; - struct _word *first_right_child; - struct _word *last_right_child; - struct _word *first_left_child; - struct _word *last_left_child; - int label; - int index; - -} node; - -void print_node(word *root); - -void word_add_right_child(word *gov, int label, word *dep); -void word_add_left_child(word *gov, int label, word *dep); - -word *word_new(char *input); -word *word_create_dummy(mcd *mcd_struct); - -word *word_copy(word *w); -void word_free(word *w); -void word_print_conll07(FILE *f, word *w, mcd *mcd_struct); -void word_print(FILE *f, word *w, mcd *mcd_struct, dico *dico_labels); - - -void word_set_column_value(word *w, mcd *mcd_struct, int column, char *value); -char *word_get_column_value(word *w, mcd *mcd_struct, int column); - -void word_set_feature_value(word *w, int feat, int value); -int word_get_feature_value(word *w, int feat); - -word *word_read(FILE *f, mcd *mcd_struct); - -word *word_parse_buffer(char *buffer, mcd *mcd_struct); - - -#endif