
c语言错误 5 error C2228: ".v"的左边必须有类/结构/联合,代码有一些问题,求帮忙,谢谢. 40
求测试样本的tfidftypedefstruct{charword[36];doublev;}WORD;WORDvwords[SUM];//存放(词条,权重)数组FILE...
求测试样本的tfidf
typedef struct
{
char word[36];
double v;
}WORD;
WORD vwords[SUM]; //存放(词条,权重)数组
FILE *fp, *out;
char tt[][40];//一个词典数组
char temp[36], words[SUM][36], ct; //temp读取提取特征中的一个词,words保存总的特征词条
int i, j, k, m, df, tf, count; //count为特征词条总数
count = 0; df = 0; tf = 0; i = 0; j = 0; k = 0;
i = 0; j = 0;
double vector; //暂存权重值
int max = 0; //出现次数最多的词
int flag = 0;
char *h[1] = { "f:\\fenci\\fenci\\*.txt" }; //某类别总文本的存放位置
char r1[] = "f:\\fenci\\fenci\\提取特征向量集\\特征.txt"; //提取的总特征存放位置
char r2[100];
char wname[] = "f:\\fenci\\fenci\\权重向量集\\特征.txt"; //输出所有(特征,权重)对的位置
count = strlen(*tt);
fHandle = _findfirst(h[0], &fa);
if (fHandle == -1L)
{
printf("当前目录下没有txt文件\n");
return 0;
}
else
do
{
for (i = 0; i < count; i++)
{
df = 0; tf = 0;
printf("%s\n", fa.name);
fp = fopen(fa.name, "r");
if (fp == NULL)
printf("File1 can not be opened.\n");
else
{
ct = fgetc(fp);
while (ct != EOF)
{
if (ct == '\n')
{
temp[j] = '\0';
j = 0;
if (strcmp(temp, tt[i]) == 0)
{
flag = 1;
tf++;
}
}
else
{
temp[j] = ct;
j++;
}
ct = fgetc(fp);
}
fclose(fp);
if (flag > 0)
df++;
if (tf > max)
max = tf;
}
vector = calculate(tf, df, max); //计算权重,返回结果用vector保存
strcpy(vwords[i].word, tt[i]);
vwords[i].v = vector;
printf("SUCCEED %d\n", i + 1);
}
if ((out = fopen(wname, "w")) == NULL)
{
printf("Open file error!\n");
exit(0);
}
for (i = 0; i < count; i++) //保存所有特征词条
fprintf(out, "%d %s %lf\n", i + 1, vwords[i].word, vwords[i].v);
fclose(out);
} while (_findnext(fHandle, &fa) == 0);
system("pause");
_findclose(fHandle); 展开
typedef struct
{
char word[36];
double v;
}WORD;
WORD vwords[SUM]; //存放(词条,权重)数组
FILE *fp, *out;
char tt[][40];//一个词典数组
char temp[36], words[SUM][36], ct; //temp读取提取特征中的一个词,words保存总的特征词条
int i, j, k, m, df, tf, count; //count为特征词条总数
count = 0; df = 0; tf = 0; i = 0; j = 0; k = 0;
i = 0; j = 0;
double vector; //暂存权重值
int max = 0; //出现次数最多的词
int flag = 0;
char *h[1] = { "f:\\fenci\\fenci\\*.txt" }; //某类别总文本的存放位置
char r1[] = "f:\\fenci\\fenci\\提取特征向量集\\特征.txt"; //提取的总特征存放位置
char r2[100];
char wname[] = "f:\\fenci\\fenci\\权重向量集\\特征.txt"; //输出所有(特征,权重)对的位置
count = strlen(*tt);
fHandle = _findfirst(h[0], &fa);
if (fHandle == -1L)
{
printf("当前目录下没有txt文件\n");
return 0;
}
else
do
{
for (i = 0; i < count; i++)
{
df = 0; tf = 0;
printf("%s\n", fa.name);
fp = fopen(fa.name, "r");
if (fp == NULL)
printf("File1 can not be opened.\n");
else
{
ct = fgetc(fp);
while (ct != EOF)
{
if (ct == '\n')
{
temp[j] = '\0';
j = 0;
if (strcmp(temp, tt[i]) == 0)
{
flag = 1;
tf++;
}
}
else
{
temp[j] = ct;
j++;
}
ct = fgetc(fp);
}
fclose(fp);
if (flag > 0)
df++;
if (tf > max)
max = tf;
}
vector = calculate(tf, df, max); //计算权重,返回结果用vector保存
strcpy(vwords[i].word, tt[i]);
vwords[i].v = vector;
printf("SUCCEED %d\n", i + 1);
}
if ((out = fopen(wname, "w")) == NULL)
{
printf("Open file error!\n");
exit(0);
}
for (i = 0; i < count; i++) //保存所有特征词条
fprintf(out, "%d %s %lf\n", i + 1, vwords[i].word, vwords[i].v);
fclose(out);
} while (_findnext(fHandle, &fa) == 0);
system("pause");
_findclose(fHandle); 展开
1个回答
展开全部
试试这样 px=(touch->getLocation()).x;
px=(touch->getLocation())->x;
不行的话就是 touch->getLocation()这个指针的结构问题了
px=(touch->getLocation())->x;
不行的话就是 touch->getLocation()这个指针的结构问题了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |