forked from NicoleJAVA/Vector-Space-Model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
185 lines (135 loc) · 5.89 KB
/
README
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
Github\Vector-Space-Model\README
/************************************************************
README in Github local repository directory !
************************************************************/
2013.10.22 >> Week >> day
蟲 [ B U G ]
[ Where ] : doctxtname.cpp >> Ver. 24
[ B U G ] cannot pass objects of non-POD type 'struct std::string' through '...'
[ Solution ] :
Wrong Code :
snprintf( titleBuf, TXT_NAME_LEN, "%d%s", 20, txtSuffixTitle );
Correct Code :
snprintf( titleBuf, TXT_NAME_LEN, "%d%s", 20, txtSuffixTitle.c_str() );
---
蟲 [ B U G ]: sort_firstDict.cpp
base operand of `->' has non-pointer type `std::string'
[ Solution ]
Wrong : value->data.c_str()
Correct:value.c_str()
( declaration is " std::string value; " )
---
蟲 [ B U G ]: in compareTerm.cpp :
Only 3 character of std::string will be copied into term1 and term2.
[ Solution ] :
Wrong Code :
#define CMP_LEN 100
Correct Code :
#define CMP_LEN 1000
================================================================
2013. 10. 21 >> Week 7 >> Monday
蟲 [ B U G ]:
currentPtr = *sPtr; << SOMETHING WRONG !
[ Solution ] :
很酷唷, 這次改成是在實際引數反而是用 &。
這次形式引數反而是用 * 唷。
實際引數 : insertNode( &dictNode, stemByPorter[ i ] ); /* 這是在 main() 內的實際呼叫 */
形式引數 : void insertNode( ListNodePtr *sPtr, std::string value ){}
補充說明 : typedef struct ListNode* ListNodePtr
---
蟲 [ B U G ] :
[ Where ] : dictCpp.cpp ( about Ver. 11 )
[ B U G ] : dictCpp.cpp : no matching function for call to `strncpy(std::string&, const char*, int)'
[ B U G ] : invalid conversion from `const char*' to `char*'
WRONG CODE :
strncpy( tail->nextPtr->data, h2->data.c_str(), MAX_STR_LEN );
CORRECT CODE :
strncpy( const_cast<char*>(tail->nextPtr->data.c_str()), h2->data.c_str(), MAX_STR_LEN );
---
蟲 [ B U G ] :
[ Where ] : sort_firstDict.cpp
[ B U G ] : I printf each line. I found that strncmp( newPtr->data, value, MAX_STR_LEN ) will CRASH.
[ Solution ] :
tutorial : http://stackoverflow.com/questions/1623769/is-there-any-safe-strcmp/1623778#1623778
<<
take a look, what the US DHS National Cyber Security Division recommends on this matter:
Ensure that strings are null terminated before passing into strcmp. This can be enforced by always placing a \0 in the last allocated byte of the buffer.
char str1[] ="something";
char str2[] = "another thing";
/* In this case we know strings are null terminated. Pretend we don't. */
str1[sizeof(str1)-1] = '\0';
str2[sizeof(str2)-1] = '\0';
/* Now the following is safe. */
if (strcmp(str1, str2)) { /* do something */ } else { /* do something
>> // End tutorial
HOWEVER,
array[ ] is more like a "C-stlye" thing.
and many tutorials sugget that : Don't use array[]; instead, use std::string stringname
蟲[ B U G ]:
no matching function for call to `strncmp(std::string&, char*&, int)'
[ Solution ] :
( PPS. from now on, I start my std::string life-style ! )
Wrong code :
strcmp (word1, word2)
Corrct code :
x = strcmp(word1.c_str(), word2.c_str());
---
蟲 [ B U G ]: sort_firstDict_ver_string.cpp
FINALLY, it's not because of the usage of strncmp( ) .
It's because adding the first listNode is a SPECIAL CASE !!!!
So Nicole adds these lines of code :
if( previousPtr != NULL ){ /* If currentPtr->data is the first node, this node is empty, and strncmp() will crash becuse this is NULL */
termOrder = strncmp( value.c_str(), currentPtr->data.c_str(), value.size());
}
//printf("\nHello insert >> termOrder = strcmp( ) " );
//printf("\nHello insert >> termOder is : %d.", termOrder );
/* loop to find the correct location in the list */
while ( currentPtr != NULL && termOrder > 0 && previousPtr != NULL ) {
IMPORTANT ! If currentPtr->data is the first node, this node is empty, and strncmp() will CRASH becuse this is NULL.
/*==========================================================================*/
2013. 10. 20 >> Week 6 >> Sunday
when migrating from dev cpp to visual studio c++,
put this into >> project properties >> C/C++ >> other include directory : C:\Dev-Cpp\include
---
蟲 [ B U G ] :
fatal error C1021: invalid preprocessor command 'include_next',
[ Solution ] :
In control pannel, msvc's include should be prior to mingw's include.
C:/Program Files/Microsoft Visual Studio/VC98/atl/include;C:/Program Files/Microsoft Visual Studio/VC98/mfc/include;C:/Program Files/Microsoft Visual Studio/VC98/include;C:/Modeltech_6.3f/include;C:/Program Files/Microsoft DirectX 9.0 SDK (February 2005)/Samples/C++/DirectShow/Samples/C++/DirectShow/BaseClasses;C:/Modeltech_6.3f/gcc-3.3.1-mingw32/include
( tutorial : http://blog.csdn.net/aboy85/article/details/4208915 )
---
蟲 [ B U G ] :
when I do rmvStop() in a loop in main() many times, at first, the program runs well.
but in the 4-th loop, main() can't recive a succussful-return from rmvStop().
[ Solution ] :
So I print out some codes in rmvStop().
And then I observed that,
...
stopNum is : 319 .
tokenSize is : 300 .
...
stopNum is : 638 .
tokenSize is : 300 .
...
stopNum is : 957 .
tokenSize is : 300 .
Therefore, in txtToArray(), I must reset stopNum to zero.
SO COOL !!!!!!! The bug is fixed !!!
---
蟲 [ B U G ] :
I need to press "Enter" key on keyboard 1095 times for the for-loop in main( ) to loop 1095 times.
Solution :
Yeah ! Nicole debugs successfully by herself !
Discard this line in porter.cpp : system("PAUSE");
---
蟲 [ B U G ] :
Too many open files
In iteration xxxx i get an "Too many open files" error when opening the xxxx-th file.
Solution :
Yeah ! Nicole debugs successfully by herself !
Nicole must add this line of code in function txtToArray( ) :
fclose(txtFile);
Ha~ Don't forget that txtFile is declared 1095 times because everytime when txtToArray( ) is entered,
this line will declare again txtFile : void txtToArray( FILE *txtFile, char twoDimArr[][ MAX_STR_LEN ], int & wordCount )
Ha~ Just be careful !
---