#include "tToken.h" #include #include #include #include #include using namespace std; void tToken::print(tTokenFormat format) { switch (format) { case STRING: printStringToken(pair()); break; case CANDC: printCandCToken(pair()); break; case CONLL: printConllToken(pair()); break; case TNT: printTnTToken(pair()); break; case PET: printPETToken(); break; case FSC: printFSCToken(pair()); break; } } const char *tToken::separator(tTokenFormat format) { switch (format) { case STRING: return " "; break; case CANDC: return " "; break; case TNT: return "\n"; break; case CONLL: return "\n"; break; case PET: return " "; break; case FSC: return "\n"; break; } return " "; } void tToken::print(tTokenFormat format, pair stag) { switch (format) { case STRING: printStringToken(stag); break; case CANDC: printCandCToken(stag); break; case CONLL: printConllToken(stag); break; case TNT: printTnTToken(stag); break; case PET: printPETToken(); break; case FSC: printFSCToken(stag); break; } } void tToken::printStringToken(pair stag) { cout << _surface; if (!stag.first.empty()) { cout << "|" << stag.first << "|" << stag.second; } } void tToken::printCandCToken(pair stag) { cout << _surface; if (!_tags.empty()) { cout << "|" << _tags[0]; } if (!stag.first.empty()) { cout << "|" << stag.first; } } void tToken::printConllToken(pair stag) { cout << _surface; if (!_tags.empty()) { cout << "\t"; for (int i=0; i < _tags.size(); ++i) { double prob; istringstream(_probs[i]) >> prob; cout << " \"" << _tags[i] << "\" " << fixed << setprecision(4) << prob; } } if (!stag.first.empty()) { cout << "\t" << stag.first; } } void tToken::printTnTToken(pair stag) { cout << _surface; if (!_tags.empty() && stag.first.empty()) { cout << "\t" << _tags[0]; } if (!stag.first.empty()) { cout << "\t" << stag.first; } //special if (!_tids.empty()) { for (vector::iterator it = _tids.begin(); it != _tids.end(); ++it) { cout << " " << *it; } } } void tToken::printPETToken() { cout << "(" << _id+42 << ", " << _id << ", " << _id+1 << ", <" << _start << ":" << _end << ">, 1, \"" << _surface << "\", 0, \"null\""; if (!_tags.empty()) { cout << ","; for (int i=0; i < _tags.size(); ++i) { double prob; istringstream(_probs[i]) >> prob; cout << " \"" << _tags[i] << "\" " << fixed << setprecision(4) << prob; } } cout << ")"; } void tToken::printFSCToken(pair stag) { cout << "" << endl; cout << "" << endl; cout << "" << endl; cout << "" << _start << "" << endl; cout << "" << _end-1 << "" << endl; if (!_tags.empty()) { cout << "" << endl; cout << "" << endl; cout << ""; for (std::vector::iterator i1 = _tags.begin(); i1 != _tags.end(); ++i1) { cout << "" << *i1 << ""; } cout << "" << endl; cout << ""; for (std::vector::iterator i2 = _probs.begin(); i2 != _probs.end(); ++i2) { double prob; istringstream(*i2) >> prob; cout << "" << fixed << setprecision(4) << prob << ""; } cout << "" << endl; cout << "" << endl << "" << endl; } if (!stag.first.empty()) { cout << "" << endl; cout << "" << endl; cout << "" << stag.first << "" << endl; cout << "" << fixed << setprecision(6) << stag.second << "" << endl; cout << "" << endl << "" << "" << endl; } cout << "" << endl; cout << ""; } void print_header(tTokenFormat format, string &itemno, string &sent, int n) { if (format == STRING) cout << itemno << endl; if (format == FSC) { cout << "" << endl; cout << "" << endl; cout << "" << endl; cout << "" << endl; cout << "" << endl; } if (format == TNT) { cout << "%%" << itemno << endl; } } void print_footer(tTokenFormat format) { if (format == STRING) cout << endl; if (format == PET) cout << endl; if (format == TNT) cout << endl << endl; if (format == CONLL) cout << endl << endl; if (format == CANDC) cout << endl; if (format == FSC) { cout << "" << endl; cout << "" << endl; cout << "" << endl; cout << endl; } } std::string tToken::tag() { if (!_tags.empty()) { return _tags[0]; } else { return std::string(); } } std::string tToken::supertag() { if (!_supertags.empty()) { return _supertags[0]; } else { return std::string(); } }