Skip to content

Commit 01b5adc

Browse files
Add Mecab as a cpp file (#21)
* delete mecab script * add mecab-based parser * rename files * update readme
1 parent 8cd7d1b commit 01b5adc

11 files changed

+233
-215
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ because it's easy to make a mistake during the process
3434
and end up with a broken install.
3535

3636
1) To build the `gd-tools` you need to install `xmake` and `gcc` (13.1 and newer).
37+
1) Install `mecab` (`mecab-git` from the AUR).
3738
2) Run `./quickinstall.sh`.
3839

3940
**Note:** You can run `./quickinstall.sh --local`

src/gd-mecab.sh

-205
This file was deleted.

src/main.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#include "anki_search.h"
2020
#include "echo.h"
2121
#include "images.h"
22-
#include "marisa.h"
22+
#include "marisa_split.h"
2323
#include "massif.h"
24+
#include "mecab_split.h"
2425
#include "precompiled.h"
2526

2627
static constexpr std::string_view help_text = R"EOF(usage: {} ACTION [OPTIONS]
@@ -31,6 +32,7 @@ ACTIONS
3132
massif Search word on Massif.
3233
images Search images on Bing.
3334
marisa Split search string using MARISA.
35+
mecab Split search string using Mecab.
3436
strokeorder Show stroke order of a word.
3537
handwritten Display the handwritten form of a word.
3638
@@ -91,6 +93,8 @@ auto take_action(std::span<std::string_view const> const args) -> void
9193
return images(rest);
9294
case "gd-marisa"_h:
9395
return marisa_split(rest);
96+
case "gd-mecab"_h:
97+
return mecab_split(rest);
9498
}
9599

96100
// Help requested explicitly.
@@ -111,6 +115,8 @@ auto take_action(std::span<std::string_view const> const args) -> void
111115
return images(rest);
112116
case "marisa"_h:
113117
return marisa_split(rest);
118+
case "mecab"_h:
119+
return mecab_split(rest);
114120
}
115121

116122
// Couldn't determine command.

src/marisa.cpp src/marisa_split.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ auto find_dic_file() -> std::filesystem::path
8989
static auto const locations = {
9090
// possible .dic locations
9191
std::filesystem::path("/usr/share/gd-tools/marisa_words.dic"),
92-
std::filesystem::path(std::getenv("HOME")) / ".local/share/gd-tools/marisa_words.dic"
92+
user_home() / ".local/share/gd-tools/marisa_words.dic",
9393
};
9494
for (auto const& location: locations) {
9595
if (std::filesystem::exists(location) and std::filesystem::is_regular_file(location)) {

src/marisa.h src/marisa_split.h

File renamed without changes.

0 commit comments

Comments
 (0)