From fc0b36e88fece0bb97827ae60ac121832a08d723 Mon Sep 17 00:00:00 2001 From: Alexis Nasr <alexis.nasr@lif.univ-mrs.fr> Date: Mon, 26 Sep 2016 10:51:46 -0400 Subject: [PATCH] moved word.c and sentence.c to maca_common changed some file names. --- maca_common/CMakeLists.txt | 2 + .../src => maca_common/include}/sentence.h | 0 .../src => maca_common/include}/word.h | 0 .../src/sentence.c | 0 {maca_trans_parser => maca_common}/src/word.c | 0 maca_trans_parser/CMakeLists.txt | 20 +++--- maca_trans_parser/src/beam.c | 2 +- maca_trans_parser/src/cff_cutoff.c | 4 +- maca_trans_parser/src/corpus.c | 67 ------------------- maca_trans_parser/src/corpus.h | 9 --- maca_trans_parser/src/decode_forrest.c | 4 +- maca_trans_parser/src/feat_vec.c | 3 - .../src/{decode.c => maca_trans_parser.c} | 6 +- .../src/maca_trans_parser_conll2cff.c | 5 +- .../src/maca_trans_parser_conll2fann.c | 5 +- .../{decode_tagger.c => maca_trans_tagger.c} | 0 ...tagger.c => maca_trans_tagger_conll2cff.c} | 1 - .../src/{movement.c => movement_parser.c} | 2 +- .../src/{movement.h => movement_parser.h} | 0 .../src/{oracle.c => oracle_parser.c} | 4 +- .../src/{oracle.h => oracle_parser.h} | 0 .../src/simple_decoder_forrest.c | 4 +- ...mple_decoder.c => simple_decoder_parser.c} | 4 +- ...mple_decoder.h => simple_decoder_parser.h} | 0 maca_trans_parser/src/train.c | 4 +- maca_trans_parser/src/train_perceptron.c | 5 +- maca_trans_parser/src/tree.c | 56 ---------------- maca_trans_parser/src/tree.h | 45 ------------- 28 files changed, 34 insertions(+), 218 deletions(-) rename {maca_trans_parser/src => maca_common/include}/sentence.h (100%) rename {maca_trans_parser/src => maca_common/include}/word.h (100%) rename {maca_trans_parser => maca_common}/src/sentence.c (100%) rename {maca_trans_parser => maca_common}/src/word.c (100%) delete mode 100644 maca_trans_parser/src/corpus.c delete mode 100644 maca_trans_parser/src/corpus.h rename maca_trans_parser/src/{decode.c => maca_trans_parser.c} (97%) rename maca_trans_parser/src/{decode_tagger.c => maca_trans_tagger.c} (100%) rename maca_trans_parser/src/{maca_trans_parser_conll2cff_tagger.c => maca_trans_tagger_conll2cff.c} (99%) rename maca_trans_parser/src/{movement.c => movement_parser.c} (99%) rename maca_trans_parser/src/{movement.h => movement_parser.h} (100%) rename maca_trans_parser/src/{oracle.c => oracle_parser.c} (96%) rename maca_trans_parser/src/{oracle.h => oracle_parser.h} (100%) rename maca_trans_parser/src/{simple_decoder.c => simple_decoder_parser.c} (98%) rename maca_trans_parser/src/{simple_decoder.h => simple_decoder_parser.h} (100%) delete mode 100644 maca_trans_parser/src/tree.c delete mode 100644 maca_trans_parser/src/tree.h diff --git a/maca_common/CMakeLists.txt b/maca_common/CMakeLists.txt index 4fb7f51..394e71f 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 78c431c..7d07e33 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 70ff2d2..6edd69f 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 818cd26..5801501 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 ecd2673..0000000 --- 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 20cb8af..0000000 --- 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 1371c04..ec3d199 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 4d650b0..a817056 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 6e749d1..51a7c7e 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 3ca37e8..9539944 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 d71feea..4c44bfe 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 9aa8c06..a3acdbd 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 288db3f..a2d5af0 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 0d8ddda..89cb0a8 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 f31d662..52f1194 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 b43dcbe..0459968 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 6f3dd3b..e084359 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 e2b21bb..52fb1bc 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 bd58bc8..0000000 --- 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 83a445f..0000000 --- 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 -- GitLab