[Solved] Try to answer some boolean queries using Term-Document-Incidence-Matrix [closed]


Your problem is in this line: (ProcessFiles function)

String[] termsCollection = RemoveStopsWords(file.ToUpper().Split(' '));

you’re splitting the name of the file and not its content
That’s why you have no search results

you should do something like this instead:

String[] termsCollection = RemoveStopsWords(File.ReadAllText(file).ToUpper().Split(' '));

Now change your TermDocMatrix constructor:

public TermDocMatrix(string IndexPath,string FileName)
{
    if (!Directory.Exists(IndexPath)) Directory.CreateDirectory(IndexPath);
    LogManager.Configure(System.IO.Path.Combine(_Path, _FileName + ".txt"), false);
    // read all files
    LoadFiles();
}

And your LoadFiles function:

private void LoadFiles()
{
    int count = 0;

    if (File.Exists(System.IO.Path.Combine(_Path, _FileName + ".txt")) == false)
        return;
    // load words
    string b = File.ReadAllText(System.IO.Path.Combine(_Path, _FileName + ".txt"));

    .....
}

28

solved Try to answer some boolean queries using Term-Document-Incidence-Matrix [closed]