ccs-amsterdam / amcat4r Goto Github PK
View Code? Open in Web Editor NEWR Bindings for AmCAT4
Home Page: https://amcat.nl/
License: MIT License
R Bindings for AmCAT4
Home Page: https://amcat.nl/
License: MIT License
Might be obvious from a database perspective, but took me a loong time to figure out: the axes argument in query_aggregate() is apparently limited to "date" and "keyword" field types, if I'm not mistaken. Relatedly, the set_fields() function seems to work only on empty indices (i.e. before uploading documents).
Both issues should be flagged in the documentation and/or backed by more informative error messages than the current 'internal server error' (HTTP 500) to save future users some time ...
Thank you!
# No field specification
my_data <- data.frame(date = rep(as.Date("2020-01-01"), 6),
title = paste0("Title ", seq(1:6)),
text = paste0("bla bla blub ", seq(1:6)),
aggregator = c("A", "A", "A", "B", "B", NA))
create_index("my_index", description = "My Index")
upload_documents("my_index", my_data)
get__fields("my_index")
query_aggregate(index = "my_index",
queries = NULL,
axes = list(list(name="aggregator",
field="aggregator"))) # HTTP 500 error
set_fields(index = "my_index", list(aggregator = "keyword")) # HTTP 500 error
# With field specification
my_data <- data.frame(date = rep(as.Date("2020-01-01"), 6),
title = paste0("Title ", seq(1:6)),
text = paste0("bla bla blub ", seq(1:6)),
aggregator = c("A", "A", "A", "B", "B", NA))
create_index("my_index", description = "My Index")
set_fields(index = "my_index", list(aggregator = "keyword")) # Before upload!
get__fields("my_index")
upload_documents("my_index", my_data)
query_aggregate(index = "my_index",
queries = NULL,
axes = list(list(name="aggregator",
field="aggregator"))) # Ah!
While going through the functions, I noticed list_indexes()
and create_index()
did not work. I found that the issue was that they were sending requests to http://localhost/api/index
which produced a 405 (Method Not Allowed) error. I fixed list_indexes()
in 15d41eb and will fix create_index()
in a minute. I wonder though:
request()
, which removes trailing /
from the url
@kasperwelbers has done most of the work and documented it. It should be implemented in amcat4r:
httr2
has this implemented and stores encrypted token in rappdirs::user_cache_dir("httr2")
(they can be decrypted with httr2
by any user who has access to the file). The httr2
readme suggests to ask the user if they are happy with the risk in storing the token on disk. If they opt out, the token will only be stored in memory.login()
function for now, but show a deprecation message informing the user that the old amcat authentication is slowly phased out.We do have a page
parameter in the API, but never implemented it here or in amcat4py
.
I started to write some tests for middlecat in #4. It would be nice though to do more testing. There are two approaches which I'm considering:
httr2::response
+ httr2::with_mock
like in the test for getting the config. This is quite cumbersome though as it requires building half the api again just for testing. The vcr
package, which solves this problem for httr
does not support httr2
and I'm also unsure if it would solve our purpose since we process server responses right away.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.