forked from NicoleJAVA/Vector-Space-Model
-
Notifications
You must be signed in to change notification settings - Fork 0
xingfeT/Vector-Space-Model
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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 ! ---
About
IR-HW-PA-2-Vector-Space-Model
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published