<commit_before>// a smoke-test for our typescipt typings
import nlp from '../'
import nlpNumbers from '../plugins/numbers'

// Typings for imported plugin
interface NumberFunctions {
  json(n?: number): Document
  fractions(): Document
  toText(): Document
  toNumber(): Document
  toOrdinal(): Document
  toCardinal(): Document
  add(n: number): Document
  subtract(n: number): Document
  increment(): Document
  decrement(): Document
  isEqual(): Document
  greaterThan(min: number): Document
  lessThan(max: number): Document
  between(min: number, max: number): Document
  isOrdinal(): Document
  isCardinal(): Document
  toLocaleString(): Document
}

type NLPNumbers = nlp.Plugin<
  {
    numbers(n?: number): NumberFunctions
  },
  {}
>

// vs Typed plugin
type NLPTest = nlp.Plugin<{ test: (text: string) => string }, { test: string }>
const test: NLPTest = (Doc, world) => {
  // Prototype is visible in here with plugin values
  Doc.prototype.test = text => text
  world.test = 'Hello world!'
}

const nlpEx = nlp
  // Give typing to untyped Plugin
  .extend(nlpNumbers)
  // Use typed plugin
  .extend(test)

const doc = nlpEx('hello world') // This type is cleaner
doc.nouns()
doc.nouns().world.test
doc.test('test')
doc.numbers()
doc.numbers().json()
doc.world.test === typeof 'string'

// Demo: For external use
export type NLP = typeof nlpEx

// Standard still works
const docSimple = nlp('test')
docSimple.nouns()
docSimple.nouns().world
nlp.tokenize('test')
nlp.version

// Directly set nlp type
const doc2 = nlp<
  {
    numbers: () => number[]
  },
  {
    a: string
  }
>('test')
doc2.numbers()
doc2.world.a === typeof 'string'
<commit_msg>Remove nlp numbers type from main tests<commit_after>// a smoke-test for our typescipt typings
import nlp from '../'
import nlpNumbers from '../plugins/numbers'

// vs Typed plugin
type NLPTest = nlp.Plugin<{ test: (text: string) => string }, { test: string }>
const test: NLPTest = (Doc, world) => {
  // Prototype is visible in here with plugin values
  Doc.prototype.test = text => text
  world.test = 'Hello world!'
}

const nlpEx = nlp
  // Give typing to untyped Plugin
  .extend(nlpNumbers)
  // Use typed plugin
  .extend(test)

const doc = nlpEx('hello world') // This type is cleaner
doc.nouns()
doc.nouns().world.test
doc.test('test')
doc.numbers()
doc.numbers().json()
doc.world.test === typeof 'string'

// Demo: For external use
export type NLP = typeof nlpEx

// Standard still works
const docSimple = nlp('test')
docSimple.nouns()
docSimple.nouns().world
nlp.tokenize('test')
nlp.version

// Directly set nlp type
const doc2 = nlp<
  {
    numbers: () => number[]
  },
  {
    a: string
  }
>('test')
doc2.numbers()
doc2.world.a === typeof 'string'

{'fraction_non_alphanumeric': 0.14537444933920704, 'fraction_numerical': 0.0022026431718061676, 'mean_word_length': 3.7309027777777777, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 16, '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': '1959129', 'n_tokens_mistral': 924, 'n_tokens_neox': 907, 'n_words': 278}