nishant94 commented on code in PR #64667:
URL: https://github.com/apache/doris/pull/64667#discussion_r3629535162


##########
build.sh:
##########
@@ -465,6 +465,12 @@ if [[ ! -f 
"${DORIS_THIRDPARTY}/installed/lib/${LAST_THIRDPARTY_LIB}" ]]; then
     fi
 fi
 
+MECAB_IPADIC_DIR="${DORIS_THIRDPARTY}/installed/share/mecab-ipadic-2.7.0-20250920"

Review Comment:
   Fixed.



##########
be/src/tools/kuromoji_build_dict.cpp:
##########
@@ -0,0 +1,150 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Offline tool: compile a UTF-8 mecab-ipadic source directory into the four
+// kuromoji .bin files consumed by KuromojiDictionary.
+//   usage: kuromoji_build_dict <ipadic_src_dir> <out_dir>
+// Built on demand via `ninja kuromoji_dict`; never linked into doris_be.
+
+#include <cstdio>
+#include <filesystem>
+#include <fstream>
+#include <functional>
+#include <sstream>
+#include <string>
+#include <string_view>
+#include <system_error>
+#include <unordered_map>
+#include <utility>
+#include <vector>
+
+#include "common/status.h"
+#include 
"storage/index/inverted/analyzer/kuromoji/dict/kuromoji_dictionary_builder.h"
+#include 
"storage/index/inverted/analyzer/kuromoji/dict/kuromoji_ipadic_parser.h"
+
+namespace fs = std::filesystem;
+using namespace doris::segment_v2::inverted_index::kuromoji;
+using doris::Status;
+
+namespace {
+
+bool read_file(const std::string& path, std::string* out) {
+    std::ifstream in(path, std::ios::binary);
+    if (!in) {
+        std::fprintf(stderr, "cannot open %s\n", path.c_str());
+        return false;
+    }
+    std::ostringstream ss;
+    ss << in.rdbuf();
+    *out = ss.str();
+    return true;
+}
+
+void for_each_line(const std::string& content, const 
std::function<void(std::string_view)>& fn) {
+    std::size_t i = 0;
+    while (i < content.size()) {
+        auto nl = content.find('\n', i);
+        if (nl == std::string::npos) {
+            nl = content.size();
+        }
+        std::string_view line(content.data() + i, nl - i);
+        if (!line.empty() && line.back() == '\r') {
+            line.remove_suffix(1);
+        }
+        if (!line.empty()) {
+            fn(line);
+        }
+        i = nl + 1;
+    }
+}
+
+} // namespace
+
+int main(int argc, char** argv) {
+    if (argc < 3) {
+        std::fprintf(stderr, "usage: %s <ipadic_src_dir> <out_dir>\n", 
argv[0]);
+        return 2;
+    }
+    const std::string src = argv[1];
+    const std::string out = argv[2];
+    std::error_code ec;
+    fs::create_directories(out, ec);
+
+    // --- system dictionary: group all *.csv lexicon rows by surface 
(homographs) ---
+    std::unordered_map<std::string, std::vector<BuilderWord>> by_surface;
+    std::size_t lexicon_rows = 0;
+    for (const auto& entry : fs::directory_iterator(src)) {

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to