Skip to content

Commit

Permalink
docs: add info about loading cases/queries
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Mar 3, 2024
1 parent 4625b6f commit dc7b6ee
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The following modules are part of CBRkit:
CBRkit is fully typed, so IDEs like VSCode and PyCharm can provide autocompletion and type checking.
We will explain all modules and their basic usage in the following sections.

### Loading Cases
### Loading Cases and Queries

The first step is to load cases and queries.
We provide predefined functions for the most common formats like CSV, JSON, and XML.
Expand All @@ -70,8 +70,35 @@ df = pd.read_csv("path/to/cases.csv")
cases = cbrkit.loaders.dataframe(df)
```

Queries can either be loaded using the same loader functions or constructed manually.
When dealing with formats like JSON, the files can be loaded directly:

```python
cases = cbrkit.loaders.json("path/to/cases.json")
```

Queries can either be loaded using the same loader functions.
CBRkit expects the type of the queries to match the type of the cases.

```python
# for pandas
queries = cbrkit.loaders.dataframe(pd.read_csv("path/to/queries.csv"))
# for json
queries = cbrkit.loaders.json("path/to/queries.json")
```

In case your query collection only contains a single query, you can use the `singleton` function to extract it.

```python
query = cbrkit.singleton(queries)
```

Alternatively, you can also create a query directly in Python:

```python
# for pandas
query = pd.Series({"name": "John", "age": 25})
# for json
query = {"name": "John", "age": 25}
```

### Similarity Measures and Aggregation

0 comments on commit dc7b6ee

Please sign in to comment.