Skip to content

Instantly share code, notes, and snippets.

@okanon
Last active August 5, 2020 01:43
Show Gist options
  • Save okanon/a69cdb13f4fdceeea8d3eb4d06d49de2 to your computer and use it in GitHub Desktop.
Save okanon/a69cdb13f4fdceeea8d3eb4d06d49de2 to your computer and use it in GitHub Desktop.
Eat MeCab-Java built on Ubuntu and macOS

Eat MeCab-Java built on Ubuntu 20.04 and macOS Catalina

How to Build

MeCab

wget "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7cENtOXlicTFaRUE" -O mecab-0.996.tar.gz

MeCab Dictionary (IPA)

MeCab-Java

How to Use

Scala (sbt)

--- Makefile 2020-08-05 07:57:26.703600861 +0900
+++ Makefile_macOS 2020-08-05 07:58:51.705329200 +0900
@@ -12,7 +12,7 @@ INC=`mecab-config --cflags` -I$(INCLUDE)
all:
$(CXX) -O3 -c -fpic $(TARGET)_wrap.cxx $(INC)
- $(CXX) -shared $(TARGET)_wrap.o -o lib$(TARGET).so $(LIBS)
+ $(CXX) -dynamiclib $(TARGET)_wrap.o -o lib$(TARGET).dylib $(LIBS)
$(JAVAC) $(PACKAGE)/*.java
$(JAVAC) test.java
$(JAR) cfv $(TARGET).jar $(PACKAGE)/*.class
@@ -21,7 +21,7 @@ test:
env LD_LIBRARY_PATH=. $(JAVA) test
clean:
- rm -fr *.jar *.o *.so *.class $(PACKAGE)/*.class
+ rm -fr *.jar *.o *.dylib *.so *.class $(PACKAGE)/*.class
cleanall:
- rm -fr $(TARGET).java *.cxx
+ rm -fr $(TARGET).java *.cxxmecab-java
import java.io.File
import org.chasen.mecab.Tagger
object MeCabMain extends App {
val lib: File = new File("lib/" + System.mapLibraryName("MeCab"));
System.load(lib.getAbsolutePath());
val t = new Tagger
println(t.parse("パンケーキ食べたい"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment