-
Notifications
You must be signed in to change notification settings - Fork 0
/
Document.cpp
69 lines (60 loc) · 1008 Bytes
/
Document.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "Document.h"
#include<boost/foreach.hpp>
Document::Document(std::string& filename,Toker* t)
:file(filename),
toker(t)
{
docName=filename.substr(filename.find_last_of("/\\")+1);
docID=global_doc_id;
++global_doc_id;
}
Document::~Document()
{
}
bool
Document::isDocValid()
{
if (toker)
return toker->getIsValid();
return false;
}
LinkedList&
Document::getTokenList()
{
return tokens;
}
unsigned int&
Document::getDocID()
{
return docID;
}
std::string&
Document::getDocName()
{
return docName;
}
bool
Document::processDocument()
{
return (toker->tokenize(file,tokens,attributeMap));
}
int
Document::getTermCountAttribute(std::string& term)
{
TermAttributes* ta=attributeMap[term];
if(ta)
return(ta->getCount());
else
return 0;
}
void
Document::printDetails()
{
std::cout<<"Doc Name: "<<docName<<"\n";
std::cout<<"Doc ID: "<<docID<<"\n";
BOOST_FOREACH(std::string t,tokens)
{
std::cout<<"Doc Token (sample): "<<t<<"\n";
break;
}
}