【发布时间】:2013-11-30 18:48:58
【问题描述】:
我尝试编写一个从名为 aisha 的文本文件中读取的代码
This is a new file I did it for as a trial for university
but it worked =)
Its about Removing stopwords from the file
and apply casefolding to it
It tried doing that many times
and finally now I could do now
然后代码将读取的文本存储在一个数组中,然后从中删除停用词 但现在我需要做折叠步骤 这段代码逐字读取文本文件的问题
我想逐个字符地读取它,这样我就可以将大小写折叠应用于每个字符 有没有办法让代码按字符读取aisha文件char?
#include <iostream>
#include <string>
#include <fstream>
int main()
{
using namespace std;
ifstream file("aisha.txt");
if(file.is_open())
{
string myArray[200];
for(int i = 0; i < 200; ++i)
{
file >> myArray[i];
if (myArray[i] !="is" && myArray[i]!="the" && myArray[i]!="that"&& myArray[i]!="it"&& myArray[i]!="to"){
cout<< myArray[i]<<" ";
}
}
}
system("PAUSE");
return 0;
}
【问题讨论】:
-
你的数组应该是一个字符数组而不是字符串。
-
好的,但是停用词的部分不起作用也许我会制作另一个数组
-
@AishaAhmedAhmed 你对使用向量好吗?如果您对此感到满意,我有一个使用向量的答案。
-
Cygwinnian 不,我还是个初学者