Skip to content
Snippets Groups Projects
Commit 442a0adb authored by Ibtissem Benchikh LeHocine's avatar Ibtissem Benchikh LeHocine
Browse files

Add utf8/char16

parent 77764b6d
Branches
Tags
No related merge requests found
#ifndef __FEAT_DESC__
#define __FEAT_DESC__
#include "char16.h"/*
typedef struct
{
char* form;
char* pos;
}FP;
typedef int (*feat_fct) (FP *c);*/
typedef int (*feat_fct) (void *c);
typedef struct {
......
......@@ -5,6 +5,7 @@ set(SOURCES
src/fplm2cff_fct.c
src/predict_fct.c
src/fplm_fct.c
../maca_common/src/char16.c
)
......
......@@ -85,20 +85,20 @@ void write_cff(FILE *cff, CLASS class, FILE* code_class, char* form, char* morph
feat_vec_print(cff, fv);
return;
}
if(class == TENSE)
/*if(class == TENSE)
{
fprintf(cff,"%d", associate_number_to_classes(code_class,class,morpho_feature,0));
form2fv(form, fv, fm, dico_features, ADD_MODE);
feat_vec_print(cff, fv);
}
else
{
{*/
for(i=0; i<(int)strlen(morpho_feature);i++)
{
fprintf(cff,"%d", associate_number_to_classes(code_class,class,morpho_feature,i));
form2fv(form, fv, fm, dico_features, ADD_MODE);
feat_vec_print(cff, fv);
}
}
//}
}
......@@ -99,20 +99,20 @@ int associate_number_to_classes(FILE* classes_code, CLASS class, char* morpho_fe
fscanf(classes_code,"%s",tmp);
while(fscanf(classes_code,"%d %s\n",&code,tmp) == 2)
{
if(class == TENSE)
/*if(class == TENSE)
{
if(!strcmp(tmp, morpho_feature))
return code;
}
else
{
{*/
if(tmp[0] == morpho_feature[current_morpho_feature])
return code;
//}
}
}
if(class == TENSE)
fprintf(classes_code, "%d %s\n", code+1, morpho_feature);
else
//if(class == TENSE)
//fprintf(classes_code, "%d %s\n", code+1, morpho_feature);
//else
fprintf(classes_code, "%d %c\n", code+1, morpho_feature[current_morpho_feature]);
return code+1;
}
......@@ -2,83 +2,119 @@
#include <stdlib.h>
#include <string.h>
#include "feat_lib.h"
#include "char16.h"
/*
char* type[22] = {"np","adj","nc","adv","prep","poncts","csu","v","vprespart","vppart",
"vinf","pres","ponctw","clr","det","coo","cln","pro","pri","prorel","clo","advneg"};
int find_type(char* pos)
{
int i;
for(i=0;i<22;i++)
if(!strcmp(pos,type[i]))
return i;
return -1;
}*/
/*patterns feature*/
int p1(void *input)
int s1(void* form)
{
if(input == NULL || (int)strlen((char *)input) - 1 < 0)
char16* tmp = utf8tochar16(form);
int size = char16_strlen(tmp);
if(tmp == NULL || size - 1 < 0)
return -1;
return ((char *)input)[(int)strlen((char *)input) - 1];
return tmp[size - 1];
}
int p2(void *input)
int s2(void* form)
{
if(input == NULL || (int)strlen((char *)input) - 2 < 0)
char16* tmp = utf8tochar16(form);
int size = char16_strlen(tmp);
if(tmp == NULL || size - 2 < 0)
return -1;
return ((char *)input)[(int)strlen((char *)input) - 2];
return tmp[size - 2];
}
int p3(void *input)
int s3(void* form)
{
if(input == NULL || (int)strlen((char *)input) - 3 < 0)
char16* tmp = utf8tochar16(form);
int size = char16_strlen(tmp);
if(tmp == NULL || size - 3 < 0)
return -1;
return ((char *)input)[(int)strlen((char *)input) - 3];
return tmp[size - 3];
}
int p4(void *input)
int s4(void* form)
{
if(input == NULL || (int)strlen((char *)input) - 4 < 0)
char16* tmp = utf8tochar16(form);
int size = char16_strlen(tmp);
if(tmp == NULL || size - 4 < 0)
return -1;
return ((char *)input)[(int)strlen((char *)input) - 4];
return tmp[size - 4];
}
int p5(void *input)
int s5(void* form)
{
if(input == NULL || (int)strlen((char *)input) - 5 < 0)
char16* tmp = utf8tochar16(form);
int size = char16_strlen(tmp);
if(tmp == NULL || size - 5 < 0)
return -1;
return ((char *)input)[(int)strlen((char *)input) - 5];
return tmp[size - 5];
}
int p6(void *input)
int s6(void* form)
{
if(input == NULL || (int)strlen((char *)input) - 6 < 0)
char16* tmp = utf8tochar16(form);
int size = char16_strlen(tmp);
if(tmp == NULL || size - 6 < 0)
return -1;
return ((char *)input)[(int)strlen((char *)input) - 6];
return tmp[size - 6];
}
int p7(void *input)
int s7(void* form)
{
if(input == NULL || (int)strlen((char *)input) - 7 < 0)
char16* tmp = utf8tochar16(form);
int size = char16_strlen(tmp);
if(tmp == NULL || size - 7 < 0)
return -1;
return ((char *)input)[(int)strlen((char *)input) - 7];
return tmp[size - 7];
}
int p8(void *input)
int s8(void* form)
{
if(input == NULL || (int)strlen((char *)input) - 8 < 0)
char16* tmp = utf8tochar16(form);
int size = char16_strlen(tmp);
if(tmp == NULL || size - 8 < 0)
return -1;
return ((char *)input)[(int)strlen((char *)input) - 8];
return tmp[size - 8];
}
int p9(void *input)
int s9(void* form)
{
if(input == NULL || (int)strlen((char *)input) - 9 < 0)
char16* tmp = utf8tochar16(form);
int size = char16_strlen(tmp);
if(tmp == NULL || size - 9 < 0)
return -1;
return ((char *)input)[(int)strlen((char *)input) - 9];
return tmp[size - 9];
}
int p10(void *input)
int s10(void* form)
{
if(input == NULL || (int)strlen((char *)input) - 10 < 0)
char16* tmp = utf8tochar16(form);
int size = char16_strlen(tmp);
if(tmp == NULL || size - 10 < 0)
return -1;
return ((char *)input)[(int)strlen((char *)input) - 10];
}
return tmp[size - 10];
}/*
int code_pos(FP* fp)
{
return find_type(fp->pos);
}*/
feat_lib *feat_lib_build(void) {
feat_lib *fl = feat_lib_new();
feat_lib_add(fl, 1, (char *)"p1", p1);
feat_lib_add(fl, 1, (char *)"p2", p2);
feat_lib_add(fl, 1, (char *)"p3", p3);
feat_lib_add(fl, 1, (char *)"p4", p4);
feat_lib_add(fl, 1, (char *)"p5", p5);
feat_lib_add(fl, 1, (char *)"p6", p6);
feat_lib_add(fl, 1, (char *)"p7", p7);
feat_lib_add(fl, 1, (char *)"p8", p8);
feat_lib_add(fl, 1, (char *)"p9", p9);
feat_lib_add(fl, 1, (char *)"p10", p10);
feat_lib_add(fl, 1, (char *)"s1", s1);
feat_lib_add(fl, 1, (char *)"s2", s2);
feat_lib_add(fl, 1, (char *)"s3", s3);
feat_lib_add(fl, 1, (char *)"s4", s4);
feat_lib_add(fl, 1, (char *)"s5", s5);
feat_lib_add(fl, 1, (char *)"s6", s6);
feat_lib_add(fl, 1, (char *)"s7", s7);
feat_lib_add(fl, 1, (char *)"s8", s8);
feat_lib_add(fl, 1, (char *)"s9", s9);
feat_lib_add(fl, 1, (char *)"s10", s10);
//feat_lib_add(fl, 1, (char *)"code_pose", code_pos);
return fl;
}
......
......@@ -119,11 +119,12 @@ int extract_real_class(FILE* code_class, CLASS class, char* morpho_feature, int*
size++;
real_class[size]=0;
}
else if(class == TENSE)
/*else if(class == TENSE)
{
size++;
real_class[size] = associate_number_to_classes(code_class,class,morpho_feature,0);
}
}*/
//
else
{
for(i=0; i<(int)strlen(morpho_feature);i++) //do not parcour the array if it's the tense !!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment