Skip to content

Commit

Permalink
Added set intersection instead of addition in findFreeVariables
Browse files Browse the repository at this point in the history
  • Loading branch information
samidhtalsania committed Jan 12, 2017
1 parent d37b6d7 commit 2391482
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/lpmln2wc_src/lpmln2wc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ set<string> findVariables(const string& head){
set<string> findFreeVariables(const string& head,const string& body){
set<string> s = findVariables(head);
set<string> s1 = findVariables(body);
s.insert(s1.begin(), s1.end());
return s;
set<string> intersect;
set_intersection(s.begin(), s.end(), s1.begin(), s1.end(),inserter(intersect, intersect.begin()));
// s.insert(s1.begin(), s1.end());
return intersect;
// s.insert(s1.begin(), s1.end());
// return s;
}


Expand Down Expand Up @@ -181,8 +185,9 @@ int main(int argc, char **argv){
split(splitVecSpace, splitVec[0], is_any_of(" "), token_compress_on);
//Process soft rules of form W H.
try{
float floatVal = stof(splitVecSpace[0]);
if(isinf(floatVal) || isnan(floatVal)) throw std::runtime_error("inf/nan error");
std::string::size_type sz;
float floatVal = stof(splitVecSpace[0],&sz);
if(isinf(floatVal) || isnan(floatVal) || sz != splitVecSpace[0].length()) throw std::runtime_error("inf/nan error");

weight = (int)floatVal;

Expand Down

0 comments on commit 2391482

Please sign in to comment.