Package dev.dokimos.core
Record Class Dataset
java.lang.Object
java.lang.Record
dev.dokimos.core.Dataset
- Record Components:
name- the dataset namedescription- the dataset descriptionexamples- the examples in the dataset
public record Dataset(String name, String description, List<Example> examples)
extends Record
implements Iterable<Example>
A collection of examples for evaluation.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Dataset.Builderbuilder()Creates a new builder for constructing datasets.Returns the dataset's description.final booleanIndicates whether some other object is "equal to" this one.examples()Returns the examples in the dataset.static DatasetParses a dataset from a CSV string.static DatasetLoads a dataset from a CSV file.static DatasetParses a dataset from a JSON string.static DatasetLoads a dataset from a JSON file.static DatasetParses a dataset from a JSONL string with a default name.static DatasetParses a dataset from a JSONL string.static DatasetLoads a dataset from a JSONL file, streaming line-by-line from disk without loading the entire file into memory.get(int index) Returns the example at the specified index.final inthashCode()Returns a hash code value for this object.iterator()name()Returns the dataset's name.intsize()Returns the number of examples in the dataset.final StringtoString()Returns a string representation of this record class.Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Dataset
Creates an instance of aDatasetrecord class.- Parameters:
name- the value for thenamerecord componentdescription- the value for thedescriptionrecord componentexamples- the value for theexamplesrecord component
-
-
Method Details
-
builder
Creates a new builder for constructing datasets.- Returns:
- a new builder
-
fromJson
Loads a dataset from a JSON file.- Parameters:
path- the file path- Returns:
- the loaded dataset
- Throws:
IOException- if reading the file fails
-
fromJson
Parses a dataset from a JSON string.- Parameters:
json- the JSON string- Returns:
- the parsed dataset
-
fromCsv
Loads a dataset from a CSV file. Expects headers: input,expectedOutput, plus optional metadata columns.- Parameters:
path- the file path- Returns:
- the loaded dataset
- Throws:
IOException- if reading the file fails
-
fromCsv
Parses a dataset from a CSV string.- Parameters:
csv- the CSV contentname- the dataset name- Returns:
- the parsed dataset
-
fromJsonl
Loads a dataset from a JSONL file, streaming line-by-line from disk without loading the entire file into memory.- Parameters:
path- the file path- Returns:
- the loaded dataset
- Throws:
IOException- if reading the file fails
-
fromJsonl
Parses a dataset from a JSONL string with a default name.- Parameters:
jsonl- the JSONL content- Returns:
- the parsed dataset
-
fromJsonl
Parses a dataset from a JSONL string.- Parameters:
jsonl- the JSONL contentname- the dataset name- Returns:
- the parsed dataset
-
name
Returns the dataset's name.- Returns:
- the name
-
description
Returns the dataset's description.- Returns:
- the description
-
examples
Returns the examples in the dataset.- Returns:
- the examples list
-
size
public int size()Returns the number of examples in the dataset.- Returns:
- the size
-
get
Returns the example at the specified index.- Parameters:
index- the example index- Returns:
- the example
-
iterator
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object).
-