| 80 | class ITopicModel; |
| 81 | |
| 82 | class DocumentBase : public RawDocKernel |
| 83 | { |
| 84 | public: |
| 85 | tvector<Vid> words; // word id of each word |
| 86 | std::vector<uint32_t> wOrder; // original word order (optional) |
| 87 | |
| 88 | DocumentBase(const DocumentBase&) = default; |
| 89 | DocumentBase(DocumentBase&&) = default; |
| 90 | |
| 91 | DocumentBase(const RawDocKernel& o) |
| 92 | : RawDocKernel{ o } |
| 93 | { |
| 94 | } |
| 95 | |
| 96 | DocumentBase(Float _weight = 1, const SharedString& _docUid = {}) |
| 97 | : RawDocKernel{ _weight, _docUid } |
| 98 | { |
| 99 | } |
| 100 | |
| 101 | virtual ~DocumentBase() {} |
| 102 | |
| 103 | virtual RawDoc::MiscType makeMisc(const ITopicModel*) const |
| 104 | { |
| 105 | return {}; |
| 106 | } |
| 107 | |
| 108 | virtual operator RawDoc() const |
| 109 | { |
| 110 | RawDoc raw{ *static_cast<const RawDocKernel*>(this) }; |
| 111 | if (wOrder.empty()) |
| 112 | { |
| 113 | raw.words.insert(raw.words.begin(), words.begin(), words.end()); |
| 114 | } |
| 115 | else |
| 116 | { |
| 117 | raw.words.resize(words.size()); |
| 118 | for (size_t i = 0; i < words.size(); ++i) |
| 119 | { |
| 120 | raw.words[i] = words[wOrder[i]]; |
| 121 | } |
| 122 | } |
| 123 | //raw.misc = makeMisc(); |
| 124 | return raw; |
| 125 | } |
| 126 | |
| 127 | DEFINE_SERIALIZER_WITH_VERSION(0, serializer::to_key("Docu"), weight, words, wOrder); |
| 128 | DEFINE_TAGGED_SERIALIZER_WITH_VERSION(1, 0x00010001, weight, words, wOrder, |
| 129 | rawStr, origWordPos, origWordLen, |
| 130 | docUid |
| 131 | ); |
| 132 | }; |
| 133 | |
| 134 | enum class ParallelScheme { default_, none, copy_merge, partition, size }; |
| 135 | enum class GlobalSampler { train, freeze_topics, inference, size }; |