@echogarden/text-segmentation 0.1.0
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.md +7 -0
- package/README.md +178 -0
- package/dist/EastAsianCharacterPatterns.d.ts +7 -0
- package/dist/EastAsianCharacterPatterns.js +24 -0
- package/dist/EastAsianCharacterPatterns.js.map +1 -0
- package/dist/Patterns.d.ts +34 -0
- package/dist/Patterns.js +126 -0
- package/dist/Patterns.js.map +1 -0
- package/dist/Suppressions.d.ts +4 -0
- package/dist/Suppressions.js +31 -0
- package/dist/Suppressions.js.map +1 -0
- package/dist/Test.d.ts +1 -0
- package/dist/Test.js +39 -0
- package/dist/Test.js.map +1 -0
- package/dist/TextSegmentation.d.ts +31 -0
- package/dist/TextSegmentation.js +208 -0
- package/dist/TextSegmentation.js.map +1 -0
- package/dist/WordSequence.d.ts +26 -0
- package/dist/WordSequence.js +67 -0
- package/dist/WordSequence.js.map +1 -0
- package/dist/utilities/Timer.d.ts +13 -0
- package/dist/utilities/Timer.js +70 -0
- package/dist/utilities/Timer.js.map +1 -0
- package/dist/utilities/Utilities.d.ts +6 -0
- package/dist/utilities/Utilities.js +24 -0
- package/dist/utilities/Utilities.js.map +1 -0
- package/package.json +55 -0
- package/src/EastAsianCharacterPatterns.ts +45 -0
- package/src/Patterns.ts +225 -0
- package/src/Suppressions.ts +35 -0
- package/src/Test.ts +55 -0
- package/src/TextSegmentation.ts +303 -0
- package/src/WordSequence.ts +94 -0
- package/src/utilities/Timer.ts +95 -0
- package/src/utilities/Utilities.ts +33 -0
- package/tsconfig.json +105 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2024 Rotem Dan
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Echogarden text segmentation library
|
|
2
|
+
|
|
3
|
+
A library providing word, phrase and sentence segmentation for natural language text.
|
|
4
|
+
|
|
5
|
+
* Fully **multilingual**. Covers all languages and writing systems representable as Unicode characters. When needed, applies second stage processing using a [WebAssembly port](https://github.com/echogarden-project/icu-segmentation-wasm) of the [ICU C++ Library](https://icu.unicode.org/) (if available) for handling difficult to segment east-Asian languages, like Chinese, Japanese, Thai and Khmer
|
|
6
|
+
* Segments **mixtures of different languages**, including mixtures of different scripts, like Chinese, Cyrillic and Latin, all within a single sentence or phrase, without needing to explicitly specify a particular language
|
|
7
|
+
* Includes **built-in suppression lists** for language-specific abbreviations and special word patterns. Currently included languages are English, German, Spanish, French, Italian, Portuguese and Russian, mostly extracted from the [CLDR JSON datasets](https://github.com/unicode-org/cldr-json)
|
|
8
|
+
* Accepts **user-provided suppression lists**
|
|
9
|
+
* **Very fast**. For most languages, word segmentation is done mostly via a single regular expression, dynamically built for the given options, and suppression set. Majority of processing is done within the JavaScript regular expression engine, or within optimized WebAssembly binaries
|
|
10
|
+
* Written in TypeScript
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
npm install @echogarden/text-segmentation
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
To enable fine-grained segmentation of Chinese, Japanese, Thai and Khmer words, install this additional package:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
npm install @echogarden/icu-segmentation-wasm
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
(`@echogarden/icu-segmentation-wasm` is a 27 MB package, and is set as a [peer dependency](https://docs.npmjs.com/cli/v10/configuring-npm/package-json#peerdependencies). For size reasons, it's not installed by default, to ease on deployments that may not require it - especially browsers)
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Splitting to words
|
|
29
|
+
```ts
|
|
30
|
+
import { splitToWords } from '@echogarden/text-segmentation'
|
|
31
|
+
|
|
32
|
+
const wordSequence: WordSequence =
|
|
33
|
+
await splitToWords('Hello, world! How are you doing today?', { language: 'en' })
|
|
34
|
+
|
|
35
|
+
console.log(wordSequence.words)
|
|
36
|
+
```
|
|
37
|
+
Prints a list of words (including spaces and punctuation):
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
['Hello', ',', ' ', 'world', '!', ' ', 'How',' ', 'are', ' ', 'you', ' ', 'doing', ' ', 'today', '?']
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Language mixtures
|
|
44
|
+
|
|
45
|
+
A language option provided like `language: 'en'` is only used for loading suppression dictionaries. You can still include mixtures of different languages and scripts within the same input text:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
await splitToWords('Hello world! Привет мир! 你好世界!')
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Producing:
|
|
52
|
+
```ts
|
|
53
|
+
['Hello', ' ', 'world', '!', ' ', 'Привет', ' ', 'мир', '!', ' ', '你好', '世界', '!']
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Getting detailed metadata
|
|
57
|
+
|
|
58
|
+
To get more detailed information,
|
|
59
|
+
```ts
|
|
60
|
+
console.log(wordSequence.entries)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
prints a list of objects, including metadata on each word:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
[
|
|
67
|
+
{ text: 'Hello', startOffset: 0, endOffset: 5, isPunctuation: false },
|
|
68
|
+
{ text: ',', startOffset: 5, endOffset: 6, isPunctuation: true },
|
|
69
|
+
{ text: ' ', startOffset: 6, endOffset: 7, isPunctuation: true },
|
|
70
|
+
{ text: 'world', startOffset: 7, endOffset: 12, isPunctuation: false },
|
|
71
|
+
{ text: '!', startOffset: 12, endOffset: 13, isPunctuation: true },
|
|
72
|
+
{ text: ' ', startOffset: 13, endOffset: 14, isPunctuation: true },
|
|
73
|
+
{ text: 'How', startOffset: 14, endOffset: 17, isPunctuation: false },
|
|
74
|
+
{ text: ' ', startOffset: 17, endOffset: 18, isPunctuation: true },
|
|
75
|
+
{ text: 'are', startOffset: 18, endOffset: 21, isPunctuation: false },
|
|
76
|
+
{ text: ' ', startOffset: 21, endOffset: 22, isPunctuation: true },
|
|
77
|
+
{ text: 'you', startOffset: 22, endOffset: 25, isPunctuation: false },
|
|
78
|
+
{ text: ' ', startOffset: 25, endOffset: 26, isPunctuation: true },
|
|
79
|
+
{ text: 'doing', startOffset: 26, endOffset: 31, isPunctuation: false },
|
|
80
|
+
{ text: ' ', startOffset: 31, endOffset: 32, isPunctuation: true },
|
|
81
|
+
{ text: 'today', startOffset: 32, endOffset: 37, isPunctuation: false },
|
|
82
|
+
{ text: '?', startOffset: 37, endOffset: 38, isPunctuation: true }
|
|
83
|
+
]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Segmenting to words, phrases and sentences
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
const result: SegmentationResult =
|
|
90
|
+
await segmentText(`Hello, world! How are you doing today?`)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`result` is a nested object containing a breakdown of sentences, phrases and words in the given text. It is described by these TypeScript types:
|
|
94
|
+
```ts
|
|
95
|
+
interface SegmentationResult {
|
|
96
|
+
wordSequence: WordSequence
|
|
97
|
+
sentences: Sentence[]
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface Sentence {
|
|
101
|
+
text: string
|
|
102
|
+
charRange: Range
|
|
103
|
+
wordRange: Range
|
|
104
|
+
wordSequence: WordSequence
|
|
105
|
+
|
|
106
|
+
phrases: Phrase[]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface Phrase {
|
|
110
|
+
text: string
|
|
111
|
+
charRange: Range
|
|
112
|
+
wordRange: Range
|
|
113
|
+
wordSequence: WordSequence
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface Range {
|
|
117
|
+
start: number
|
|
118
|
+
end: number
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Segmenting a predefined word sequence
|
|
123
|
+
|
|
124
|
+
If you have a pre-existing `WordSequence` object (or possibly a modified form of an existing one), you can segment it to sentences and phrases without needing to recompute the word boundaries:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
const result: SegmentationResult = await segmentWordSequence(wordSequence: WordSequence)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
In this way, you can also specify custom word boundaries, and the phrase and sentence segmentation operations would ensure that break characters are never identified within the spans of non-punctuation words.
|
|
131
|
+
|
|
132
|
+
## Algorithm outline
|
|
133
|
+
|
|
134
|
+
### Word segmentation
|
|
135
|
+
|
|
136
|
+
Looks for one out of several accepted character sequence patterns, and identifies that pattern as an individual word.
|
|
137
|
+
|
|
138
|
+
There are several types of accepted patterns, evaluated in this order:
|
|
139
|
+
* User-provided suppressions
|
|
140
|
+
* Language-specific suppressions. For example, in English it would include abbreviations like `Mr.`, `Mrs.`, `e.g.`, `i.e`, `etc.`, or contractions like and `'cause`, `'bout` in English, `'n` in Afrikaans
|
|
141
|
+
* Noun suppressions, shared in all languages, like names of brands, misc. abbreviations and programming languages. Examples: `C#`, `F#`, `C++`, `Yahoo!`, `Toys"R"Us`, `Dunkin'`, `Ke$ha`, `Sky+`, `I/O`, `A/C`, `A/V`
|
|
142
|
+
* Top-level domains, like `.com`, `.org`, `.net` (also doubling as the noun `.NET` as in the ".NET framework")
|
|
143
|
+
* Number patterns, consisting of a sequences of digits separated by various separator characters, like decimal separators `3.14`, `3,14`, and thousands separators like `233,421` (`,`), `233.421` (`.`) or `233 421` (` `). optional `-` or `+` signs like `-34,534.123`, `+43 345,344`
|
|
144
|
+
* Date, time, and phone number patterns, consisting of digits separated by characters like `/`, `:`, `-`, like `15:23:23`, `1953/11/06`, `64-534-756`
|
|
145
|
+
* Percentage patterns, which are a subset of number patterns preceded or followed by `%`, like `53.243%` or `%34.12`
|
|
146
|
+
* Currency patterns like `$101.25`, `€50`, `20£`, `-53.23¥`, which, like percentage patterns, are number patterns preceded or followed by a currency symbol
|
|
147
|
+
* Abbreviation patterns like `Y.M.C.A`: these patterns will be automatically matched (no special suppressions needed) if there is a sequence of single `.` alternating between single letters (like `x.y.z`), optionally, there may be a space between the characters, like `x. y. z.`
|
|
148
|
+
* **And finally** (but most importantly): word character sequences consisting of letter characters (Unicode category `Letter`), mark characters (Unicode category `Mark`) or digit characters (Unicode category `Decimal_Number`), which may include inner apostrophes like `'` and `’` and inner separators like `-`, `_` `·`
|
|
149
|
+
|
|
150
|
+
**Current limitations**:
|
|
151
|
+
* No current general identification of preceding or trailing apostrophes, like in English possessive plurals "The brothers' friend" or "The diplomats' contracts". **Reason**: this requires a large lexicon or more sophisticated language understanding, since the apostrophe is generally ambiguous with a single quote.
|
|
152
|
+
|
|
153
|
+
#### Further segmentation for words containing Chinese, Japanese, Thai, or Khmer characters
|
|
154
|
+
|
|
155
|
+
This requires the the `@echogarden/icu-segmentation-wasm` package to be **manually** installed.
|
|
156
|
+
|
|
157
|
+
* Iterate each previously identified word span
|
|
158
|
+
* Check if the word span contains at at least one codepoint belonging to the supported east Asian languages character ranges
|
|
159
|
+
* Load the ICU module on the first match that is found (due to a startup delay of about `40ms` - `80ms`, the module is only loaded if absolutely needed)
|
|
160
|
+
* Split the word span further using the ICU library
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
### Sentence and phrase segmentation
|
|
164
|
+
|
|
165
|
+
**Sentence segmentation**:
|
|
166
|
+
* Split to words, or use a pre-supplied word sequence
|
|
167
|
+
* Identify sentence enders, like `.`, `。`, `?`, `?`, `!`, `!` or a line break, outside word spans, and identify sentence boundaries based on them
|
|
168
|
+
* Extend sentence spans with any number of possible trailing punctuation characters, after the ender character, like `”`, `’`, `)`, `]`, `}`, `»`, line breaks or other whitespace
|
|
169
|
+
|
|
170
|
+
**Phrase segmentation**:
|
|
171
|
+
* Iterate over the sentences detected
|
|
172
|
+
* Within each sentence, identify phrase separators like `,`, `、`, `,`, `،`, `;`, `;`, `:`, `:`, `—` outside word spans, and split phrases based on them
|
|
173
|
+
* Extend phrase spans with any number of trailing punctuation characters, up to the end of the containing sentence
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
MIT
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const chineseCharacterRanges: import("regexp-composer").AnyOf;
|
|
2
|
+
export declare const japaneseHiraganaCharacterRanges: import("regexp-composer").AnyOf;
|
|
3
|
+
export declare const japaneseKatakanaCharacterRanges: import("regexp-composer").AnyOf;
|
|
4
|
+
export declare const thaiLetterRanges: import("regexp-composer").AnyOf;
|
|
5
|
+
export declare const khmerLetterRanges: import("regexp-composer").AnyOf;
|
|
6
|
+
export declare const eastAsianCharRanges: import("regexp-composer").AnyOf;
|
|
7
|
+
export declare const eastAsianCharRangesRegExp: RegExp;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { anyOf, buildRegExp, codepointRange } from 'regexp-composer';
|
|
2
|
+
export const chineseCharacterRanges = anyOf(codepointRange('4E00', '9FFF'), // Main
|
|
3
|
+
codepointRange('3400', '4DBF'), // CJK Unified Ideographs Extension A
|
|
4
|
+
codepointRange('20000', '2A6DF') // CJK Unified Ideographs Extension B
|
|
5
|
+
);
|
|
6
|
+
export const japaneseHiraganaCharacterRanges = anyOf(codepointRange('3040', '309F'), // Hiragana
|
|
7
|
+
codepointRange('1AFF0', '1AFFF'), // Kana Extended-B
|
|
8
|
+
codepointRange('1B000', '1B0FF'), // Kana Supplement
|
|
9
|
+
codepointRange('1B100', '1B12F'), // Kana Extended-A
|
|
10
|
+
codepointRange('1B130', '1B16F'));
|
|
11
|
+
export const japaneseKatakanaCharacterRanges = anyOf(codepointRange('30A0', '30FF'), // Katakana
|
|
12
|
+
codepointRange('31F0', '31FF'), // Katakana Phonetic Extensions
|
|
13
|
+
codepointRange('3200', '32FF'), // Enclosed CJK Letters and Months
|
|
14
|
+
codepointRange('FF00', 'FFEF'), // Halfwidth and Fullwidth Forms
|
|
15
|
+
codepointRange('1AFF0', '1AFFF'), // Kana Extended-B
|
|
16
|
+
codepointRange('1B000', '1B0FF'), // Kana Supplement
|
|
17
|
+
codepointRange('1B100', '1B12F'), // Kana Extended-A
|
|
18
|
+
codepointRange('1B130', '1B16F'));
|
|
19
|
+
export const thaiLetterRanges = anyOf(codepointRange('0E00', '0E7F'));
|
|
20
|
+
export const khmerLetterRanges = anyOf(codepointRange('1780', '17FF'), // Letters
|
|
21
|
+
codepointRange('19E0', '19FF'));
|
|
22
|
+
export const eastAsianCharRanges = anyOf(chineseCharacterRanges, japaneseHiraganaCharacterRanges, japaneseKatakanaCharacterRanges, thaiLetterRanges, khmerLetterRanges);
|
|
23
|
+
export const eastAsianCharRangesRegExp = buildRegExp(eastAsianCharRanges);
|
|
24
|
+
//# sourceMappingURL=EastAsianCharacterPatterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EastAsianCharacterPatterns.js","sourceRoot":"","sources":["../src/EastAsianCharacterPatterns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW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Ac,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU;AAC1C,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAC9B,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CACvC,sBAAsB,EACtB,+BAA+B,EAC/B,+BAA+B,EAC/B,gBAAgB,EAChB,iBAAiB,CACjB,CAAA;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,WAAW,CAAC,mBAAmB,CAAC,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare function buildWordOrNumberPattern(suppressions: string[]): import("regexp-composer").AnyOf;
|
|
2
|
+
export declare function buildSuppressionPattern(suppressions: string[]): import("regexp-composer").Pattern;
|
|
3
|
+
export declare const punctuationPattern: import("regexp-composer").SpecialToken;
|
|
4
|
+
export declare const digitPattern: import("regexp-composer").SpecialToken;
|
|
5
|
+
export declare const arabicNumeralPattern: import("regexp-composer").SpecialToken;
|
|
6
|
+
export declare const numericSeparatorPattern: import("regexp-composer").Pattern;
|
|
7
|
+
export declare const dateTimeSeparatorPattern: import("regexp-composer").Pattern;
|
|
8
|
+
export declare const dateTimePattern: import("regexp-composer").OneOrMore;
|
|
9
|
+
export declare const spacedThousandsSeparatorPattern: import("regexp-composer").Pattern;
|
|
10
|
+
export declare const numericSignPattern: import("regexp-composer").Pattern;
|
|
11
|
+
export declare const numberPattern: import("regexp-composer").OneOrMore[];
|
|
12
|
+
export declare const prefixPercentageOrCurrencyPattern: import("regexp-composer").Pattern;
|
|
13
|
+
export declare const suffixPercentagePattern: import("regexp-composer").Pattern;
|
|
14
|
+
export declare const percentagePattern: import("regexp-composer").AnyOf;
|
|
15
|
+
export declare const letterPattern: import("regexp-composer").SpecialToken;
|
|
16
|
+
export declare const markPattern: import("regexp-composer").SpecialToken;
|
|
17
|
+
export declare const apostrophPattern: import("regexp-composer").AnyOf;
|
|
18
|
+
export declare const letterOrMarkPattern: import("regexp-composer").AnyOf;
|
|
19
|
+
export declare const dottedAbbreviationSequencePattern: import("regexp-composer").Pattern;
|
|
20
|
+
export declare const wordCharacterPattern: import("regexp-composer").AnyOf;
|
|
21
|
+
export declare const wordSeparatorPattern: import("regexp-composer").Pattern;
|
|
22
|
+
export declare const wordInnerApostrophPattern: import("regexp-composer").Pattern;
|
|
23
|
+
export declare const wordStartApostrophPattern: import("regexp-composer").Pattern;
|
|
24
|
+
export declare const basicWordPattern: import("regexp-composer").OneOrMore;
|
|
25
|
+
export declare const wordSegmentPattern: import("regexp-composer").AnyOf;
|
|
26
|
+
export declare const phraseSeparators: string[];
|
|
27
|
+
export declare const phraseSeparatorRegExp: RegExp;
|
|
28
|
+
export declare const sentenceSeparators: string[];
|
|
29
|
+
export declare const sentenceSeparatorRegExp: RegExp;
|
|
30
|
+
export declare const sentenceSeparatorTrailingPunctuationRegExp: RegExp;
|
|
31
|
+
export declare const phraseSeparatorTrailingPunctuationRegExp: RegExp;
|
|
32
|
+
export declare const oneOrMoreSpacesRegExp: RegExp;
|
|
33
|
+
export declare const wordCharacterRegExp: RegExp;
|
|
34
|
+
export declare const whitespacePatternRegExp: RegExp;
|
package/dist/Patterns.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { anyOf, buildRegExp, charRange, inputEnd, inputStart, matches, oneOrMore, possibly, repeated, tab, unicodeProperty, whitespace } from 'regexp-composer';
|
|
2
|
+
export function buildWordOrNumberPattern(suppressions) {
|
|
3
|
+
return anyOf(buildSuppressionPattern(suppressions), wordSegmentPattern);
|
|
4
|
+
}
|
|
5
|
+
export function buildSuppressionPattern(suppressions) {
|
|
6
|
+
const suppressionsPattern = matches(anyOf(...suppressions), { ifNotFollowedBy: wordCharacterPattern });
|
|
7
|
+
return suppressionsPattern;
|
|
8
|
+
}
|
|
9
|
+
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
10
|
+
// Numeric patterns
|
|
11
|
+
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
12
|
+
export const punctuationPattern = unicodeProperty('Punctuation');
|
|
13
|
+
export const digitPattern = unicodeProperty('Decimal_Number');
|
|
14
|
+
export const arabicNumeralPattern = charRange('0', '9');
|
|
15
|
+
export const numericSeparatorPattern = matches(anyOf('.', ',', '٬', '_'), {
|
|
16
|
+
ifPrecededBy: arabicNumeralPattern,
|
|
17
|
+
ifFollowedBy: arabicNumeralPattern
|
|
18
|
+
});
|
|
19
|
+
export const dateTimeSeparatorPattern = matches(anyOf('/', '-', ':'), {
|
|
20
|
+
ifPrecededBy: arabicNumeralPattern,
|
|
21
|
+
ifFollowedBy: arabicNumeralPattern
|
|
22
|
+
});
|
|
23
|
+
export const dateTimePattern = oneOrMore(anyOf(arabicNumeralPattern, dateTimeSeparatorPattern));
|
|
24
|
+
export const spacedThousandsSeparatorPattern = matches(' ', {
|
|
25
|
+
ifPrecededBy: arabicNumeralPattern,
|
|
26
|
+
ifFollowedBy: repeated(2, arabicNumeralPattern)
|
|
27
|
+
});
|
|
28
|
+
export const numericSignPattern = matches(anyOf('-', '+'), {
|
|
29
|
+
ifPrecededBy: anyOf(whitespace, punctuationPattern),
|
|
30
|
+
ifFollowedBy: arabicNumeralPattern,
|
|
31
|
+
});
|
|
32
|
+
export const numberPattern = [
|
|
33
|
+
oneOrMore(anyOf(digitPattern, numericSeparatorPattern, spacedThousandsSeparatorPattern, numericSignPattern)),
|
|
34
|
+
];
|
|
35
|
+
const percentageChars = ['%'];
|
|
36
|
+
const currencySpecialChars = ['$', '¥', '€', '£', '¥', '₩', '₭', '₽', '₫', '฿', '¢', '₮', '؋', '₦', '₱', '₴', '₪'];
|
|
37
|
+
const percentageOrCurrencyPattern = anyOf(...percentageChars, ...currencySpecialChars);
|
|
38
|
+
export const prefixPercentageOrCurrencyPattern = matches([
|
|
39
|
+
percentageOrCurrencyPattern,
|
|
40
|
+
numberPattern,
|
|
41
|
+
], {
|
|
42
|
+
ifNotPrecededBy: digitPattern,
|
|
43
|
+
ifFollowedBy: anyOf(whitespace, punctuationPattern),
|
|
44
|
+
});
|
|
45
|
+
export const suffixPercentagePattern = matches([
|
|
46
|
+
numberPattern,
|
|
47
|
+
percentageOrCurrencyPattern,
|
|
48
|
+
], {
|
|
49
|
+
ifPrecededBy: anyOf(whitespace, punctuationPattern),
|
|
50
|
+
ifNotFollowedBy: digitPattern,
|
|
51
|
+
});
|
|
52
|
+
export const percentagePattern = anyOf(prefixPercentageOrCurrencyPattern, suffixPercentagePattern);
|
|
53
|
+
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
54
|
+
// Letter patterns
|
|
55
|
+
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
56
|
+
export const letterPattern = unicodeProperty('Letter');
|
|
57
|
+
export const markPattern = unicodeProperty('Mark');
|
|
58
|
+
export const apostrophPattern = anyOf(`'`, `’`, `‘`);
|
|
59
|
+
export const letterOrMarkPattern = anyOf(letterPattern, markPattern);
|
|
60
|
+
export const dottedAbbreviationSequencePattern = matches(anyOf([
|
|
61
|
+
letterPattern,
|
|
62
|
+
oneOrMore([
|
|
63
|
+
'. ',
|
|
64
|
+
letterPattern,
|
|
65
|
+
]),
|
|
66
|
+
possibly('.'),
|
|
67
|
+
], [
|
|
68
|
+
letterPattern,
|
|
69
|
+
oneOrMore([
|
|
70
|
+
'.',
|
|
71
|
+
possibly(' '),
|
|
72
|
+
letterPattern,
|
|
73
|
+
]),
|
|
74
|
+
possibly('.'),
|
|
75
|
+
]), {
|
|
76
|
+
ifNotPrecededBy: anyOf(letterOrMarkPattern, digitPattern),
|
|
77
|
+
ifNotFollowedBy: anyOf(letterOrMarkPattern, digitPattern)
|
|
78
|
+
});
|
|
79
|
+
export const wordCharacterPattern = anyOf(letterPattern, markPattern, digitPattern);
|
|
80
|
+
export const wordSeparatorPattern = matches(anyOf('-', '_', '·', '‧', '&'), {
|
|
81
|
+
ifPrecededBy: letterOrMarkPattern,
|
|
82
|
+
ifFollowedBy: letterOrMarkPattern
|
|
83
|
+
});
|
|
84
|
+
export const wordInnerApostrophPattern = matches(apostrophPattern, {
|
|
85
|
+
ifPrecededBy: letterOrMarkPattern,
|
|
86
|
+
ifFollowedBy: letterOrMarkPattern,
|
|
87
|
+
});
|
|
88
|
+
export const wordStartApostrophPattern = matches(apostrophPattern, {
|
|
89
|
+
ifPrecededBy: whitespace,
|
|
90
|
+
ifFollowedBy: [letterOrMarkPattern, letterOrMarkPattern, whitespace]
|
|
91
|
+
});
|
|
92
|
+
export const basicWordPattern = oneOrMore(anyOf(wordCharacterPattern, wordSeparatorPattern, wordInnerApostrophPattern));
|
|
93
|
+
export const wordSegmentPattern = anyOf(dottedAbbreviationSequencePattern, dateTimeSeparatorPattern, percentagePattern, numberPattern, basicWordPattern);
|
|
94
|
+
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
95
|
+
// Prebuilt regular expressions
|
|
96
|
+
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
97
|
+
export const phraseSeparators = [',', '、', ',', '،', ';', ';', ':', ':', '—'];
|
|
98
|
+
export const phraseSeparatorRegExp = buildRegExp([
|
|
99
|
+
inputStart,
|
|
100
|
+
anyOf(...phraseSeparators),
|
|
101
|
+
inputEnd
|
|
102
|
+
]);
|
|
103
|
+
export const sentenceSeparators = ['.', '。', '?', '?', '!', '!', '\n'];
|
|
104
|
+
export const sentenceSeparatorRegExp = buildRegExp([
|
|
105
|
+
inputStart,
|
|
106
|
+
anyOf(...sentenceSeparators),
|
|
107
|
+
inputEnd
|
|
108
|
+
]);
|
|
109
|
+
export const sentenceSeparatorTrailingPunctuationRegExp = buildRegExp([
|
|
110
|
+
inputStart,
|
|
111
|
+
anyOf('"', '”', '’', ')', ']', '}', '»', ...sentenceSeparators, ...phraseSeparators, oneOrMore(whitespace)),
|
|
112
|
+
inputEnd
|
|
113
|
+
]);
|
|
114
|
+
export const phraseSeparatorTrailingPunctuationRegExp = buildRegExp([
|
|
115
|
+
inputStart,
|
|
116
|
+
anyOf(...phraseSeparators, ' ', tab),
|
|
117
|
+
inputEnd
|
|
118
|
+
]);
|
|
119
|
+
export const oneOrMoreSpacesRegExp = buildRegExp([
|
|
120
|
+
inputStart,
|
|
121
|
+
oneOrMore(' '),
|
|
122
|
+
inputEnd
|
|
123
|
+
]);
|
|
124
|
+
export const wordCharacterRegExp = buildRegExp(wordCharacterPattern);
|
|
125
|
+
export const whitespacePatternRegExp = buildRegExp(whitespace);
|
|
126
|
+
//# sourceMappingURL=Patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Patterns.js","sourceRoot":"","sources":["../src/Patterns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE/J,MAAM,UAAU,wBAAwB,CAAC,YAAsB;IAC9D,OAAO,KAAK,CACX,uBAAuB,CAAC,YAAY,CAAC,EACrC,kBAAkB,CAClB,CAAA;AACF,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,YAAsB;IAC7D,MAAM,mBAAmB,GACxB,OAAO,CACN,KAAK,CAAC,GAAG,YAAY,CAAC,EACtB,EAAE,eAAe,EAAE,oBAAoB,EAAE,CACzC,CAAA;IAEF,OAAO,mBAAmB,CAAA;AAC3B,CAAC;AAED,gGAAgG;AAChG,mBAAmB;AACnB,gGAAgG;AAChG,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC,aAAa,CAAC,CAAA;AAChE,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAA;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AAEvD,MAAM,CAAC,MAAM,uBAAuB,GACnC,OAAO,CACN,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,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', 'Ok.', 'Org.', 'Ex.', 'Cont.', 'U.', 'Mart.', 'Fn.', 'Abs.', 'Lt.', 'OK.', 'Z.', 'E.', 'Kb.', 'Est.', 'A.M.', 'L.A.', 'Prof.', 'U.S.', 'Nov.', 'Ph.D.', 'Mar.', 'I.T.', 'exec.', 'Jan.', 'N.Y.', 'X.', 'Md.', 'Op.', 'vs.', 'D.A.', 'A.D.', 'R.L.', 'P.M.', 'Or.', 'M.R.', 'Cap.', 'PC.', 'Feb.', 'Exec.', 'I.e.', 'Sep.', 'Gb.', 'K.', 'U.S.C.', 'Mt.', 'S.', 'A.S.', 'C.O.D.', 'Capt.', 'Col.', 'In.', 'C.F.', 'Adj.', 'AD.', 'I.D.', 'Mgr.', 'R.T.', 'B.V.', 'M.', 'Conn.', 'Yr.', 'Rev.', 'Phys.', 'pp.', 'Ms.', 'To.', 'Sgt.', 'J.K.', 'Nr.', 'Jun.', 'Fri.', 'S.A.R.', 'Lev.', 'Lt.Cdr.', 'Def.', 'F.', 'Do.', 'Joe.', 'Id.', 'Mr.', 'Dept.', 'Is.', 'Pvt.', 'Diff.', 'Hon.B.A.', 'Q.', 'Mb.', 'On.', 'Min.', 'J.B.', 'Ed.', 'AB.', 'A.', 'S.p.A.', 'I.', 'a.m.', 'Comm.', 'Go.', 'VS.', 'L.', 'All.', 'PP.', 'P.V.', 'T.', 'K.R.', 'Etc.', 'D.', 'Adv.', 'Lib.', 'E.g.', 'Pro.', 'U.S.A.', 'S.E.', 'AA.', 'Rep.', 'Sq.', 'As.'],
|
|
3
|
+
'de': ['Port.', 'Alt.', 'Di.', 'Ges.', 'frz.', 'entspr.', 'Gebr.', 'erw.', 'Frl.', 'Inh.', 'k.u.k.', 'Ca.', 'J.D.', 'Ausg.', 'evtl.', 'So.', 'i.B.', 's.a.', 'kgl.', 'Sept.', 'o.B.', 'Sa.', 'ev.', 'Dez.', 'am.', 'i.R.', 'eigtl.', 'i.J.', 'u.U.', 'G.', 'z.Hd.', 'u.A.w.g.', 'Kl.', 'Spezif.', 'Obj.', 'Ing.', 'D. h.', 'Folg.', 'Akt.', 'i.A.', 'Msp.', 'U.U.', 'Chr.', 'R.', 'Einh.', 'schwäb.', 'Vgl.', 'Aug.', 'Dipl.-Ing.', 'W.', 'B.', 'U. U.', 'J.', 'Fa.', 'Mo.', 'n.u.Z.', 'Op.', 'Mrd.', 'e.h.', 'Hr.', 'Hrn.', 'Ztr.', 'k. u. k.', 'Bibl.', 'd.Ä.', 'b.', 'M.', 'i.H.', 'v.R.w.', 'o.A.', 'St.', 'Dr.', 'Fn.', 'Abs.', 'Rd.', 'Dtzd.', 'Jahrh.', 'Z.', 'Std.', 'n. Chr.', 'möbl.', 'tägl.', 'gest.', 'gesch.', 'z.B.', 'Hbf.', 'Abt.', 'A.M.', 'e.Wz.', 'v.T.', 'Nov.', 'z.', 'Prot.', 'U.S.', 'Wg.', 'u.v.a.', 'Adr.', 'App.', 'ggf.', 'ggfs.', 'Jan.', 'O.', 'Rel.', 'od.', 'Pfd.', 'a.a.O.', 'p.Adr.', 'P.', 'Gem.', 'v. Chr.', 'Art.', 'z.Z.', 'S.A.', 'i.V.', 'verh.', 'Ausschl.', 'm.W.', 'Dir.', 'Verf.', 'Sek.', 'r.', 'Chin.', 'Feb.', 'Int.', 'Sep.', 'Gesch.', 'schweiz.', 'Bed.', 'a.Rh.', 'jew.', 'vgl.', 'a.M.', 'Str.', 'exkl.', 'gek.', 'Erf.', 'u.Ä.', 'ehem.', 'näml.', 'u. Z.', 'v. u. Z.', 'sog.', 'C.', 'Dipl.-Kfm.', 'mtl.', 'Hrsg.', 'Qu.', 'röm.', 'u.', 'U.', 'Adj.', 'Kap.', 'hpts.', 'a.D.', 'gedr.', 'Best.', 'N.', 'v.u.Z.', 'Phys.', 'Fr.', 'd.J.', 'Reg.-Bez.', 'm.E.', 'schles.', 'Max.', 'Ltd.', 'südd.', 'inkl.', 'geb.', 'Ggf.', 'Inc.', 'kath.', 'kfm.', 'Nr.', 'Proz.', 'Dim.', 'verw.', 'Reg.', 'Dat.', 'Evtl.', 'led.', 'F.', 'Test.', 'Schr.', 'Do.', 'PIN.', 'Z. Zt.', 'v.Chr.', 'Tägl.', 's.', 'amtl.', 'Temp.', 'Mind.', 'e.V.', 'Abw.', 'P.M.', 'F.f.', 'a.a.S.', 'Mod.', 'Co.', 'Min.', 'Allg.', 'Geograph.', 'Jr.', 'Urspr.', 'Apr.', 'Z. B.', 'v.H.', 'A.', 'einschl.', 'Trans.', 'zzgl.', 'StR.', 'Fam.', 'I.', 'jhrl.', 'u.a.', 'Ben.', 'o.g.', 'Kfm.', 'Konv.', 'Mi.', 'L.', 'beil.', 'T.', 'Ursprüngl.', 'röm.-kath.', 'Okt.', 'u.ä.', 'Tel.', 'D.', 'Ber.', 'Kop.', 'Mio.', 'Y.', 'U.S.A.', 'v. H.', 'Forts. f.', 'Rep.', 'Hptst.', 'österr.'],
|
|
4
|
+
'es': ['Rdos.', 'JJ.OO.', 'Sres.', 'fig.', 'may.', 'RR.HH.', 'oct.', 'cap.', 'mié.', 'doc.', 'Excmo.', 'Trab.', 'Excmos.', 'Kit.', 'Inc.', 'FF.CC.', 'DC.', 'ago.', 'trad.', 'SA.', 'Rvdos.', 'ed.', 'Exmo.', 'jul.', 'col.', 'RAM.', 'Srtas.', 'ene.', 'Rol.', 'Fabric.', 'Comm.', 'vid.', 'Da.', 'dic.', 'ss.', 'abr.', 'ntra.', 'Sra.', 'dtor.', 'cf.', 'dom.', 'prov.', 'Emm.', 'Sr.', 'licdo.', 'p.ej.', 'bol.', 'figs.', 'Vda.', 'Dr.', 'ntro.', 'Desv.', 'O.M.', 'Ldo.', 'Drs.', 'sáb.', 'feb.', 'Ltda.', 'Lcda.', 'Exma.', 'C.V.', 'SS.MM.', 'Lda.', 'U.S.', 'hnos.', 'R.D.', 'Korn.', 'v.gr.', 'vs.', 'Ilmas.', 'Rdo.', 'ej.', 'vie.', 'jue.', 'a. C.', 'Ilmos.', 'e. c.', 'Excma.', 'afma.', 'licda.', 'Em.', 'K.', 'sras.', 'MM.', 'fund.', 'Mons.', 'Lcdo.', 'afmo.', 'C.', 'A.C.', 'dptos.', 'Col.', 'Srta.', 'Av.', 'Ant.', 'depto.', 'Var.', 'H.P.', 'D.', 'M.', 'C.P.', 'Rev.', 'Rvdmos.', 'Fr.', 'Ilmo.', 'afmos.', 'Ltd.', 'afmas.', 'prof.', 'lun.', 'SS.AA.', 'Sol.', 'nov.', 'mss.', 'Dña.', 'Seg.', 'mar.', 'Rvdmo.', 'Reg.', 'ms.', 'Sras.', 'sres.', 'U.S.A.', 'Sta.', 'Sdad.', 'Dra.', 'srs.', 'R.U.', 'deptos.', 'dpto.', 'jun.', 'bco.', 'Cía.', 'Id.', 'Mr.', 'e.g.', 'C.S.', 'Excmas.', 'Dª.', 'Rvdo.', 'Lic.', 'cfr.', 'Corp.', 'Dto.', 'Ilma.', 'L.', 'All.', 'PP.', 'd. C.', 'Ltdo.', 'mtro.', 'Mrs.', 'Desc.', 'Avda.', 'Exmas.', 'a. e. c.', 'Bien.', 'Exmos.', 'AA.', 'Sto.', 'CA.', 'sept.', 'Exc.', 'c/c.'],
|
|
5
|
+
'fr': ['aux.', 'config.', 'collab.', 'M.', 'dim.', 'imprim.', 'oct.', 'syst.', 'bull.', 'MM.', 'doc.', 'P.O.', 'hôp.', 'Mart.', 'juil.', 'broch.', 'adr.', 'symb.', 'C.', 'anc.', 'voit.', 'Jr.', 'graph.', 'dir.', 'éd.', 'fig.', 'édit.', 'niv.', 'quart.', 'cam.', 'éval.', 'anon.', 'réf.', 'Comm.', 'Prof.', 'févr.', 'indus.', 'DC.', 'équiv.', 'illustr.', 'acoust.', 'nov.', 'L.', 'All.', 'U.S.', 'S.M.A.R.T.', 'sept.', 'avr.', 'jeu.', 'dest.', 'P.-D. G.', 'ill.', 'coll.', 'encycl.', 'mer.', 'Desc.', 'ven.', 'P.', 'lun.', 'Inc.', 'sam.', 'D.', 'append.', 'Var.', 'categ.', 'janv.', 'S.A.', 'imm.', 'U.S.A.', 'mar.', 'exempl.', 'déc.', 'ann.', 'U.', 'synth.', 'dict.', 'av. J.-C.', 'W.', 'Op.', 'ap. J.-C.', 'gouv.', 'trav. publ.'],
|
|
6
|
+
'it': ['N.B.', 'div.', 'a.C.', 'fig.', 'd.p.R.', 'c.c.p.', 'Cfr.', 'vol.', 'Geom.', 'O.d.G.', 'S.p.A.', 'ver.', 'N.d.A.', 'dott.', 'arch.', 'd.C.', 'N.d.T.', 'rag.', 'Sig.', 'Mod.', 'pag.', 'dr.', 'tav.', 'N.d.E.', 'DC.', 'mitt.', 'Ing.', 'int.', 'on.', 'C.P.', 'ag.', 'L.', 'U.S.', 'S.M.A.R.T.', 'p.i.', 'tab.', 'Ltd.', 'Liv.', 'D.', 'U.S.A.', 'sez.', 'avv.', 'S.A.R.', 'all.', 'p.'],
|
|
7
|
+
'pt': ['psicol.', 'fig.', 'compl.', 'rep.', 'cap.', 'doc.', 'fisiol.', 'dipl.', 'astron.', 'port.', 'eletrôn.', 'geom.', 'mov.', 'ago.', 'trad.', 'arquit.', 'dez.', 'ed.', 'apt.', 'Exmo.', 'col.', 'ff.', 'univ.', 'res.', 'R.', 'transp.', 'D.C', 'l.', 'des.', 'fev.', 'abr.', 'liter.', 'lat.', 'Dir.', 'cf.', 'adm.', 'fot.', 'p.m.', 'P.M.', 'créd.', 'jur.', 'com.', 'anat.', 'dir.', 'end.', 'fís.', 'E.', 'Est.', 'cont.', 'matem.', 'Drs.', 'gên.', 'neol.', 'pág.', 'índ.', 'Ltda.', 'Exma.', 'esp.', 'ingl.', 'tecnol.', 'Mar.', 'símb.', 'Pe.', 'pal.', 'filos.', 'V.T.', 'fasc.', 'vs.', 'mai.', 'S.A.', 'profa.', 'N.Sra.', 'r.s.v.p.', 'cel.', 'mat.', 'abrev.', 'out.', 'long.', 'aux.', 'arit.', 'aer.', 'jul.', 'lin.', 'S.', 'méd.', 'odontol.', 'org.', 'A.C.', 'jun.', 'déb.', 'Av.', 'álg.', 'sup.', 'fl.', 'odont.', 'caps.', 'relat.', 'organiz.', 'hist.', 'Fr.', 'Ilmo.', 'fem.', 'ap.', 'Ltd.', 'pol.', 'séc.', 'prof.', 'cx.', 'nov.', 'quím.', 'mús.', 'agric.', 'mar.', 'W.C.', 'fr.', 'cat.', 'jan.', 'pron.', 'rel.', 'autom.', 'Sta.', 'Dra.', 'p.', 'tel.', 'div.', 'p. ex.', 'a.C.', 'bras.', 'Alm.', 'Dr.', 'comp.', 'pq.', 'arqueol.', 'náut.', 'biogr.', 'f.', 'círc.', 'fac.', 'd.C.', 'apart.', 'ex.', 'Jr.', 'set.', 'tec.', 'sociol.', 'gram.', 'ind.', 'Ilma.', 'vol.', 'eng.', 'rod.', 'Ph.D.', 'Dras.', 'pp.', 'elem.', 'máq.', 'cód.', 'eletr.', 'prod.', 'ref.', 'fil.', 'a.m.', 'A.M', 'obs.', 'N.T.', 'contab.', 'Sto.', 'lit.', 'educ.', 'rementente', 'desc.', 'próx.'],
|
|
8
|
+
'ru': ['руб.', 'янв.', 'до н. э.', 'сент.', 'тел.', 'дек.', 'февр.', 'нояб.', 'апр.', 'н. э.', 'окт.', 'тыс.', 'авг.', 'проф.', 'н.э.', 'кв.', 'ул.', 'отд.'],
|
|
9
|
+
};
|
|
10
|
+
export const leadingApostropheContractionSuppressions = {
|
|
11
|
+
'en': [`'cause`, `'til`, `'bout`, `'twas`, `'tis`],
|
|
12
|
+
'af': [`'n`]
|
|
13
|
+
};
|
|
14
|
+
export const nounSuppressions = [
|
|
15
|
+
'C#', 'F#', 'C++', 'Yahoo!', 'Toys"R"Us', `Dunkin'`, 'Ke$ha', 'I/O', 'Sky+', 'A/C', 'A/V'
|
|
16
|
+
];
|
|
17
|
+
export const tldSuppressions = [
|
|
18
|
+
'.com', '.org', '.net', '.co', '.us'
|
|
19
|
+
];
|
|
20
|
+
// What about plural possesive English nouns like:
|
|
21
|
+
// The brothers' friend.
|
|
22
|
+
// The professors' books.
|
|
23
|
+
// Trees' roots.
|
|
24
|
+
// Diplomats' contracts.
|
|
25
|
+
//
|
|
26
|
+
// Not easy to confidently identify these.
|
|
27
|
+
// The apostrophe can also represent an ending single quotation mark,
|
|
28
|
+
// or a misplaced opening single quotation mark.
|
|
29
|
+
// Maybe if a word ends with `s'` and there is no opening `'` seen anywhere near,
|
|
30
|
+
// but that is still not 100% certain. The opening `'` may have appeared long before that.
|
|
31
|
+
//# sourceMappingURL=Suppressions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Suppressions.js","sourceRoot":"","sources":["../src/Suppressions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAA6B;IACzD,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM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O,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;CAC7J,CAAA;AAED,MAAM,CAAC,MAAM,wCAAwC,GAA6B;IACjF,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC;IAClD,IAAI,EAAE,CAAC,IAAI,CAAC;CACZ,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CACzF,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CACpC,CAAA;AAED,kDAAkD;AAClD,wBAAwB;AACxB,yBAAyB;AACzB,gBAAgB;AAChB,wBAAwB;AACxB,EAAE;AACF,0CAA0C;AAC1C,qEAAqE;AACrE,gDAAgD;AAChD,iFAAiF;AACjF,0FAA0F"}
|
package/dist/Test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/Test.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { segmentText, splitToWords } from "./TextSegmentation.js";
|
|
2
|
+
import { Timer } from "./utilities/Timer.js";
|
|
3
|
+
const log = console.log;
|
|
4
|
+
async function test1() {
|
|
5
|
+
{
|
|
6
|
+
const wordSequence = await splitToWords('Hello world! Привет мир! 你好世界!');
|
|
7
|
+
console.log(JSON.stringify(wordSequence.words));
|
|
8
|
+
}
|
|
9
|
+
const { readFileSync, writeFileSync } = await import('fs');
|
|
10
|
+
const text = readFileSync('test-data/Test.txt', 'utf-8');
|
|
11
|
+
const timer = new Timer();
|
|
12
|
+
const result = await segmentText(text, {
|
|
13
|
+
language: 'en',
|
|
14
|
+
customSuppressions: [],
|
|
15
|
+
enableEastAsianPostprocessing: true
|
|
16
|
+
});
|
|
17
|
+
//const json = JSON.stringify(result.sentences)
|
|
18
|
+
timer.logAndRestart(`Total execution time`);
|
|
19
|
+
log('');
|
|
20
|
+
//
|
|
21
|
+
let segmentedText = '';
|
|
22
|
+
for (let sentenceIndex = 0; sentenceIndex < result.sentences.length; sentenceIndex++) {
|
|
23
|
+
const sentence = result.sentences[sentenceIndex];
|
|
24
|
+
const phrases = sentence.phrases;
|
|
25
|
+
for (let phraseIndex = 0; phraseIndex < phrases.length; phraseIndex++) {
|
|
26
|
+
const phrase = phrases[phraseIndex];
|
|
27
|
+
segmentedText += phrase.wordSequence.words.join(' | ');
|
|
28
|
+
if (phraseIndex < phrases.length - 1) {
|
|
29
|
+
segmentedText += `\n${'-'.repeat(100)}\n`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (sentenceIndex < result.sentences.length - 1) {
|
|
33
|
+
segmentedText += `\n${'='.repeat(100)} \n`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
writeFileSync('out/segmented.txt', segmentedText);
|
|
37
|
+
}
|
|
38
|
+
test1();
|
|
39
|
+
//# sourceMappingURL=Test.js.map
|
package/dist/Test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Test.js","sourceRoot":"","sources":["../src/Test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE5C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;AAEvB,KAAK,UAAU,KAAK;IACnB,CAAC;QACA,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,gCAAgC,CAAC,CAAA;QACzE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KA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AG,CAAC,EAAE,CAAC;YACjD,aAAa,IAAI,KAAM,GAAG,CAAC,MAAM,CAAC,GAAG,CAAE,KAAK,CAAA;QAC7C,CAAC;IACF,CAAC;IAED,aAAa,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAA;AAClD,CAAC;AAED,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { WordSequence } from './WordSequence.js';
|
|
2
|
+
export { cldrSuppressions } from './Suppressions.js';
|
|
3
|
+
export declare function segmentText(text: string, options?: SegmentationOptions): Promise<SegmentationResult>;
|
|
4
|
+
export declare function segmentWordSequence(wordSequence: WordSequence): Promise<SegmentationResult>;
|
|
5
|
+
export declare function splitToWords(text: string, options?: SegmentationOptions): Promise<WordSequence>;
|
|
6
|
+
export interface SegmentationResult {
|
|
7
|
+
wordSequence: WordSequence;
|
|
8
|
+
sentences: Sentence[];
|
|
9
|
+
}
|
|
10
|
+
export declare class TextFragment {
|
|
11
|
+
wordRange: Range;
|
|
12
|
+
wordSequence: WordSequence;
|
|
13
|
+
constructor(wordRange: Range, wordSequence: WordSequence);
|
|
14
|
+
get text(): string;
|
|
15
|
+
get charRange(): Range;
|
|
16
|
+
}
|
|
17
|
+
export declare class Sentence extends TextFragment {
|
|
18
|
+
phrases: Phrase[];
|
|
19
|
+
}
|
|
20
|
+
export declare class Phrase extends TextFragment {
|
|
21
|
+
}
|
|
22
|
+
export interface Range {
|
|
23
|
+
start: number;
|
|
24
|
+
end: number;
|
|
25
|
+
}
|
|
26
|
+
export interface SegmentationOptions {
|
|
27
|
+
language?: string;
|
|
28
|
+
customSuppressions?: string[];
|
|
29
|
+
enableEastAsianPostprocessing?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare const defaultSegmentationOptions: SegmentationOptions;
|