void asferencodestr::pairwiseCompAndExtractPatterns()
{
		int MAXENCSTRLEN=28;
		std::vector<string> encstr_vec;
		ifstream input;
		char line[500];
		string encstrpath(asferroot);
		encstrpath.append("/asfer.enterprise.encstr");
		input.open(encstrpath.c_str(), ifstream::in);
		while (!input.eof())
		{
			input.getline(line,256);
			cout<<"line = "<<line<<endl;
			if(strcmp(line,"") != 0)
			{
				string encstr(line);
				encstr_vec.push_back(encstr);
			}
			else
				break;
		}

		for(int i=0;i < encstr_vec.size();i++)
		{
			for(int k=0; k < encstr_vec.size();k++)
			{
				cout<<"=================================================="<<endl;
				cout<<"pair ("<<encstr_vec[i]<<","<<encstr_vec[k]<<")"<<endl;
				string extPat = extractPattern(encstr_vec[i], encstr_vec[k]);
				cout<<"pair ("<<i<<","<<k<<") has the common pattern:"<<extPat<<endl;
				cout<<"=================================================="<<endl;

			}
		}

		cout<<"============================================================================================================================="<<endl;
		cout<<"For each of the pairs of encoded strings, distance between them is computed (by an algorithm described in Grafit Course Notes - course_material/ComputerScienceMiscellaneous/ComputerScienceMiscellaneous_CourseNotes.txt) and sum of these distances is printed"<<endl;
		cout<<"============================================================================================================================="<<endl;
		int number_of_ones=0;	
		long double sum_distance=0.0;
		long double sum_distance_bit=0.0;
		for(int i=0;i < MAXENCSTRLEN;i++)
		{
			//cout<<"bit index = "<<i<<endl;
			for(std::vector<string>::iterator it=encstr_vec.begin(); it != encstr_vec.end(); it++)
			{
				//cout<<"(*it)[i] = "<<(*it)[i]<<endl;
				if((*it)[i] == '1')
				{
					number_of_ones += 1;
				}
				sum_distance_bit = combination(MAXENCSTRLEN,2) - (combination(number_of_ones,2) + combination(MAXENCSTRLEN-number_of_ones,2)); 
				sum_distance += sum_distance_bit;
				//cout<<"sum_distance for bit index = "<<sum_distance<<endl;
				number_of_ones=0;
			}
		}
		cout<<"Sum of pairwise distance = "<<sum_distance<<endl;
		cout<<"========================================================="<<endl;
}
void asferencodestr::powerSetExtractPatterns(std::vector<std::string> subsetvec)
{
	cout<<"================================================="<<endl;
	cout<<"powerSetExtractPatterns(): subset size = "<<subsetvec.size()<<endl;
	string prev = subsetvec[0];
	for(int next=1;next < subsetvec.size();next++)
	{
		//prev = strcomp(prev,subsetvec[next]);
		prev = extractPattern(prev,subsetvec[next]);
	}
	cout<<"powerSetExtractPatterns(): subset pattern ="<<prev<<endl;
	cout<<"================================================="<<endl;
}
inline void
RegexPatternListMatcher::compile()
{
  size_t len = m_expr.size();
  size_t index = 0;
  size_t subHead = index;

  while (index < len) {
    subHead = index;

    if (!extractPattern(subHead, &index))
      BOOST_THROW_EXCEPTION(RegexMatcher::Error("Compile error"));
  }
}
void asferencodestr::allCompAndExtractPatterns()
{
	std::vector<string> enchoro_vec;
	ifstream input;
	char line[256];
	string encstrpath(asferroot);
	encstrpath.append("/asfer.enterprise.encstr");
	input.open(encstrpath.c_str(), ifstream::in);
	while (!input.eof())
	{
		input.getline(line,256);
		string enchorostr(line);
		enchoro_vec.push_back(enchorostr);
	}
	
	string prev = enchoro_vec[0];
	for(int next=1;next < enchoro_vec.size();next++)
	{
		//prev = strcomp(prev,enchoro_vec[next]);
		prev = extractPattern(prev,enchoro_vec[next]);
	}
	cout<<"allCompAndExtractPatterns(): prev ="<<prev<<endl;
	cout<<"================================================="<<endl;
}