Skip to content

Commit

Permalink
allow use of fcarepository.prg
Browse files Browse the repository at this point in the history
  • Loading branch information
neuroimaginador committed Sep 10, 2024
1 parent 412b680 commit 58a3da6
Show file tree
Hide file tree
Showing 59 changed files with 1,178 additions and 1,179 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ VignetteBuilder:
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
15 changes: 11 additions & 4 deletions R/concept_lattice.R
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ ConceptLattice <- R6::R6Class(
attributes = private$attributes,
objects = private$objects,
extents = private$pr_extents[, candidates],
intents = private$pr_intents[, candidates])
intents = private$pr_intents[, candidates],
I = private$I
)
)

}
Expand All @@ -412,7 +414,9 @@ ConceptLattice <- R6::R6Class(
extents = .extract_column(private$pr_extents,
candidates),
intents = .extract_column(private$pr_intents,
candidates))
candidates),
I = private$I
)
)

},
Expand Down Expand Up @@ -446,7 +450,9 @@ ConceptLattice <- R6::R6Class(
attributes = private$attributes,
objects = private$objects,
extents = private$pr_extents[, candidates],
intents = private$pr_intents[, candidates])
intents = private$pr_intents[, candidates],
I = private$I
)
)

}
Expand All @@ -458,7 +464,8 @@ ConceptLattice <- R6::R6Class(
extents = .extract_column(private$pr_extents,
candidates),
intents = .extract_column(private$pr_intents,
candidates))
candidates),
I = private$I)
)
},

Expand Down
48 changes: 47 additions & 1 deletion R/formal_context.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ FormalContext <- R6::R6Class(
#'
#' If no \code{I} is used, the resulting \code{FormalContext} will be empty and not usable unless for loading a previously saved one. In this case, one can provide a \code{filename} to import. Only RDS, CSV and CXT files are currently supported.
#'
#' If the file is not present, the fcarepository.org is looked for coincidences. If so, the corresponding context is loaded.
#'
#' @return An object of the \code{FormalContext} class.
#' @export
#'
Expand All @@ -108,7 +110,51 @@ FormalContext <- R6::R6Class(

}

version
if ((length(I) == 1) && is.character(I) && !file.exists(I)) {

warning("The file does not exist, trying to find it at fcarepository.org",
call. = FALSE,
immediate. = TRUE)

URL <- glue::glue("https://github.com/fcatools/contexts/raw/main/contexts/{I}")

file <- tempfile(fileext = ".cxt")

err <- try(
download.file(URL,
destfile = file,
quiet = TRUE)
)

if (inherits(err, "try-error")) {

stop("No such context.")

} else {

message("Found context.")

meta <- get_metadata(I)

if (!is.null(meta)) {

glue::glue("- {cli::style_underline('Title')}: {meta$title}\n- {cli::style_underline('Description')}: {stringr::str_to_sentence(meta$description)}\n- {cli::style_underline('Source')}: {meta$source}\n\n",
.trim = FALSE) |>
cat()

}

}

self$load(file)

unlink(file)

return(invisible(self))

}

# version

if (!capabilities()["long.double"] & getRversion() < "4.1.0") {

Expand Down
14 changes: 14 additions & 0 deletions R/repository.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
get_metadata <- function(ID) {

meta <- yaml::read_yaml("https://fcarepository.org/contexts.yaml")

if (ID %in% names(meta)) {

return(meta[[ID]])

}

return(NULL)

}

82 changes: 41 additions & 41 deletions doc/arules.html

Large diffs are not rendered by default.

594 changes: 297 additions & 297 deletions doc/concept_lattice.html

Large diffs are not rendered by default.

322 changes: 160 additions & 162 deletions doc/implications.html

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions docs/CODE_OF_CONDUCT.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions docs/CONTRIBUTING.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 58a3da6

Please sign in to comment.