commit 88ec559b38ab4dde69196a7db075126af65f7175 Author: Tanmai Khanna Date: Mon Jul 29 20:50:01 2019 +0530 Adding score parsing from external xml file diff --git a/src/parse_ref.cc b/src/parse_ref.cc index 0f2d862..865dae0 100644 --- a/src/parse_ref.cc +++ b/src/parse_ref.cc @@ -21,7 +21,6 @@ void print_tags(vector< wstring > input) } } -// g++ parse_ref.cc -I /opt/local/include/libxml2/ -L /usr/lib -lxml2 -lz -lpthread -lm vector ParseRef::parseTags (wstring tags) { vector temp_tags_list; @@ -218,6 +217,16 @@ void ParseRef::parsePatterns (xmlDocPtr doc, xmlNodePtr cur, wstring markable_na markables[markable_name].push_back(temp_pattern); } + + else if ((!xmlStrcmp(cur->name, (const xmlChar *)"score"))) + { + Attr = xmlGetProp(cur, (const xmlChar *)"n"); + wstring score_ws = XMLParseUtil::towstring(Attr); + + int score_int = std::stoi(score_ws); + + markable_score[markable_name] = score_int; + } cur = cur->next; diff --git a/src/parse_ref.h b/src/parse_ref.h index a1f8385..b7de48b 100644 --- a/src/parse_ref.h +++ b/src/parse_ref.h @@ -31,6 +31,7 @@ private: unordered_map cats; //cat name mapped to acceptable tag lists unordered_map markables; //markable name mapped to acceptable pattern lists. Also each pattern has a head == 1 + unordered_map markable_score; //markable name mapped to score of markable public: void parseDoc(char *docname); diff --git a/src/score.cc b/src/score.cc index dbf6968..aac2c12 100644 --- a/src/score.cc +++ b/src/score.cc @@ -158,9 +158,9 @@ wstring Scoring::get_antecedent() for(vector::reverse_iterator it=antecedent_list.rbegin();it!=antecedent_list.rend();++it) //read it in reverse so that we read from furthest to nearest { - //cerr << "\n" << (*it).LU.id << ": "; - //wcerr << (*it).LU.wordform; - //cerr << " : " << (*it).score << "\n"; + cerr << "\n" << (*it).LU.id << ": "; + wcerr << (*it).LU.wordform; + cerr << " : " << (*it).score << "\n"; if((*it).score >= final_antecedent.score) //picking the highest scored and latest added (most recent) antecedent final_antecedent = (*it);