Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

entity_types_map() does not work reliably #40

Open
ChristophLeonhardt opened this issue Feb 28, 2024 · 0 comments
Open

entity_types_map() does not work reliably #40

ChristophLeonhardt opened this issue Feb 28, 2024 · 0 comments

Comments

@ChristophLeonhardt
Copy link
Collaborator

This concerns the version of the package on the entity_types branch. The line

type_list <- unlist(el, recursive = FALSE)

which was used in a similar function earlier causes issues in entity_types_map(). This is already anticipated in the comments surrounding this line. Long story short: Earlier, a list of lists was passed to the function (as an object corresponding to el here). Now, el is already a list itself, so does not need to be unlisted. If unlisted, the names of the resulting character vector probably won't match the mapping_vector. In consequence, all entities in the data.table are assigned to the category defined in the argument other.

To address this, I think it would suffice to omit the line quoted above. And instead of type_list in the following chunk, you would use el directly here:

dbpedia/R/entity_types.R

Lines 81 to 87 in f4dc779

types_with_class_raw <- lapply(
seq_along(type_list),
function(i) {
list_name <- names(type_list)[[i]]
list_elements <- type_list[[i]]
paste0(list_name, ":", list_elements)
})

Then, the assignment should work as expected.

Two notes here:

  • It might be worth considering changing the name of the resulting column in the data.table from "class" to "category" as this wording is indeed unclear.
  • A similar issue occurs with the "old" map_type_to_class() function. Here, the issue results in a different outcome, assigning all classes to all entities as currently visible in the README. This can be addressed in a similar fashion, but if the function is replaced by entity_types_map() fixing the former seems more important.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant