Skip to content

Commit

Permalink
Adding more ts specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo-ter-Doest committed Mar 22, 2024
1 parent 106ec4d commit dd1fc2c
Show file tree
Hide file tree
Showing 26 changed files with 483 additions and 99 deletions.
4 changes: 2 additions & 2 deletions lib/natural/tfidf/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ THE SOFTWARE.

import type { Tokenizer } from '../tokenizers'

declare type TfIdfCallback = (i: number, measure: number, key?: string) => void
declare type TfIdfCallback = (i: number, measure: number, key?: string | Record<string, any>) => void

declare interface TfIdfTerm {
term: string
Expand All @@ -42,7 +42,7 @@ export class TfIdf {

constructor (deserialized?: Record<string, unknown>)
idf (term: string, force?: boolean): number
addDocument (document: string | string[], key?: string, restoreCache?: boolean): void
addDocument (document: string | string[] | Record<string, string>, key?: Record<string, any> | any, restoreCache?: boolean): void
addFileSync (path: string, encoding?: string, key?: string, restoreCache?: boolean): void
tfidf (terms: string | string[], d: number): number
tfidfs (terms: string | string[], callback?: TfIdfCallback): number[]
Expand Down
2 changes: 1 addition & 1 deletion lib/natural/tfidf/tfidf.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class TfIdf {
setTokenizer (t) {
if (!_.isFunction(t.tokenize)) { throw new Error('Expected a valid Tokenizer') }
tokenizer = t
}
}

// Define a stopwords other than the default
setStopwords (customStopwords) {
Expand Down
2 changes: 1 addition & 1 deletion lib/natural/trie/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Trie {
addString (string: string): boolean
addStrings (list: string[]): void
contains (string: string): boolean
findPrefix (search: string): string[]
findPrefix (search: string): Array<string | null>
findMatchesOnPath (search: string): string[]
keysWithPrefix (prefix: string): string[]
getSize (): number
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"clean": "rimraf *~ #* *classifier.json dist io_spec/tmp/*.json",
"test": "cross-env NODE_PATH=. jasmine --random=false spec/*_spec.js",
"test_io": "jasmine --random=false io_spec/*_spec.js",
"test_ts": "cross-env NODE_PATH=. jasmine --random=false dist/spec/*_spec.js",
"test_ts": "cross-env NODE_PATH=. jasmine --random=false dist/ts_spec/*_spec.js",
"coverage": "nyc --reporter=lcov npm run test && nyc npm run test_io",
"test_browser": "cross-env NODE_PATH=. node ./node_modules/gulp/bin/gulp.js",
"lint": "eslint . --ext .ts"
Expand Down
17 changes: 0 additions & 17 deletions spec/brill_pos_tagger_test.ts

This file was deleted.

50 changes: 0 additions & 50 deletions spec/tfidf_test.ts

This file was deleted.

23 changes: 0 additions & 23 deletions spec/trie_test.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { WordTokenizer, Lexicon, RuleSet, BrillPOSTagger } from 'lib/natural'
import type { Sentence, TagResults } from 'lib/natural'

import * as englishSentences from './test_data/NYT-20150205-picassos-granddaughter-plans-to-sell-art-worrying-the-market.json'
import * as englishSentences from '../spec/test_data/NYT-20150205-picassos-granddaughter-plans-to-sell-art-worrying-the-market.json'

import jsonData from './test_data/NYT-20150205-picassos-granddaughter-plans_expected_tag_results.json'
import jsonData from '../spec/test_data/NYT-20150205-picassos-granddaughter-plans_expected_tag_results.json'

import * as dutchSentences from './test_data/Volkskrant-20150205-Knot-geldpers-aanzetten-is-paardenmiddel-voor-half-procent-inflatie.json'
import * as dutchSentences from '../spec/test_data/Volkskrant-20150205-Knot-geldpers-aanzetten-is-paardenmiddel-voor-half-procent-inflatie.json'

const englishTagResults: TagResults = jsonData as TagResults
const DEBUG = false
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit dd1fc2c

Please sign in to comment.