sentencex-ts 0.1.13-ts

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abe Jellinek
4
+
5
+ Based on sentencex
6
+ Copyright (c) 2025 Santhosh Thottingal
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Sentence segmenter
2
+
3
+ [sentencex](https://github.com/wikimedia/sentencex), but ported (back) from Rust to TypeScript, so it can be used on the
4
+ web in environments where bundle size matters.
5
+
6
+ ## Install
7
+
8
+ ```shell
9
+ npm install sentencex-ts
10
+ ```
11
+
12
+ ## Build
13
+
14
+ ```shell
15
+ npm run build
16
+ ```
@@ -0,0 +1 @@
1
+ export declare function chunkText(text: string, chunkSize: number): string[];
@@ -0,0 +1,11 @@
1
+ export declare const ROMAN_NUMERALS: readonly string[];
2
+ export declare function getQuotePairs(): Map<string, string>;
3
+ export declare const PARENS_REGEX: RegExp;
4
+ export declare const EMAIL_REGEX: RegExp;
5
+ export declare const NUMBERED_REFERENCE_REGEX: RegExp;
6
+ export declare const SPACE_AFTER_SEPARATOR: RegExp;
7
+ export declare const QUOTES_REGEX: RegExp;
8
+ export declare const EXCLAMATION_WORDS: readonly string[];
9
+ export declare const GLOBAL_SENTENCE_TERMINATORS: readonly string[];
10
+ export declare const SENTENCE_TERMINATOR_SET: Set<string>;
11
+ export declare const TERMINATORS_PATTERN: string;
@@ -0,0 +1 @@
1
+ export declare const LANGUAGE_FALLBACKS: ReadonlyMap<string, readonly string[]>;
@@ -0,0 +1,10 @@
1
+ export { Language, parseAbbreviations } from './language';
2
+ export type { SentenceBoundary } from './language';
3
+ export { chunkText } from './chunk-text';
4
+ export { LANGUAGE_FALLBACKS } from './fallbacks';
5
+ export { LANGUAGE_REGISTRY } from './languages';
6
+ import type { SentenceBoundary } from './language';
7
+ import { Language } from './language';
8
+ export declare function languageFactory(languageCode: string): Language;
9
+ export declare function segment(languageCode: string, text: string): string[];
10
+ export declare function getSentenceBoundaries(languageCode: string, text: string): SentenceBoundary[];
@@ -0,0 +1,33 @@
1
+ export interface SentenceBoundary {
2
+ startIndex: number;
3
+ endIndex: number;
4
+ text: string;
5
+ boundarySymbol: string | null;
6
+ isParagraphBreak: boolean;
7
+ }
8
+ export declare enum SkippableRangeType {
9
+ Quote = "Quote",
10
+ Parentheses = "Parentheses",
11
+ Email = "Email"
12
+ }
13
+ export interface SkippableRange {
14
+ start: number;
15
+ end: number;
16
+ rangeType: SkippableRangeType;
17
+ }
18
+ export declare function parseAbbreviations(...texts: string[]): string[];
19
+ export declare abstract class Language {
20
+ abstract getAbbreviations(): readonly string[];
21
+ getAbbreviationChar(): string;
22
+ getSentenceBreakRegex(): RegExp;
23
+ getSentenceBoundaries(text: string): SentenceBoundary[];
24
+ segment(text: string): string[];
25
+ getBoundaryExtend(word: string): number;
26
+ isAbbreviation(head: string, _tail: string, separator: string): boolean;
27
+ getLastWord(text: string): string;
28
+ isExclamation(head: string, _tail: string): boolean;
29
+ getNextWordApprox(text: string, start: number): string;
30
+ findBoundary(text: string, start: number, end: number): number | null;
31
+ continueInNextWord(textAfterBoundary: string): boolean;
32
+ getSkippableRanges(text: string): SkippableRange[];
33
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Amharic extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Arabic extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Bulgarian extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Bengali extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,5 @@
1
+ import { Language } from '../language';
2
+ export declare class Catalan extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ continueInNextWord(textAfterBoundary: string): boolean;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Language } from '../language';
2
+ export declare class Danish extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ continueInNextWord(textAfterBoundary: string): boolean;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Language } from '../language';
2
+ export declare class German extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ continueInNextWord(textAfterBoundary: string): boolean;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Language } from '../language';
2
+ export declare class Greek extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ getSentenceBreakRegex(): RegExp;
5
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class English extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Spanish extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,5 @@
1
+ import { Language } from '../language';
2
+ export declare class Finnish extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ continueInNextWord(textAfterBoundary: string): boolean;
5
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class French extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Gujarati extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Hindi extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,5 @@
1
+ import { Language } from '../language';
2
+ export declare class Armenian extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ getSentenceBreakRegex(): RegExp;
5
+ }
@@ -0,0 +1,3 @@
1
+ import { Language } from '../language';
2
+ export type LanguageConstructor = new () => Language;
3
+ export declare const LANGUAGE_REGISTRY: Map<string, LanguageConstructor>;
@@ -0,0 +1,6 @@
1
+ import { Language } from '../language';
2
+ export declare class Italian extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ getLastWord(text: string): string;
5
+ continueInNextWord(textAfterBoundary: string): boolean;
6
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Japanese extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,6 @@
1
+ import { Language } from '../language';
2
+ export declare class Kazakh extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ getLastWord(text: string): string;
5
+ continueInNextWord(textAfterBoundary: string): boolean;
6
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Kannada extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Malayalam extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Marathi extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,5 @@
1
+ import { Language } from '../language';
2
+ export declare class Burmese extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ getSentenceBreakRegex(): RegExp;
5
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Dutch extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Punjabi extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Polish extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Portuguese extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,5 @@
1
+ import { Language } from '../language';
2
+ export declare class Russian extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ continueInNextWord(textAfterBoundary: string): boolean;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Language } from '../language';
2
+ export declare class Slovak extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ continueInNextWord(textAfterBoundary: string): boolean;
5
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Tamil extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Language } from '../language';
2
+ export declare class Telugu extends Language {
3
+ getAbbreviations(): readonly string[];
4
+ }