<commit_before>declare namespace schema {
  export type StrategyFunction = (value: any, parent: any, key: string) => any;
  export type SchemaFunction = (value: any, parent: any, key: string) => string;
  export type MergeFunction = (entityA: any, entityB: any) => any;

  export class Array {
    constructor(definition: Schema, schemaAttribute?: string | SchemaFunction)
    define(definition: Schema): void
  }

  export interface EntityOptions {
    idAttribute?: string | SchemaFunction
    mergeStrategy?: MergeFunction
    processStrategy?: StrategyFunction
  }

  export class Entity {
    constructor(key: string | symbol, definition?: Schema, options?: EntityOptions)
    define(definition: Schema): void
    key: string
  }

  export class Object {
    constructor(definition: {[key: string]: Schema})
    define(definition: Schema): void
  }

  export class Union {
    constructor(definition: Schema, schemaAttribute?: string | SchemaFunction)
    define(definition: Schema): void
  }

  export class Values {
    constructor(definition: Schema, schemaAttribute?: string | SchemaFunction)
    define(definition: Schema): void
  }
}

export type Schema =
  schema.Array |
  schema.Entity |
  schema.Object |
  schema.Union |
  schema.Values |
  schema.Array[] |
  schema.Entity[] |
  schema.Object[] |
  schema.Union[] |
  schema.Values[] |
  {[key: string]: Schema | Schema[]};

export type NormalizedSchema<E, R> = { entities: E, result: R };

export function normalize<E = any, R = any>(
  data: any,
  schema: Schema
): NormalizedSchema<E, R>;

export function denormalize(
  input: any,
  schema: Schema,
  entities: any
): any;<commit_msg>[enhance] Improve typescript types with generics (#365)<commit_after>declare namespace schema {
  export type StrategyFunction<T> = (value: any, parent: any, key: string) => T;
  export type SchemaFunction = (value: any, parent: any, key: string) => string;
  export type MergeFunction = (entityA: any, entityB: any) => any;

  export class Array<T = any> {
    constructor(definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
    define(definition: Schema): void
  }

  export interface EntityOptions<T = any> {
    idAttribute?: string | SchemaFunction
    mergeStrategy?: MergeFunction
    processStrategy?: StrategyFunction<T>
  }

  export class Entity<T = any> {
    constructor(key: string | symbol, definition?: Schema, options?: EntityOptions<T>)
    define(definition: Schema): void
    key: string
    getId: SchemaFunction
    _processStrategy: StrategyFunction<T>
  }

  export class Object<T = any> {
    constructor(definition: {[key: string]: Schema<T>})
    define(definition: Schema): void
  }

  export class Union<T = any> {
    constructor(definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
    define(definition: Schema): void
  }

  export class Values<T = any> {
    constructor(definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
    define(definition: Schema): void
  }
}

export type Schema<T = any> =
  | schema.Entity<T>
  | schema.Object<T>
  | schema.Union<T>
  | schema.Values<T>
  | SchemaObject<T>
  | SchemaArray<T>;

export interface SchemaObject<T> {
  [key: string]: Schema<T>
}

export interface SchemaArray<T> extends Array<Schema<T>> {}

export type NormalizedSchema<E, R> = { entities: E, result: R };

export function normalize<T = any, E = { [key:string]: { [key:string]: T }}, R = any>(
  data: any,
  schema: Schema<T>
): NormalizedSchema<E, R>;

export function denormalize(
  input: any,
  schema: Schema,
  entities: any
): any;
{'fraction_non_alphanumeric': 0.1238814317673378, 'fraction_numerical': 0.0008389261744966443, 'mean_word_length': 4.22953216374269, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '850987', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1039, 'n_words': 315}