From svnnotify ¡÷ sourceforge.jp Tue Jan 20 16:08:21 2009 From: svnnotify ¡÷ sourceforge.jp (svnnotify ¡÷ sourceforge.jp) Date: Tue, 20 Jan 2009 16:08:21 +0900 Subject: [Yamato-svn] =?utf-8?b?W3lhbWF0by1zdm5dIFsyXSAg44K544Kt44Oj44OK?= =?utf-8?b?44Gn44Gu6K2Y5Yil5a2Q566h55CG44Kv44Op44K55LiA5b+c5a6M5oiQ?= Message-ID: <1232435301.442909.15055.nullmailer@users.sourceforge.jp> Revision: 2 http://svn.sourceforge.jp/view?root=yamato&view=rev&rev=2 Author: whiteball Date: 2009-01-20 16:08:21 +0900 (Tue, 20 Jan 2009) Log Message: ----------- ?¹ã??£ã??§ã?è­??å­????????ä¸??å®?? Modified Paths: -------------- trunk/yamato/ident_manager.cpp trunk/yamato/ident_manager.h trunk/yamato/yamato.vcproj Modified: trunk/yamato/ident_manager.cpp =================================================================== --- trunk/yamato/ident_manager.cpp 2008-10-29 13:00:49 UTC (rev 1) +++ trunk/yamato/ident_manager.cpp 2009-01-20 07:08:21 UTC (rev 2) @@ -1,21 +1,82 @@ #include -#include -#include -#include +//#include #include "ident_manager.h" +namespace +{ +using namespace yamato; + +compare_res_t CompareIdent(std::vector &base,std::list::iterator target_begin,std::list::iterator target_end) + { + std::list::iterator target_itr = target_begin, + last_hit = target_end; + std::vector::iterator base_itr = base.begin(), + base_end = base.end(); + int res,num; + + for(num=0;;num++) + { + res = (*target_itr)->GetStr().compare((*base_itr)->GetStr()); + if (res == 0) + { + last_hit = target_itr; + target_itr++; + base_itr++; + if (target_itr == target_end) + { + if (base_itr != base_end) + { + res = 1; + } + } + else if (base_itr == base_end) + { + res = -1; + } + else if ((*target_itr)->GetType() != dummy_token_id) + { + continue; + } + num++; + break; + } + else + { + break; + } + } + + compare_res_t result(new tag_compare_res_t); + result->cmp_res = res; + result->token_num = num; + result->itr = last_hit; + + return result; + } + +inline compare_res_t CompareIdent(std::list &target,std::vector &base) + { + return CompareIdent(base,target.begin(),target.end()); + } + +} + namespace yamato { -using namespace std; -const size_t TABLE_SIZE = 67; -CIdentManager::CIdentManager(void):m_table(new boost::scoped_ptr[TABLE_SIZE]) +namespace {const size_t TABLE_SIZE = 67;} + +CIdentManager::CIdentManager(boost::shared_ptr parent):m_table(new boost::scoped_ptr[TABLE_SIZE]),m_parent(parent) { } CIdentManager::~CIdentManager(void) { } + +CIdentManager::CIdentManager(const CIdentManager&) + { + } size_t CIdentManager::CalcHash(str_t s) { @@ -38,131 +99,176 @@ return *plist; } -void CIdentManager::RegisterIdent(list &/*terms*/) +compare_res_t CIdentManager::SearchIdent(std::list &terms) { - + return SearchIdent(terms.begin(),terms.end()); } - -inline boost::tuple::iterator> CompareIdent(list target,vector base) + +/* +??F +?????????????? +?????X??????????? +?????????????????????p +???????????1???????Ž¯????? +*/ +compare_res_t CIdentManager::SearchIdent(std::list::iterator terms_begin,std::list::iterator terms_end) { - list::iterator target_itr = target.begin(), - target_end = target.end(), - last_hit = target_end; - vector::iterator base_itr = base.begin(), - base_end = base.end(); - int res,num; + TableElement &li = GetList((*terms_begin)->GetStr()); - for(num=0;;num++) + TableElement::iterator itr=li.begin(); + + compare_res_t lasthit(new tag_compare_res_t); + lasthit->cmp_res = -1; + lasthit->token_num = -1; + lasthit->itr = terms_begin; + for(;itr!=li.end();itr++) { - res = (*target_itr)->GetStr().compare((*base_itr)->GetStr()); - if (res == 0) + compare_res_t res = CompareIdent((*itr),terms_begin,terms_end); + + if (res->cmp_res < 0) { - last_hit = target_itr; - target_itr++; - base_itr++; - if (target_itr == target_end) + continue; + } + else if (res->cmp_res == 0) + { + if (res->itr == terms_end) { - if (base_itr != base_end) - { - res = 1; - } + //src????????Ž¯?? + lasthit = res; + break;// to return } - else if (base_itr == base_end) + + //???????? + if (lasthit->token_num <= res->token_num) { - res = -1; + lasthit = res; } - else if ((*target_itr)->GetType() != dummy_token_id) - { - continue; - } - num++; - break; } else { - break; + } } + if((lasthit->itr == terms_end)&&(m_parent != 0))// ?????????? + { + compare_res_t res = m_parent->SearchIdent(terms_begin,terms_end); + //???????? + if (lasthit->token_num <= res->token_num) + { + lasthit = res; + } + } - //return std::pair::iterator>(res,last_hit); - return boost::make_tuple(res,num,last_hit); + return lasthit; } -void CIdentManager::RegisterIdentList(list &terms) +void CIdentManager::RegisterIdentList(std::list &terms) { - //list::iterator terms_itr = terms.begin(); + std::list::iterator terms_begin = terms.begin(); + std::basic_ostringstream buffer; + compare_res_t lasthit; - //str_t str = (*terms_itr)->GetStr(); - //terms_itr++; + while(terms_begin != terms.end()) + { + if ((*terms_begin)->GetType() == dummy_token_id) + { + // Ž¯???????????(????????)??????+ terms_begin++; + continue; + } + + lasthit = SearchIdent(terms_begin,terms.end()); + + if (lasthit->cmp_res != 0) + { + // ?????????1?????Ž¯?? + RegisterIdent(*terms_begin); + terms_begin++; + } + else + { + // ???Ž¯????? + buffer.clear(); + for(std::list::iterator t_itr=terms_begin; t_itr!=lasthit->itr; t_itr++) + { + buffer << (*t_itr)->GetStr(); + } + // ????????1?????? + (*terms_begin)->SetStr(buffer.str()); + (*terms_begin)->SetType(ident); + // ??????(v-v)??? + // begin v---------v end + // +-+-*-+-+-+-+-+-+-*-+-+ + terms_begin++; + terms_begin = terms.erase(terms_begin,lasthit->itr); + } + } + + return; + } + +void CIdentManager::RegisterIdent(std::list &terms) + { TableElement &li = GetList(terms.front()->GetStr()); + TableElement::iterator itr = li.begin(); + for(;itr != li.end();itr++) + { + compare_res_t hit = CompareIdent(*itr,terms.begin(),terms.end()); + if (hit->cmp_res < 0) + { + continue; + } + else if(hit->cmp_res == 0) + { + // ???? + return; + } + else + { + break; + } + } - // not impl. + IdentBlock ib(terms.begin(),terms.end()); + li.insert(itr,ib); - TableElement::iterator itr=li.begin(); - //size_t len = 0; - //basic_ostringstream buffer; + return; + } + +void CIdentManager::RegisterIdent(PToken token) + { + TableElement &li = GetList(token->GetStr()); + TableElement::iterator itr = li.begin(); - //while((itr!=li.end()) && (terms_itr!=terms.end())) - - for(;itr!=li.end();itr++) + for(;itr != li.end();itr++) { - /*if (str.length() < (itr->length()+len)) + int res = itr->at(0)->GetStr().compare(token->GetStr()); + if (res < 0) { - break; - }*/ - //int res = str.compare(0,str.length(),*itr,len,(*itr).length()-len); - boost::tuple::iterator> res = CompareIdent(terms,(*itr)); - - if (res.get<0>() < 0) - { continue; } - else if (res.get<0>() == 0) + else { - /*if ((str.length()+len) == (*itr).length()) + if (res == 0) { - buffer << str; - } - if ((*boost::next(terms_itr))->GetType() == dummy_token_id)// Ž¯????? - { - if (buffer.str().empty()) + if (itr->size() == 1) { - // ????????Ž¯?? + // ??????? + return; } - else - { - // ????????????Ž¯???-> ??????????1?????? - } } - else - { - // ????????? - } - /*str_t str2 = (*terms_itr)->GetStr(); - if ((str.length()+str2.length()) > itr->length()) - { - } - res = str2.compare(str.length()-1,str2.length(),*itr); - /*/ + break; } - else - { - - } - //itr++; - //terms_itr++; } + IdentBlock ib(1); + ib.push_back(token); + li.insert(itr,ib); return; } - -void CIdentManager::RegisterIdent(PToken token) - { - GetList(token->GetStr()); - } /* void CIdentManager::RegisterIdent(str_t str) { Modified: trunk/yamato/ident_manager.h =================================================================== --- trunk/yamato/ident_manager.h 2008-10-29 13:00:49 UTC (rev 1) +++ trunk/yamato/ident_manager.h 2009-01-20 07:08:21 UTC (rev 2) @@ -2,8 +2,8 @@ #include #include #include -#include #include +#include #include #include "token.h" /* @@ -11,24 +11,37 @@ */ namespace yamato { - + struct tag_compare_res_t + { + int cmp_res; + int token_num; + std::list::iterator itr; + }; + typedef boost::shared_ptr compare_res_t; + class CIdentManager { private: typedef std::vector IdentBlock; typedef std::list TableElement; + boost::scoped_array > m_table; + boost::shared_ptr m_parent; inline size_t CalcHash(str_t); inline TableElement &GetList(str_t); inline TableElement &GetList(size_t); + CIdentManager(const CIdentManager&); public: void RegisterIdentList(std::list&); void RegisterIdent(std::list&); void RegisterIdent(PToken); //void RegisterIdent(str_t); - CIdentManager(void); + compare_res_t SearchIdent(std::list::iterator,std::list::iterator); + compare_res_t SearchIdent(std::list&); + + explicit CIdentManager(boost::shared_ptr); ~CIdentManager(void); }; Modified: trunk/yamato/yamato.vcproj =================================================================== --- trunk/yamato/yamato.vcproj 2008-10-29 13:00:49 UTC (rev 1) +++ trunk/yamato/yamato.vcproj 2009-01-20 07:08:21 UTC (rev 2) @@ -42,7 +42,7 @@ MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" - DisableLanguageExtensions="false" + DisableLanguageExtensions="true" DefaultCharIsUnsigned="true" WarningLevel="4" WarnAsError="true" From svnnotify ¡÷ sourceforge.jp Thu Jan 29 17:20:59 2009 From: svnnotify ¡÷ sourceforge.jp (svnnotify ¡÷ sourceforge.jp) Date: Thu, 29 Jan 2009 17:20:59 +0900 Subject: [Yamato-svn] =?utf-8?b?W3lhbWF0by1zdm5dIFszXSAg6K2Y5Yil5a2Q566h?= =?utf-8?b?55CG44Kv44Op44K544Gn44CB5paw6KaP6K2Y5Yil5a2Q55m76Yyy44Gr5LiN?= =?utf-8?b?5YKZ44GM44GC44Gj44Gf44Gu44Gn5L+u5q2j?= Message-ID: <1233217259.590096.20258.nullmailer@users.sourceforge.jp> Revision: 3 http://svn.sourceforge.jp/view?root=yamato&view=rev&rev=3 Author: whiteball Date: 2009-01-29 17:20:59 +0900 (Thu, 29 Jan 2009) Log Message: ----------- è­??å­?????????§ã??°è?è­??å­???²ã?ä¸??????£ã????ä¿?? Modified Paths: -------------- trunk/yamato/ident_manager.cpp Modified: trunk/yamato/ident_manager.cpp =================================================================== --- trunk/yamato/ident_manager.cpp 2009-01-20 07:08:21 UTC (rev 2) +++ trunk/yamato/ident_manager.cpp 2009-01-29 08:20:59 UTC (rev 3) @@ -83,12 +83,12 @@ return s[0] % TABLE_SIZE; } -CIdentManager::TableElement &CIdentManager::GetList(str_t s) +TableElement &CIdentManager::GetList(str_t s) { return GetList(CalcHash(s)); } -CIdentManager::TableElement &CIdentManager::GetList(size_t s) +TableElement &CIdentManager::GetList(size_t s) { TableElement *plist = m_table[s].get(); if (plist == NULL) @@ -99,7 +99,7 @@ return *plist; } -compare_res_t CIdentManager::SearchIdent(std::list &terms) +search_res_t CIdentManager::SearchIdent(std::list &terms) { return SearchIdent(terms.begin(),terms.end()); } @@ -111,16 +111,18 @@ ?????????????????????p ???????????1???????Ž¯????? */ -compare_res_t CIdentManager::SearchIdent(std::list::iterator terms_begin,std::list::iterator terms_end) +search_res_t CIdentManager::SearchIdent(std::list::iterator terms_begin,std::list::iterator terms_end) { TableElement &li = GetList((*terms_begin)->GetStr()); TableElement::iterator itr=li.begin(); - compare_res_t lasthit(new tag_compare_res_t); + search_res_t lasthit(new tag_search_res_t); lasthit->cmp_res = -1; lasthit->token_num = -1; lasthit->itr = terms_begin; + lasthit->insert_itr = li.end(); + for(;itr!=li.end();itr++) { compare_res_t res = CompareIdent((*itr),terms_begin,terms_end); @@ -134,19 +136,23 @@ if (res->itr == terms_end) { //src????????Ž¯?? - lasthit = res; + lasthit->SetCmpRes(res); + lasthit->insert_itr = itr; break;// to return } //???????? if (lasthit->token_num <= res->token_num) { - lasthit = res; + lasthit->SetCmpRes(res); + lasthit->insert_itr = itr; } } else { - + // ?????????????????????? + lasthit->insert_itr = itr; + break; } } if((lasthit->itr == terms_end)&&(m_parent != 0))// ?????????? @@ -155,25 +161,26 @@ //???????? if (lasthit->token_num <= res->token_num) { - lasthit = res; + lasthit->SetCmpRes(res); } } return lasthit; } -void CIdentManager::RegisterIdentList(std::list &terms) +// ????? +void CIdentManager::RegisterIdentList(std::list &terms,bool is_force_dec) { std::list::iterator terms_begin = terms.begin(); std::basic_ostringstream buffer; - compare_res_t lasthit; + search_res_t lasthit; while(terms_begin != terms.end()) { if ((*terms_begin)->GetType() == dummy_token_id) { // Ž¯???????????(????????)??????- terms_begin++; + terms_begin = terms.erase(terms_begin); continue; } @@ -181,9 +188,19 @@ if (lasthit->cmp_res != 0) { - // ?????????1?????Ž¯?? - RegisterIdent(*terms_begin); - terms_begin++; + if (is_force_dec) + { + throw new std::domain_error("???Ž¯??"); + } + else + { + // ?????????1?????Ž¯?? + IdentBlock ib(1); + ib.push_back(*terms_begin); + TableElement &li = GetList((*terms_begin)->GetStr()); + li.insert(lasthit->insert_itr,ib); + terms_begin++; + } } else { @@ -207,35 +224,66 @@ return; } +// "??"????? void CIdentManager::RegisterIdent(std::list &terms) { - TableElement &li = GetList(terms.front()->GetStr()); - TableElement::iterator itr = li.begin(); - - for(;itr != li.end();itr++) + std::list::iterator first = terms.begin(), + last = terms.end(), + sep = first; + for(;sep != last;sep++) { - compare_res_t hit = CompareIdent(*itr,terms.begin(),terms.end()); - if (hit->cmp_res < 0) + if ((*sep)->GetType() == dummy_token_id) { - continue; + break; } - else if(hit->cmp_res == 0) + } + + while(first != last) + { + TableElement &li = GetList((*first)->GetStr()); + TableElement::iterator itr = li.begin(); + + for(;itr != li.end();itr++) { - // ???? - return; + compare_res_t hit = CompareIdent(*itr,first,sep); + if (hit->cmp_res < 0) + { + continue; + } + else if(hit->cmp_res == 0) + { + // ???? + throw new std::domain_error("Ž¯?????o???"); + } + else + { + // ????????? + IdentBlock ib(first,sep); + li.insert(itr,ib); + + if (sep != last) + { + sep++; + } + + break; + } } - else + + first = sep; + + for(;sep != last;sep++) { - break; + if ((*sep)->GetType() == dummy_token_id) + { + break; + } } } - - IdentBlock ib(terms.begin(),terms.end()); - li.insert(itr,ib); - return; } +// ????? void CIdentManager::RegisterIdent(PToken token) { TableElement &li = GetList(token->GetStr()); From svnnotify ¡÷ sourceforge.jp Thu Jan 29 17:27:24 2009 From: svnnotify ¡÷ sourceforge.jp (svnnotify ¡÷ sourceforge.jp) Date: Thu, 29 Jan 2009 17:27:24 +0900 Subject: [Yamato-svn] =?utf-8?b?W3lhbWF0by1zdm5dIFs0XSBUKCkg44CBY29uc3Q=?= =?utf-8?b?44Gu44Gk44GR5b+Y44KM5L+u5q2j44CC5Y+v5aSJ6ZW35byV5pWw44Gu5buD?= =?utf-8?b?5q2i?= Message-ID: <1233217644.181446.25898.nullmailer@users.sourceforge.jp> Revision: 4 http://svn.sourceforge.jp/view?root=yamato&view=rev&rev=4 Author: whiteball Date: 2009-01-29 17:27:24 +0900 (Thu, 29 Jan 2009) Log Message: ----------- T()??onst????????¿®æ­£ã?????·å??°ã?å»?? Modified Paths: -------------- trunk/yamato/string_utility.cpp trunk/yamato/string_utility.h Modified: trunk/yamato/string_utility.cpp =================================================================== --- trunk/yamato/string_utility.cpp 2009-01-29 08:20:59 UTC (rev 3) +++ trunk/yamato/string_utility.cpp 2009-01-29 08:27:24 UTC (rev 4) @@ -6,7 +6,7 @@ namespace string_utility { - str_t normalize_ident(const str_t str) + str_t normalize_ident(const str_t &str) { std::basic_ostringstream output; @@ -17,6 +17,7 @@ output.put(c); if (!is_hiragana(c)) { + i++; break; } } Modified: trunk/yamato/string_utility.h =================================================================== --- trunk/yamato/string_utility.h 2009-01-29 08:20:59 UTC (rev 3) +++ trunk/yamato/string_utility.h 2009-01-29 08:27:24 UTC (rev 4) @@ -2,8 +2,6 @@ #include #include -#include -#include #include "token.h" namespace yamato @@ -11,40 +9,37 @@ namespace string_utility { - inline int_t hex2int(str_t &str) + inline int_t hex2int(const str_t &str) { int_t i; i = wcstol(str.c_str(),0,16); return i; } - inline int_t str2int(str_t &str) + inline int_t str2int(const str_t &str) { return boost::lexical_cast(str); } - inline real_t str2real(str_t &str) + inline real_t str2real(const str_t &str) { return boost::lexical_cast(str); } - inline bool checkchar(char_t ch,int num, ...) + inline bool checkchar(char_t ch,char_t c1) { - va_list ap; - bool result = false; - - va_start(ap, num); - - for(int i=0;i Revision: 5 http://svn.sourceforge.jp/view?root=yamato&view=rev&rev=5 Author: whiteball Date: 2009-01-29 17:32:43 +0900 (Thu, 29 Jan 2009) Log Message: ----------- r3¤Ø¤ÎÄɲà Modified Paths: -------------- trunk/yamato/ident_manager.h Modified: trunk/yamato/ident_manager.h =================================================================== --- trunk/yamato/ident_manager.h 2009-01-29 08:27:24 UTC (rev 4) +++ trunk/yamato/ident_manager.h 2009-01-29 08:32:43 UTC (rev 5) @@ -19,12 +19,23 @@ }; typedef boost::shared_ptr compare_res_t; + typedef std::vector IdentBlock; + typedef std::list TableElement; + struct tag_search_res_t : public tag_compare_res_t + { + void SetCmpRes(const compare_res_t& val) + { + this->cmp_res = val->cmp_res; + this->token_num = val->token_num; + this->itr = val->itr; + } + TableElement::iterator insert_itr; + }; + typedef boost::shared_ptr search_res_t; + class CIdentManager { private: - typedef std::vector IdentBlock; - typedef std::list TableElement; - boost::scoped_array > m_table; boost::shared_ptr m_parent; @@ -33,13 +44,13 @@ inline TableElement &GetList(size_t); CIdentManager(const CIdentManager&); public: - void RegisterIdentList(std::list&); + void RegisterIdentList(std::list&,bool is_force_dec = true); void RegisterIdent(std::list&); void RegisterIdent(PToken); //void RegisterIdent(str_t); - compare_res_t SearchIdent(std::list::iterator,std::list::iterator); - compare_res_t SearchIdent(std::list&); + search_res_t SearchIdent(std::list::iterator,std::list::iterator); + search_res_t SearchIdent(std::list&); explicit CIdentManager(boost::shared_ptr); ~CIdentManager(void);