#include #include #include #include #include #include #include using namespace std; int stringToInteger(string s) { istringstream buffer(s); int some_int; buffer >> some_int; return some_int; } void loadInput(const char * fileName, vector & input) { ifstream sr (fileName); string line; if(sr.is_open()) { while(getline(sr , line )) { input.push_back(line); } sr.close(); } else { cout<<"Unable to read "< & currInput) { istringstream iss(s); currInput.clear(); do { string sub; iss >> sub; currInput.push_back(sub); } while (iss); currInput.pop_back(); } string getTranslation(int index, vector < pair > > & gCepts , vector & currF , map & singletons) { string translation = ""; vector fSide = gCepts[index].second; vector :: iterator iter; for (iter = fSide.begin(); iter != fSide.end(); iter++) { if (iter != fSide.begin()) translation += "^_^"; translation+= currF[*iter]; } if(singletons.find(translation)==singletons.end()) { return "_TRANS_" + gCepts[index].first + "_TO_" + translation + " "; } else { return "_TRANS_SLF_ "; } } int closestGap(map gap,int j1, int & gp) { int dist=1172; int value=-1; int temp=0; gp=0; int opGap=0; map :: iterator iter; iter=gap.end(); do { iter--; //cout<<"Trapped "<first<first==j1 and iter->second=="Unfilled") { opGap++; gp = opGap; return j1; } if(iter->second =="Unfilled") { opGap++; temp = iter->first - j1; if(temp<0) temp=temp * -1; if(dist>temp && iter->first < j1) { dist=temp; value=iter->first; gp=opGap; } } } while(iter!=gap.begin()); //cout<<"Out"< > > & gCepts, set & targetNullWords, vector & currF, map & singletons) { int fl = 0; int i = 0; // Current English string position int j = 0; // Current French Position int N = gCepts.size(); // Total number of English words int k = 0; // Number of already generate French words int E = 0; // Position after most rightward French word generate so far int j1 = 0; // Next french translation; int Li =0; // Links of word i int Lj=0; // Links of word j map generated; map gap; map :: iterator iter; int gp=0; //vector iterator :: iterF; while (targetNullWords.find(j) != targetNullWords.end()) { cout<<"_INS_"< , set > > & ceptsInPhrase , vector < pair < string , vector > > & gCepts , set & sourceNullWords, vector & currE) { gCepts.clear(); set eSide; set fSide; std::set :: iterator iter; string english; vector germanIndex; int engIndex = 0; int prev; int curr; set engDone; for (int i = 0; i< ceptsInPhrase.size(); i++) { english = ""; germanIndex.clear(); fSide = ceptsInPhrase[i].first; eSide = ceptsInPhrase[i].second; while(engIndex < *eSide.begin()) { // cout< > > & gCepts , vector & currF) { string eSide; vector fSide; for (int i = 0; i < gCepts.size(); i++) { fSide = gCepts[i].second; eSide = gCepts[i].first; cout< "; for (int j = 0; j < fSide.size(); j++) { cout< & eSide , set & fSide , map > & tS , map > & sT) { set :: iterator iter; int sz = eSide.size(); vector t; for (iter = eSide.begin(); iter != eSide.end(); iter++) { t = tS[*iter]; for (int i = 0; i < t.size(); i++) { fSide.insert(t[i]); } } for (iter = fSide.begin(); iter != fSide.end(); iter++) { t = sT[*iter]; for (int i = 0 ; i sz) { getMeCepts(eSide,fSide,tS,sT); } } void constructCepts(vector < pair < set , set > > & ceptsInPhrase, set & sourceNullWords, set & targetNullWords, vector & alignment, int eSize, int fSize) { ceptsInPhrase.clear(); sourceNullWords.clear(); targetNullWords.clear(); vector align; std::map > sT; std::map > tS; std::set eSide; std::set fSide; std::set :: iterator iter; std :: map > :: iterator iter2; std :: pair < set , set > cept; int src; int tgt; ceptsInPhrase.clear(); for (int j=0; jfirst); getMeCepts(eSide, fSide, tS , sT); for (iter = eSide.begin(); iter != eSide.end(); iter++) { iter2 = tS.find(*iter); tS.erase(iter2); } for (iter = fSide.begin(); iter != fSide.end(); iter++) { iter2 = sT.find(*iter); sT.erase(iter2); } cept = make_pair (fSide , eSide); ceptsInPhrase.push_back(cept); } } int main(int argc, char * argv[]) { vector e; vector f; vector a; vector singletons; map sTons; vector < pair < set , set > > ceptsInPhrase; vector < pair < string , vector > > gCepts; set sourceNullWords; set targetNullWords; vector currE; vector currF; vector currA; loadInput(argv[4],singletons); for(int i=0; i>xx; */ } return 0; }