Class NegativeExampleLoader

java.lang.Object
org.ek9lang.assist.NegativeExampleLoader

public class NegativeExampleLoader extends Object
Loads negative training examples from directories containing .ek9 files. Recursively scans a given directory for .ek9 files with JSON headers (between <?- and -?>) containing error metadata, and code bodies with @Error directives that are stripped for training output. Files with plain-text (non-JSON) headers or no error information are skipped.
  • Constructor Details

    • NegativeExampleLoader

      public NegativeExampleLoader()
  • Method Details

    • loadFromDirectory

      public List<NegativeExample> loadFromDirectory(Path corpusDir) throws IOException
      Recursively scan a directory for .ek9 files and load negative training examples. Any .ek9 file with a JSON header containing error metadata is included.
      Parameters:
      corpusDir - the root directory to scan
      Returns:
      list of parsed negative examples
      Throws:
      IOException
    • loadFile

      NegativeExample loadFile(Path filePath, String relativePath, String corpusName) throws IOException
      Throws:
      IOException
    • stripDirectives

      String stripDirectives(String code)
      Strip all directive lines (@Error, @Resolved, @Complexity, @IR, @BYTECODE) from code. Also removes inline <?- ... -?> comment blocks that appear within the code body.
    • extractErrorsFromDirectives

      List<ErrorInfo> extractErrorsFromDirectives(String code)
      Extract error codes from @Error directives in the code body. Used as fallback when JSON metadata has no errors[] array.