Skip to contents

FM indices can be stored on disk and loaded into memory again in order to avoid re-computing the index every time a new R session is opened.

Usage

fm_index_save(index, path)

fm_index_load(path)

Arguments

index

FM Index to be saved to disk

path

Path where to save index to or load index from

Value

For fm_index_load, a FM Index object that can be passed to fm_index_locate() for finding matches in the corpus. For fm_index_save, no return value. Called for side-effects.

Functions

  • fm_index_save: Save FM Index to disk

  • fm_index_load: Load FM Index from disk

See also

Other FM Index functions: fm_index_create(), fm_index_locate()

Examples

data("state")
index_1 <- fm_index_create(state.name, case_sensitive = FALSE)

tmp_path <- tempfile()
fm_index_save(index_1, tmp_path)
index_2 <- fm_index_load(tmp_path)

identical(
  fm_index_locate("new", index_1),
  fm_index_locate("new", index_2)
)
#> [1] TRUE