You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

fasttext.wasm.js

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fasttext.wasm.js - npm Package Compare versions

Comparing version

to
0.0.1-next.5

dist/core/fastText.common.d.ts

1

dist/constants.d.ts

@@ -5,1 +5,2 @@ export declare const trainFileInWasmFs = "train.txt";

export declare const IS_BROWSER: boolean;
export declare const IS_WORKER: boolean;

11

dist/core/fastText.d.ts

@@ -1,2 +0,1 @@

import type { Emscripten } from '../types/emscripten'
import type { Pair, Vector } from '../types/misc'

@@ -56,4 +55,4 @@

export interface FastTextModule extends Emscripten.Module {
FS: Emscripten.FileSystem.FS
export interface FastTextModule extends EmscriptenModule {
FS: Emscripten.FileSystemType['fs']
FastText: FastTextCoreConstructor

@@ -65,4 +64,6 @@ Args: any

export type FastTextModuleConstructor = Emscripten.ModuleFactory<FastTextModule>
export type FastTextModuleFactory = EmscriptenModuleFactory<FastTextModule>
export default Emscripten.ModuleFactory<FastTextModule>
const fastTextModuleFactory: FastTextModuleFactory
export default fastTextModuleFactory

@@ -1,2 +0,1 @@

import type { Emscripten } from '../types/emscripten'
import type { Pair, Vector } from '../types/misc'

@@ -56,4 +55,4 @@

export interface FastTextModule extends Emscripten.Module {
FS: Emscripten.FileSystem.FS
export interface FastTextModule extends EmscriptenModule {
FS: Emscripten.FileSystemType['fs']
FastText: FastTextCoreConstructor

@@ -65,4 +64,6 @@ Args: any

export type FastTextModuleConstructor = Emscripten.ModuleFactory<FastTextModule>
export type FastTextModuleFactory = EmscriptenModuleFactory<FastTextModule>
export default Emscripten.ModuleFactory<FastTextModule>
const fastTextModuleFactory: FastTextModuleFactory
export default fastTextModuleFactory

@@ -0,8 +1,8 @@

/// <reference types="emscripten" />
import { FastTextModel } from './FastTextModel';
import type { Emscripten } from './types/emscripten';
import type { FastTextCoreConstructor, FastTextModule } from './core/fastText.browser';
import type { FastTextCoreConstructor, FastTextModule } from './core/fastText.common';
export declare class FastText {
core: FastTextModule;
ft: FastTextCoreConstructor;
fs: Emscripten.FileSystem.FS;
fs: Emscripten.FileSystemType['fs'];
constructor();

@@ -9,0 +9,0 @@ /**

@@ -1,2 +0,2 @@

import type { FastTextCore } from './core/fastText.browser';
import type { FastTextCore } from './core/fastText.common';
/**

@@ -3,0 +3,0 @@ * `FastTextModel` represents a trained model.

@@ -5,3 +5,3 @@ export { initializeFastTextModule } from '../helpers/models/node';

export { FastTextModel } from '../FastTextModel';
export { LanguageIdentificationModel } from '../tools/language-identification/node';
export { NodeLanguageIdentificationModel as LanguageIdentificationModel } from '../tools/language-identification/node';
export type { IdentifyLang, IdentifyLangVector, } from '../tools/language-identification/types';

@@ -1,35 +0,7 @@

import type { IdentifyLang, IdentifyLangVector } from './types';
import type { FastTextModel } from '../../FastTextModel';
export interface LanguageIdentificationModelOptions {
modelHref?: string;
import { BaseLanguageIdentificationModel } from './base';
import type { BaseLanguageIdentificationModelOptions } from './base';
export interface NodeLanguageIdentificationModelOptions extends Partial<BaseLanguageIdentificationModelOptions> {
}
export declare class LanguageIdentificationModel {
modelHref: string;
model: FastTextModel | null;
constructor(options?: LanguageIdentificationModelOptions);
load(): Promise<FastTextModel>;
static formatLang(raw: string): IdentifyLang;
identify(text: string): Promise<IdentifyLang>;
identifyVerbose(text: string): Promise<IdentifyLangVector[]>;
/**
* fastText [language identification model](https://fasttext.cc/docs/en/language-identification.html)
* result is based on [List of Wikipedias](https://en.wikipedia.org/wiki/List_of_Wikipedias) `WP code`
*
* This lib provide a normalize method to transform `WP code` to ISO 639-3 as much as possible.
*
* More detail refer to [languages scripts](https://github.com/yunsii/fasttext.wasm.js/tree/master/scripts/languages).
*/
normalizeIdentifyLang(lang: IdentifyLang): {
/**
* The three-letter 639-3 identifier.
*
* Attentions:
*
* - `eml` is not standard ISO 639-2 and ISO 639-3 code
* - `bih` and `nah` are ISO 639-2 codes, but not standard ISO 639-3 codes
*/
alpha3Code: string;
/** refName: manually normalize rawLanguage fit https://iso639-3.sil.org/code_tables/download_tables */
refName: string;
};
export declare class NodeLanguageIdentificationModel extends BaseLanguageIdentificationModel {
constructor(options?: NodeLanguageIdentificationModelOptions);
}
{
"name": "fasttext.wasm.js",
"description": "",
"version": "0.0.1-next.4",
"version": "0.0.1-next.5",
"author": "Yuns <yuns.xie@qq.com>",

@@ -17,6 +17,6 @@ "license": "MIT",

},
"./browser": {
"require": "./dist/main/browser.cjs",
"import": "./dist/main/browser.mjs",
"types": "./dist/main/browser.d.ts"
"./common": {
"require": "./dist/main/common.cjs",
"import": "./dist/main/common.mjs",
"types": "./dist/main/common.d.ts"
},

@@ -106,2 +106,5 @@ "./*": "./*"

},
"dependencies": {
"@types/emscripten": "^1.39.10"
},
"scripts": {

@@ -108,0 +111,0 @@ "dev": "vite --config vite.docs.config.ts",

@@ -11,4 +11,4 @@ # fasttext.wasm.js

- Written in TypeScript
- Browser, Node support
- Written in **TypeScript**
- **Node**, **Browser** and **Browser extension** support
- Language identification integrated

@@ -34,11 +34,14 @@

```ts
// Browser
// Others
import {
LanguageIdentificationModel,
initializeFastTextModule,
} from 'fasttext.wasm.js/browser'
} from 'fasttext.wasm.js/common'
// It will load fasttext.common.wasm from public root directly by default,
// You can download it from https://github.com/yunsii/fasttext.wasm.js/blob/master/src/core/fastText.common.wasm
// You can also use `locateFile` callback to custom fasttext.common.wasm full path.
await initializeFastTextModule()
const model = new LanguageIdentificationModel({
// Specific model path under public dir,
// Specific model path under public directory,
// You can download it from https://fasttext.cc/docs/en/language-identification.html

@@ -45,0 +48,0 @@ modelHref: '/models/lid.176.ftz',

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet