File size: 826 Bytes
13a8c43 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /* ๊ฐ๋จํ ์์ด ํ ํฌ๋์ด์ โ BM25์ฉ.
* ์๋ฌธ์ํ + ๋น์์ซ์ ๋ถ๋ฆฌ. HotpotQA/MuSiQue ๊ฐ์ ์์ด ์ํค ํ
์คํธ๊ฐ ๋์์ด๋ผ
* ์ด ์ ๋๋ก ์ถฉ๋ถํ๋ค. ํํ์ ๋ถ์์ ๋ฃ์ง ์๋๋ค โ ๋ฃ์ผ๋ฉด baseline์ด ์๋๋ผ
* ์ด๋ฏธ ํ๋๋ ๊ฒ์ด ๋์ด ๋น๊ต๊ฐ ๋ถ๊ณต์ ํด์ง๋ค. */
#pragma once
#include <string>
#include <vector>
#include <cctype>
inline std::vector<std::string> tokenize(const std::string& s) {
std::vector<std::string> out;
std::string cur;
cur.reserve(24);
for (unsigned char c : s) {
if (std::isalnum(c)) {
cur.push_back(static_cast<char>(std::tolower(c)));
} else if (!cur.empty()) {
out.push_back(cur);
cur.clear();
}
}
if (!cur.empty()) out.push_back(cur);
return out;
}
|