commit 56d772dd01d824fb28f81e53dde71439af0093f4 Merge: a92163a 11c6d38 Author: Daniel Swanson Date: Fri Jun 11 11:38:04 2021 -0500 Merge branch 'icu' of github.com:apertium/apertium into icu diff --combined apertium/perceptron_spec.h index 5d67748,cf021d1..d51a507 --- a/apertium/perceptron_spec.h +++ b/apertium/perceptron_spec.h @@@ -168,9 -168,9 +168,9 @@@ public #undef X static bool static_constructed; static unsigned char num_opcodes; - static const UString opcode_names[]; - static const UString type_names[]; - static std::map opcode_values; + static const std::string opcode_names[]; + static const std::string type_names[]; + static std::map opcode_values; static std::vector untagged_sentinel; static LexicalUnit token_wordoids_underflow; static LexicalUnit token_wordoids_overflow; @@@ -188,13 -188,14 +188,12 @@@ out << val.boolVal(); break; case STRVAL: - out << val.str().c_str(); + out << val.str(); break; case STRARRVAL: { out << "["; - std::vector &str_arr = val.strArr(); - for (auto& it : str_arr) { - std::vector &str_arr = val.strArr(); - std::vector::const_iterator it = str_arr.begin(); - for (; it != str_arr.end(); it++) { - out << *it; ++ for (auto& it : val.strArr()) { + out << it; } out << "]"; } break; @@@ -204,8 -205,9 +203,8 @@@ case WRDARRVAL: { out << "["; std::vector &wrd_arr = val.wrdArr(); - std::vector::const_iterator it = wrd_arr.begin(); - for (; it != wrd_arr.end(); it++) { - out << *it; + for (auto& it : wrd_arr) { + out << it; } out << "]"; } break; @@@ -228,11 -230,11 +227,11 @@@ type = other.type; switch (type) { case STRVAL: - payload.strval = new UString(*other.payload.strval); + payload.strval = new std::string(*other.payload.strval); break; case STRARRVAL: payload.strarrval = - new std::vector(*other.payload.strarrval); + new std::vector(*other.payload.strarrval); break; case WRDVAL: payload.wrdval = new Morpheme(*other.payload.wrdval); @@@ -258,12 -260,12 +257,12 @@@ payload.bval = bval; type = BVAL; } - StackValue(const UString &strval) { - payload.strval = new UString(strval); + StackValue(const std::string& strval) { + payload.strval = new std::string(strval); type = STRVAL; } - StackValue(const std::vector &strarrval) { - payload.strarrval = new std::vector(strarrval); + StackValue(const std::vector &strarrval) { + payload.strarrval = new std::vector(strarrval); type = STRARRVAL; } StackValue(const Morpheme &wordoid) { @@@ -288,11 -290,11 +287,11 @@@ payload.wrdarrval = new std::vector(wordoids); type = WRDARRVAL; } - StackValue(UString *strval) { + StackValue(std::string* strval) { payload.strval = strval; type = STRVAL; } - StackValue(std::vector *strarrval) { + StackValue(std::vector* strarrval) { payload.strarrval = strarrval; type = STRARRVAL; } @@@ -329,11 -331,11 +328,11 @@@ assert(type == BVAL); return payload.bval; } - UString& str() const { + std::string& str() const { assert(type == STRVAL); return *payload.strval; } - std::vector& strArr() const { + std::vector& strArr() const { assert(type == STRARRVAL); return *payload.strarrval; } @@@ -364,8 -366,8 +363,8 @@@ union StackValueUnion { int intval; bool bval; - UString* strval; - std::vector* strarrval; + std::string* strval; + std::vector* strarrval; Morpheme* wrdval; std::vector* wrdarrval; } payload; @@@ -377,8 -379,8 +376,8 @@@ signed char intbyte : 8; }; Optional coarse_tags; - static UString dot; - std::vector str_consts; + static std::string dot; + std::vector str_consts; std::vector set_consts; mutable std::vector global_results; std::vector global_defns; @@@ -388,10 -390,10 +387,10 @@@ const TaggedSentence &tagged, const Sentence &untagged, int token_idx, int wordoid_idx, UnaryFeatureVec &feat_vec_out) const; - UString coarsen(const Morpheme &wrd) const; + std::string coarsen(const Morpheme &wrd) const; void clearCache() const; int beam_width; - mutable std::map coarsen_cache; + mutable std::map coarsen_cache; private: class MachineStack { std::deque data; @@@ -452,15 -454,15 +451,15 @@@ }; std::deque loop_stack; std::vector slots; - void unimplemented_opcode(UString opstr); + void unimplemented_opcode(std::string opstr); const LexicalUnit& get_token(const Sentence &untagged); const std::vector& tagged_to_wordoids(const TaggedToken &tt); const Morpheme& get_wordoid(const TaggedSentence &tagged); const VMSet& get_set_operand(); int get_int_operand(); unsigned int get_uint_operand(); - const UString& get_str_operand(); - static UString get_tag(const Tag &in); + const std::string& get_str_operand(); + static std::string get_tag(const Tag &in); bool execCommonOp(Opcode op); public: void traceMachineState(); @@@ -476,16 -478,16 +475,16 @@@ int token_idx, int wordoid_idx); }; - struct In : public std::unary_function { + struct In : public std::unary_function { const VMSet& haystack; In(const VMSet &haystack); - bool operator() (const UString &needle) const; + bool operator() (const std::string &needle) const; }; static void appendStr(UnaryFeatureVec &feat_vec, - const UString &tail_str); + const std::string &tail_str); static void appendStr(UnaryFeatureVec::iterator begin, UnaryFeatureVec::iterator end, - const UString &tail_str); + const std::string &tail_str); void serialiseFeatDefn( std::ostream &serialised, const FeatureDefn &defn) const; void deserialiseFeatDefn(