Guile bindings for MeCab, yet another part-of-speech and morphological analyzer. The bindings link to libmecab and offer a small API for using MeCab.
Using Guix, it is easy to use and install mecab, as we
provide a recipe for mecab, mecab-ipadic (one possible dictionary for Japanese)
and guile-mecab in the
guix directory. For instance, to enter an environment
with all the tools needed to run guile-mecab, you can run, from this repository:
guix environment -L guix --ad-hoc guile guile-mecab mecab-ipadic
Once installed, you can use the bindings by loading
(mecab mecab) in a
- Scheme Procedure: mecab-version Returns MeCab's version number.
The tagger is a global object used to load a dictionary. You can create and remove a tagger by using the following procedures:
Scheme Procedure: mecab-new-tagger [
This procedure creates a new tagger that can be passed to other functions.
argsis a list of strings that represent the arguments passed to mecab. See mecab's help for a list of accepted arguments.
Scheme Procedure: mecab-destroy
This procedure destroys a tagger. Reusing it afterwards will not work, and may lead to a segmentation fault.
Scheme Procedure: mecab-error
Returns a string representing the last error message returned by the tagger.
To analyse a sentence, you can use one of the following procedures.
Scheme Procedure: mecab-parse
Parses a sentence
taggerand returns a node.
Scheme Procedure: mecab-parse-to-str
Parses a sentence
taggerand returns a string containing the result. The resulting string can be affected by options such as
Scheme Procedure: mecab-split
Returns the list of words in
Scheme Procedure: mecab-features
Returns the list of features associated with each word in
str, in the same order as
mecab-split. Note that the strings are always in CSV format, and this cannot be affected by the
Scheme Procedure: mecab-words
Returns the list of words in dictionary form that are present in
str, leaving out punctuation and declension.
Nodes can be manipulated with the following procedures.
Scheme Procedure: node-feature
Return the feature string of the given
Scheme Procedure: node-surface
Return the surface value of the given
node, that is the word as it is written in the sentence (not necessarily its dictionary form). Note that this function is not very reliable.
Scheme Procedure: node-stat
Return the type of the given
node. The value is a number which is one of
Scheme Procedure: node-next
Return the node following the given
Scheme Procedure: node-prev
Return the node preceding the given