rbm25
A light wrapper around the BM25 rust crate for Okapi BM25 text search
Science Score: 13.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
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.2%) to scientific vocabulary
Keywords
bm25
r
rust
similarity-search
Last synced: 11 months ago
·
JSON representation
Repository
A light wrapper around the BM25 rust crate for Okapi BM25 text search
Basic Info
- Host: GitHub
- Owner: DavZim
- License: other
- Language: R
- Default Branch: main
- Homepage: https://davzim.github.io/rbm25/
- Size: 18.7 MB
Statistics
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 4
- Releases: 0
Topics
bm25
r
rust
similarity-search
Created almost 2 years ago
· Last pushed over 1 year 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%"
)
```
# rbm25
[](https://github.com/DavZim/rbm25/actions/workflows/R-CMD-check.yaml)
[](https://CRAN.R-project.org/package=rbm25)
`{rbm25}` is a light wrapper around the rust [`bm25`](https://crates.io/crates/bm25) crate.
It provides a simple interface to the [Okapi BM25 algorithm](https://en.wikipedia.org/wiki/Okapi_BM25) for text search.
Note the package does not provide any text preprocessing, this needs to be done before using the package.
## Installation
You can install the development version of rbm25 like so:
``` r
# Development Version
# devtools::install_github("DavZim/rbm25")
# CRAN release
install.packages("rbm25")
```
## Example
The package exposes an R6 class `BM25` that can be used to query a text corpus.
For simplicity, there is also a `bm25_score()` function that wraps the `BM25` class.
```{r example}
library(rbm25)
# create a text corpus, where we want to find the closest matches for a query
corpus_original <- c(
"The rabbit munched the orange carrot.",
"The snake hugged the green lizard.",
"The hedgehog impaled the orange orange.",
"The squirrel buried the brown nut."
)
# text preprocessing: tolower, remove punctuation, remove stopwords
# note this is just an example and not the best way for larger amounts of text
stopwords <- c("the", "a", "an", "and")
corpus <- corpus_original |>
tolower() |>
gsub(pattern = "[[:punct:]]", replacement = "") |>
gsub(pattern = paste0("\\b(", paste(stopwords, collapse = "|"), ") *\\b"),
replacement = "") |>
trimws()
# define some metadata for the text corpus, e.g., the original text and the source
metadata <- data.frame(
text_original = corpus_original,
source = c("book1", "book2", "book3", "book4")
)
```
**Using the BM25 Class**
```{r bm25-class}
bm <- BM25$new(data = corpus, metadata = metadata)
bm
# note that query returns the values sorted by rank
bm$query(query = "orange", max_n = 2)
```
**Using the `bm25_score()` function**
```{r}
# note that bm25_score returns the score in the order of the input data
scores <- bm25_score(data = corpus, query = "orange")
data.frame(text = corpus, scores_orange = scores)
```
Owner
- Login: DavZim
- Kind: user
- Website: https://davzim.github.io/
- Repositories: 34
- Profile: https://github.com/DavZim
GitHub Events
Total
- Issues event: 4
- Watch event: 6
- Delete event: 3
- Issue comment event: 9
- Push event: 36
- Pull request event: 5
- Fork event: 1
- Create event: 8
Last Year
- Issues event: 4
- Watch event: 6
- Delete event: 3
- Issue comment event: 9
- Push event: 36
- Pull request event: 5
- Fork event: 1
- Create event: 8
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 4
- Total pull requests: 5
- Average time to close issues: N/A
- Average time to close pull requests: about 19 hours
- Total issue authors: 2
- Total pull request authors: 2
- Average comments per issue: 0.5
- Average comments per pull request: 1.4
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 4
- Pull requests: 5
- Average time to close issues: N/A
- Average time to close pull requests: about 19 hours
- Issue authors: 2
- Pull request authors: 2
- Average comments per issue: 0.5
- Average comments per pull request: 1.4
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- DavZim (3)
- vince-ar (1)
Pull Request Authors
- DavZim (3)
- CGMossa (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 191 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 2
- Total maintainers: 1
cran.r-project.org: rbm25
A Light Wrapper Around the 'BM25' 'Rust' Crate for Okapi BM25 Text Search
- Homepage: https://davzim.github.io/rbm25/
- Documentation: http://cran.r-project.org/web/packages/rbm25/rbm25.pdf
- License: MIT + file LICENSE
-
Latest release: 0.0.4
published over 1 year ago
Rankings
Dependent packages count: 27.4%
Dependent repos count: 33.8%
Average: 49.4%
Downloads: 86.9%
Maintainers (1)
Last synced:
12 months ago
Dependencies
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v4 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
- JamesIves/github-pages-deploy-action v4.5.0 composite
- actions/checkout v4 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
src/rust/Cargo.lock
cargo
- ahash 0.8.11
- allocator-api2 0.2.18
- bm25 0.3.1
- bumpalo 3.16.0
- byteorder 1.5.0
- cached 0.53.1
- cached_proc_macro 0.23.0
- cached_proc_macro_types 0.1.1
- cfg-if 1.0.0
- darling 0.20.10
- darling_core 0.20.10
- darling_macro 0.20.10
- extendr-api 0.7.1
- extendr-macros 0.7.1
- fnv 1.0.7
- fxhash 0.2.1
- hashbrown 0.14.5
- ident_case 1.0.1
- itoa 1.0.11
- js-sys 0.3.72
- libR-sys 0.7.1
- log 0.4.22
- memchr 2.7.4
- once_cell 1.20.2
- paste 1.0.15
- proc-macro2 1.0.87
- quote 1.0.37
- rust-stemmers 1.2.0
- ryu 1.0.18
- serde 1.0.210
- serde_derive 1.0.210
- serde_json 1.0.128
- stop-words 0.8.0
- strsim 0.11.1
- syn 2.0.79
- thiserror 1.0.64
- thiserror-impl 1.0.64
- unicode-ident 1.0.13
- version_check 0.9.5
- wasm-bindgen 0.2.95
- wasm-bindgen-backend 0.2.95
- wasm-bindgen-macro 0.2.95
- wasm-bindgen-macro-support 0.2.95
- wasm-bindgen-shared 0.2.95
- web-time 1.1.0
- whichlang 0.1.0
- zerocopy 0.7.35
- zerocopy-derive 0.7.35
src/rust/Cargo.toml
cargo
DESCRIPTION
cran
- R6 * imports
- testthat >= 3.0.0 suggests