Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (17.7%) to scientific vocabulary
Keywords
mecab
pos-tagging
r
r-package
rcpp
Last synced: 6 months ago
·
JSON representation
Repository
A plain ‘Rcpp’ wrapper of ‘MeCab'
Basic Info
- Host: GitHub
- Owner: paithiov909
- License: gpl-3.0
- Language: C++
- Default Branch: main
- Homepage: https://paithiov909.github.io/gibasa/
- Size: 57.4 MB
Statistics
- Stars: 16
- Watchers: 1
- Forks: 1
- Open Issues: 1
- Releases: 19
Topics
mecab
pos-tagging
r
r-package
rcpp
Created over 4 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
pkgload::load_all(export_all = FALSE)
```
# gibasa
[](https://paithiov909.r-universe.dev/gibasa)

[](https://github.com/paithiov909/gibasa/actions)
[](https://app.codecov.io/gh/paithiov909/gibasa)
[](https://cran.r-project.org/package=gibasa)
## Overview
gibasa is a plain 'Rcpp' wrapper for 'MeCab', a morphological analyzer for CJK text.
Part-of-speech tagging with morphological analyzers is useful for processing CJK text data. This is because most words in CJK text are not separated by whitespaces and `tokenizers::tokenize_words` may split them into wrong tokens.
The main goal of gibasa package is to provide an alternative to `tidytext::unnest_tokens` for CJK text data. For this goal, gibasa provides three main functions: `gibasa::tokenize`, `gibasa::prettify`, and `gibasa::pack`.

- `gibasa::tokenize` takes a TIF-compliant data.frame of corpus, returning tokens as format that known as 'tidy text data', so that users can replace `tidytext::unnest_tokens` with it for tokenizing CJK text.
- `gibasa::prettify` turns tagged features into columns.
- `gibasa::pack` takes a 'tidy text data', typically returning space-separated corpus.
## Installation
You can install binary package via [CRAN](https://cran.r-project.org/package=gibasa) or [r-universe](https://paithiov909.r-universe.dev/gibasa).
```r
## Install gibasa from r-universe repository
install.packages("gibasa", repos = c("https://paithiov909.r-universe.dev", "https://cloud.r-project.org"))
## Or build from source package
Sys.setenv(MECAB_DEFAULT_RC = "/fullpath/to/your/mecabrc") # if necessary
remotes::install_github("paithiov909/gibasa")
```
To use gibasa package requires the [MeCab](https://taku910.github.io/mecab/) library and its dictionary installed and available.
In case using Linux or macOS, you can install them with their package managers, or build and install from the source by yourself.
In case using Windows, use installer [built for 64bit](https://github.com/ikegami-yukino/mecab/releases/tag/v0.996.2). Note that gibasa requires a UTF-8 dictionary, not a Shift-JIS one.
As of v0.9.4, gibasa looks at the file specified by the environment variable `MECABRC` or the file located at `~/.mecabrc`. If the MeCab dictionary is in a different location than the default, create a mecabrc file and specify where the dictionary is located.
For example, to install and use the [ipadic](https://pypi.org/project/ipadic/) from PyPI, run:
```sh
$ python3 -m pip install ipadic
$ python3 -c "import ipadic; print('dicdir=' + ipadic.DICDIR);" > ~/.mecabrc
```
## Usage
### Tokenize sentences
```{r}
res <- gibasa::tokenize(
data.frame(
doc_id = seq_along(gibasa::ginga[5:8]),
text = gibasa::ginga[5:8]
),
text,
doc_id
)
res
```
### Prettify output
```{r}
gibasa::prettify(res)
gibasa::prettify(res, col_select = 1:3)
gibasa::prettify(res, col_select = c(1, 3, 5))
gibasa::prettify(res, col_select = c("POS1", "Original"))
```
### Pack output
```{r}
res <- gibasa::prettify(res)
gibasa::pack(res)
dplyr::mutate(
res,
token = dplyr::if_else(is.na(Original), token, Original),
token = paste(token, POS1, sep = "/")
) |>
gibasa::pack() |>
head(1L)
```
### Change dictionary
IPA, UniDic, [CC-CEDICT-MeCab](https://github.com/ueda-keisuke/CC-CEDICT-MeCab), and [mecab-ko-dic](https://bitbucket.org/eunjeon/mecab-ko-dic/src/master/) schemes are supported.
```{r}
## UniDic 2.1.2
gibasa::tokenize("あのイーハトーヴォのすきとおった風", sys_dic = file.path("mecab/unidic-lite")) |>
gibasa::prettify(into = gibasa::get_dict_features("unidic26"))
## CC-CEDICT
gibasa::tokenize("它可以进行日语和汉语的语态分析", sys_dic = file.path("mecab/cc-cedict")) |>
gibasa::prettify(into = gibasa::get_dict_features("cc-cedict"))
## mecab-ko-dic
gibasa::tokenize("하네다공항한정토트백", sys_dic = file.path("mecab/mecab-ko-dic")) |>
gibasa::prettify(into = gibasa::get_dict_features("ko-dic"))
```
## Build dictionaries
### Build a system dictionary
```{r}
## build a new ipadic in temporary directory
build_sys_dic(
dic_dir = file.path("mecab/ipadic-eucjp"), # replace here with path to your source dictionary
out_dir = tempdir(),
encoding = "euc-jp" # encoding of source csv files
)
## copy the 'dicrc' file
file.copy(file.path("mecab/ipadic-eucjp/dicrc"), tempdir())
dictionary_info(sys_dic = tempdir())
```
### Build a user dictionary
```{r}
## write a csv file and compile it into a user dictionary
writeLines(
c(
"月ノ,1290,1290,4579,名詞,固有名詞,人名,姓,*,*,月ノ,ツキノ,ツキノ",
"美兎,1291,1291,8561,名詞,固有名詞,人名,名,*,*,美兎,ミト,ミト"
),
con = (csv_file <- tempfile(fileext = ".csv"))
)
build_user_dic(
dic_dir = file.path("mecab/ipadic-eucjp"),
file = (user_dic <- tempfile(fileext = ".dic")),
csv_file = csv_file,
encoding = "utf8"
)
tokenize("月ノ美兎は箱の中", sys_dic = tempdir(), user_dic = user_dic)
```
## License
GPL (>=3).
Owner
- Name: Kato Akiru
- Login: paithiov909
- Kind: user
- Location: Akita, Japan
- Website: https://www.resume.id/paithiov909
- Twitter: paithiov909
- Repositories: 22
- Profile: https://github.com/paithiov909
@lyrikuso|加藤秋瑠はHNです
GitHub Events
Total
- Release event: 1
- Watch event: 2
- Delete event: 2
- Push event: 10
- Pull request review event: 2
- Pull request event: 4
- Create event: 4
Last Year
- Release event: 1
- Watch event: 2
- Delete event: 2
- Push event: 10
- Pull request review event: 2
- Pull request event: 4
- Create event: 4
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| paithiov909 | a****4@g****m | 260 |
| renovate[bot] | 2****] | 4 |
| imgbot[bot] | 3****] | 2 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 17
- Total pull requests: 22
- Average time to close issues: about 2 months
- Average time to close pull requests: 1 day
- Total issue authors: 3
- Total pull request authors: 3
- Average comments per issue: 0.41
- Average comments per pull request: 0.05
- Merged pull requests: 20
- Bot issues: 1
- Bot pull requests: 8
Past Year
- Issues: 0
- Pull requests: 4
- Average time to close issues: N/A
- Average time to close pull requests: 6 days
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 4
Top Authors
Issue Authors
- paithiov909 (15)
- barracuda156 (1)
- renovate[bot] (1)
Pull Request Authors
- paithiov909 (14)
- renovate[bot] (6)
- imgbot[bot] (2)
Top Labels
Issue Labels
bug (4)
feature (4)
documentation (1)
upkeep (1)
Epic (1)
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 280 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 8
- Total maintainers: 1
cran.r-project.org: gibasa
An Alternative 'Rcpp' Wrapper of 'MeCab'
- Homepage: https://paithiov909.github.io/gibasa/
- Documentation: http://cran.r-project.org/web/packages/gibasa/gibasa.pdf
- License: GPL (≥ 3)
-
Latest release: 1.1.2
published about 1 year ago
Rankings
Stargazers count: 15.1%
Forks count: 21.0%
Dependent repos count: 23.8%
Dependent packages count: 28.7%
Average: 29.4%
Downloads: 58.6%
Maintainers (1)
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- Matrix * imports
- Rcpp * imports
- RcppParallel * imports
- audubon >= 0.3.0 imports
- dplyr * imports
- purrr * imports
- rlang >= 0.4.11 imports
- stringi * imports
- utils * imports
- roxygen2 * suggests
- testthat >= 3.0.0 suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/rhub.yaml
actions
- r-hub/rhub2/actions/rhub-checkout v1 composite
- r-hub/rhub2/actions/rhub-platform-info v1 composite
- r-hub/rhub2/actions/rhub-run-check v1 composite
- r-hub/rhub2/actions/rhub-setup v1 composite
- r-hub/rhub2/actions/rhub-setup-deps v1 composite
- r-hub/rhub2/actions/rhub-setup-r v1 composite