Record Class Dataset

java.lang.Object
java.lang.Record
dev.dokimos.core.Dataset
Record Components:
name - the dataset name
description - the dataset description
examples - the examples in the dataset
All Implemented Interfaces:
Iterable<Example>

public record Dataset(String name, String description, List<Example> examples) extends Record implements Iterable<Example>
A collection of examples for evaluation.
  • Constructor Details

    • Dataset

      public Dataset(String name, String description, List<Example> examples)
      Creates an instance of a Dataset record class.
      Parameters:
      name - the value for the name record component
      description - the value for the description record component
      examples - the value for the examples record component
  • Method Details

    • builder

      public static Dataset.Builder builder()
      Creates a new builder for constructing datasets.
      Returns:
      a new builder
    • fromJson

      public static Dataset fromJson(Path path) throws IOException
      Loads a dataset from a JSON file.
      Parameters:
      path - the file path
      Returns:
      the loaded dataset
      Throws:
      IOException - if reading the file fails
    • fromJson

      public static Dataset fromJson(String json)
      Parses a dataset from a JSON string.
      Parameters:
      json - the JSON string
      Returns:
      the parsed dataset
    • fromCsv

      public static Dataset fromCsv(Path path) throws IOException
      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

      public static Dataset fromCsv(String csv, String name)
      Parses a dataset from a CSV string.
      Parameters:
      csv - the CSV content
      name - the dataset name
      Returns:
      the parsed dataset
    • fromJsonl

      public static Dataset fromJsonl(Path path) throws IOException
      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

      public static Dataset fromJsonl(String jsonl)
      Parses a dataset from a JSONL string with a default name.
      Parameters:
      jsonl - the JSONL content
      Returns:
      the parsed dataset
    • fromJsonl

      public static Dataset fromJsonl(String jsonl, String name)
      Parses a dataset from a JSONL string.
      Parameters:
      jsonl - the JSONL content
      name - the dataset name
      Returns:
      the parsed dataset
    • name

      public String name()
      Returns the dataset's name.
      Returns:
      the name
    • description

      public String description()
      Returns the dataset's description.
      Returns:
      the description
    • examples

      public List<Example> 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

      public Example get(int index)
      Returns the example at the specified index.
      Parameters:
      index - the example index
      Returns:
      the example
    • iterator

      public Iterator<Example> iterator()
      Specified by:
      iterator in interface Iterable<Example>
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.