engtagger 2.0.0.pre2 → 2.0.0.pre3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/README.md +61 -61
- data/lib/engtagger/version.rb +1 -1
- data/lib/engtagger.rb +17 -17
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b89f4c9aed0238597b71b1f5bd1a32cd99e09448778c4fc486ff281dbbf60d45
|
|
4
|
+
data.tar.gz: 1123bad4fa5901d9f67e5c34a2783487af73dfb5c130999b96ca2b9c3f09b0eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e81868b829d035cd540c27bad7e2a97f4a6e82930f3fa360ea2c05c0685b6de1fc9247cbea8fe89ae2e8573de0169dffaa65c9d5eccfd51bc9f8075a9be1a0f5
|
|
7
|
+
data.tar.gz: 478095438721d6b67c34df79871a02a6215480c2b4136c87eb5144045b2f2b8c05400f7e7a91abb673f9d437c9a4a3d74ae4e9ca89fdd05d06c262cc4d8cfa66
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,7 @@ A rewrite of the tagging engine. Tagging and tokenization output differ from 0.4
|
|
|
8
8
|
- Add a PTB/UD-compatible tokenizer whose tokens are substrings of the input.
|
|
9
9
|
- Add the `tagset: :ptb` option, which makes `tag_pairs` and `get_readable` emit standard Penn Treebank tags.
|
|
10
10
|
- Remove the HMM probability tables derived from the Penn Treebank, `install`, `EngTagger.hmm`, `EngTagger.lexicon` and the `DEFAULT_*PATH` constants.
|
|
11
|
+
- Correct the descriptions of several tags; the verbose names from `EngTagger.explain_tag`, `add_tags(text, true)` and `get_readable(text, true)` change accordingly.
|
|
11
12
|
- Keep `assign_tag(prev_tag, word)`, which now tags one word with the bundled model.
|
|
12
13
|
- Ignore the configuration keys of the HMM engine (`:relax`, `:unknown_word_tag`, lexicon paths) with a warning.
|
|
13
14
|
- Remove the `sin_lru_redux` dependency; the gem has no runtime dependencies.
|
data/README.md
CHANGED
|
@@ -33,30 +33,19 @@ Token accuracy (%) on the test splits of two Universal Dependencies English
|
|
|
33
33
|
treebanks — [EWT](https://universaldependencies.org/treebanks/en_ewt/) (web
|
|
34
34
|
media: reviews, emails, forums) and
|
|
35
35
|
[GUM](https://universaldependencies.org/treebanks/en_gum/) (multi-genre) —
|
|
36
|
-
using Penn Treebank tags, gold
|
|
37
|
-
(Universal Dependencies release 2.18):
|
|
36
|
+
using Penn Treebank tags, gold sentence boundaries and, except where noted,
|
|
37
|
+
gold tokenization (Universal Dependencies release 2.18):
|
|
38
38
|
|
|
39
39
|
| System | Algorithm | EWT test | GUM test |
|
|
40
40
|
|---|---|---|---|
|
|
41
|
-
| EngTagger 0.4 (previous) | HMM (bigram) | 84.9 | 88.4 |
|
|
42
|
-
| NLTK 3 | averaged perceptron, WSJ-trained | 85.1 | 90.4 |
|
|
41
|
+
| EngTagger 0.4.3 (previous) | HMM (bigram) | 84.9\* | 88.4\* |
|
|
42
|
+
| NLTK 3.10.3 | averaged perceptron, WSJ-trained | 85.1 | 90.4 |
|
|
43
43
|
| **EngTagger 2.0 (this gem)** | **averaged perceptron** | **94.2** | **95.7** |
|
|
44
|
-
| Stanza | neural
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
is trained on the EWT training split and on automatically tagged text from
|
|
50
|
-
Wikipedia, Wikinews and Stack Exchange. No GUM annotations were used in
|
|
51
|
-
training, so GUM is a held-out treebank for it.
|
|
52
|
-
* The figures are for text that is already split into sentences and tokens.
|
|
53
|
-
Tagging raw text also depends on the tokenizer.
|
|
54
|
-
* **NLTK 3** uses the same algorithm family as EngTagger 2.0 but its bundled
|
|
55
|
-
model is trained on Wall Street Journal text, so it runs out-of-domain on
|
|
56
|
-
these test sets.
|
|
57
|
-
* **Stanza** is a neural pipeline (Python/PyTorch, large models) trained on
|
|
58
|
-
EWT itself; it serves as the accuracy reference point, at the cost of
|
|
59
|
-
dependencies and compute.
|
|
44
|
+
| Stanza 1.15.1 (default model) | neural | 96.2 | 97.6 |
|
|
45
|
+
|
|
46
|
+
\* EngTagger 0.4.3 tokenizes its input itself, so it is scored on the
|
|
47
|
+
sentences it splits the same way as the treebank (71% of the tokens of EWT
|
|
48
|
+
test, 79% of GUM test). On those sentences EngTagger 2.0 scores 94.1 (EWT) and 95.8 (GUM).
|
|
60
49
|
|
|
61
50
|
## Synopsis
|
|
62
51
|
|
|
@@ -121,6 +110,17 @@ ptb.tag_pairs("Alice chased the cat.")
|
|
|
121
110
|
#=> [["Alice", :NNP], ["chased", :VBD], ["the", :DT], ["cat", :NN], [".", :"."]]
|
|
122
111
|
```
|
|
123
112
|
|
|
113
|
+
## Options
|
|
114
|
+
|
|
115
|
+
```ruby
|
|
116
|
+
EngTagger.new(
|
|
117
|
+
tagset: :ptb, # standard tags from tag_pairs and get_readable (default: classic tagset)
|
|
118
|
+
stem: true, # stem the words returned by the extraction methods (default: false)
|
|
119
|
+
longest_noun_phrase: 3, # longest noun phrase to extract, in words (default: 5)
|
|
120
|
+
weight_noun_phrases: true # multiply the count of a noun phrase by its length in words (default: false)
|
|
121
|
+
)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
124
|
## Tag Set
|
|
125
125
|
|
|
126
126
|
`add_tags`, `tag_pairs` and `get_readable` use the classic EngTagger tagset by
|
|
@@ -129,52 +129,57 @@ characters are renamed to work in XML-style markup and regular expressions
|
|
|
129
129
|
(`DET` for `DT`, `PRPS` for `PRP$`, and named punctuation classes such as `PP`
|
|
130
130
|
for `.`). With `EngTagger.new(tagset: :ptb)`, `tag_pairs` and `get_readable`
|
|
131
131
|
emit standard Penn Treebank tags instead; `add_tags` always uses the classic
|
|
132
|
-
tagset
|
|
133
|
-
|
|
132
|
+
tagset. The text inside the tags is not escaped.
|
|
133
|
+
|
|
134
|
+
With `tagset: :ptb`, the extended Penn Treebank tags used by Universal
|
|
135
|
+
Dependencies also appear: `HYPH` (hyphen), `ADD` (e-mail address or URL),
|
|
136
|
+
`NFP` (emoticon or other superfluous punctuation), `AFX` (affix) and `GW`
|
|
137
|
+
(part of a word written apart). The classic tagset folds them into `PPC`,
|
|
138
|
+
`NN`, `SYM`, `JJ` and `NN`.
|
|
134
139
|
|
|
135
140
|
CC Conjunction, coordinating and, or
|
|
136
|
-
CD
|
|
141
|
+
CD Cardinal number 3, fifteen
|
|
137
142
|
DET Determiner this, each, some
|
|
138
143
|
EX Pronoun, existential there there
|
|
139
144
|
FW Foreign words
|
|
140
|
-
IN Preposition /
|
|
145
|
+
IN Preposition / Subordinating conjunction for, of, to, although, that
|
|
141
146
|
JJ Adjective happy, bad
|
|
142
147
|
JJR Adjective, comparative happier, worse
|
|
143
148
|
JJS Adjective, superlative happiest, worst
|
|
144
|
-
LS
|
|
149
|
+
LS List item marker 1, 2 (in lists)
|
|
145
150
|
MD Verb, modal can, could, 'll
|
|
146
151
|
NN Noun aircraft, data
|
|
147
152
|
NNP Noun, proper London, Michael
|
|
148
153
|
NNPS Noun, proper, plural Australians, Methodists
|
|
149
154
|
NNS Noun, plural women, books
|
|
150
|
-
PDT
|
|
151
|
-
POS Possessive
|
|
152
|
-
PRP
|
|
155
|
+
PDT Predeterminer all, half
|
|
156
|
+
POS Possessive ending 's, '
|
|
157
|
+
PRP Pronoun, personal I, him, mine, yours
|
|
153
158
|
PRPS Determiner, possessive their, your
|
|
154
159
|
RB Adverb often, not, very, here
|
|
155
160
|
RBR Adverb, comparative faster
|
|
156
161
|
RBS Adverb, superlative fastest
|
|
157
|
-
RP
|
|
162
|
+
RP Particle up, off, out
|
|
158
163
|
SYM Symbol *
|
|
159
|
-
TO
|
|
164
|
+
TO Infinitive marker to (go)
|
|
160
165
|
UH Interjection oh, yes, mmm
|
|
161
|
-
VB Verb,
|
|
166
|
+
VB Verb, base form take, live
|
|
162
167
|
VBD Verb, past tense took, lived
|
|
163
168
|
VBG Verb, gerund or present participle taking, living
|
|
164
|
-
VBN Verb, past
|
|
165
|
-
VBP Verb,
|
|
166
|
-
VBZ Verb, present
|
|
167
|
-
WDT
|
|
168
|
-
WP
|
|
169
|
-
WPS
|
|
170
|
-
WRB
|
|
169
|
+
VBN Verb, past participle taken, lived
|
|
170
|
+
VBP Verb, present, non-3rd-person singular take, am, are
|
|
171
|
+
VBZ Verb, present, 3rd-person singular takes, is, has
|
|
172
|
+
WDT Wh-determiner which, whatever
|
|
173
|
+
WP Wh-pronoun who, whoever
|
|
174
|
+
WPS Possessive wh-pronoun whose
|
|
175
|
+
WRB Wh-adverb when, how, where
|
|
171
176
|
|
|
172
177
|
PP Punctuation, sentence ender ., !, ?
|
|
173
178
|
PPC Punctuation, comma ,
|
|
174
179
|
PPD Punctuation, dollar sign $
|
|
175
180
|
PPL Punctuation, quotation mark left ``
|
|
176
181
|
PPR Punctuation, quotation mark right ''
|
|
177
|
-
PPS Punctuation, colon, semicolon,
|
|
182
|
+
PPS Punctuation, colon, semicolon, ellipsis :, ;, ...
|
|
178
183
|
LRB Punctuation, left bracket (, {, [
|
|
179
184
|
RRB Punctuation, right bracket ), }, ]
|
|
180
185
|
|
|
@@ -189,32 +194,31 @@ The tagger ships with an averaged-perceptron model
|
|
|
189
194
|
automatically with a large language model. Every article and post is listed
|
|
190
195
|
with its licence in [`sources/`](https://github.com/yohasebe/engtagger/tree/master/sources).
|
|
191
196
|
|
|
192
|
-
Unlike the 0.4.x line, no Penn Treebank-derived data is included. Provenance
|
|
193
|
-
and attribution details are in the NOTICE file; the packed model format is
|
|
194
|
-
documented in the repository (`docs/model-format.md`).
|
|
195
|
-
|
|
196
197
|
## Installation
|
|
197
198
|
|
|
198
199
|
```bash
|
|
199
200
|
gem install engtagger
|
|
200
201
|
```
|
|
201
202
|
|
|
202
|
-
|
|
203
|
-
`gem install engtagger --pre`.
|
|
203
|
+
Pre-release versions are installed with `gem install engtagger --pre`.
|
|
204
204
|
|
|
205
205
|
## Upgrading from 0.4.x
|
|
206
206
|
|
|
207
|
-
The tagging and extraction methods keep their names and arguments
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
follows PTB/UD conventions more closely (e.g. `don't` splits
|
|
211
|
-
|
|
212
|
-
(`:relax`, `:unknown_word_tag`,
|
|
213
|
-
|
|
214
|
-
`
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
207
|
+
* The tagging and extraction methods keep their names and arguments.
|
|
208
|
+
* Tagged output differs from 0.4.x: the tags come from a different,
|
|
209
|
+
considerably more accurate engine.
|
|
210
|
+
* Tokenization follows PTB/UD conventions more closely (e.g. `don't` splits
|
|
211
|
+
as `do|n't` and `well-known` as `well|-|known`).
|
|
212
|
+
* The configuration keys of the HMM engine (`:relax`, `:unknown_word_tag`,
|
|
213
|
+
lexicon paths) are ignored with a warning.
|
|
214
|
+
* `install`, `EngTagger.hmm`, `EngTagger.lexicon` and the `DEFAULT_LEXPATH`,
|
|
215
|
+
`DEFAULT_WORDPATH` and `DEFAULT_TAGPATH` constants were removed.
|
|
216
|
+
* The descriptions of several tags were corrected (see [Tag Set](#tag-set)),
|
|
217
|
+
so the verbose names from `EngTagger.explain_tag`, `add_tags(text, true)`
|
|
218
|
+
and `get_readable(text, true)` differ; update code that matches them.
|
|
219
|
+
* `assign_tag(prev_tag, word)` tags one word from the tag before it, without
|
|
220
|
+
seeing the surrounding words; use `tag_pairs` or `add_tags` wherever the
|
|
221
|
+
whole text is available.
|
|
218
222
|
|
|
219
223
|
If you need the old engine's exact output, pin the previous line:
|
|
220
224
|
|
|
@@ -226,11 +230,7 @@ gem "engtagger", "~> 0.4"
|
|
|
226
230
|
|
|
227
231
|
Yoichiro Hasebe
|
|
228
232
|
|
|
229
|
-
EngTagger began
|
|
230
|
-
Version 2.0 replaces its HMM tagger and probability tables with a new
|
|
231
|
-
averaged-perceptron tagger, tokenizer and trained model. The extraction of
|
|
232
|
-
nouns and noun phrases and the formatting of tagged output retain routines
|
|
233
|
-
ported and adapted from Lingua::EN::Tagger.
|
|
233
|
+
EngTagger began as a Ruby port of Lingua::EN::Tagger by Aaron Coburn.
|
|
234
234
|
|
|
235
235
|
## License
|
|
236
236
|
|
data/lib/engtagger/version.rb
CHANGED
data/lib/engtagger.rb
CHANGED
|
@@ -69,47 +69,47 @@ class EngTagger
|
|
|
69
69
|
# used by the explain_tag method
|
|
70
70
|
tags = [
|
|
71
71
|
"CC", "Conjunction, coordinating",
|
|
72
|
-
"CD", "
|
|
72
|
+
"CD", "Cardinal number",
|
|
73
73
|
"DET", "Determiner",
|
|
74
74
|
"EX", "Pronoun, existential there",
|
|
75
75
|
"FW", "Foreign words",
|
|
76
|
-
"IN", "Preposition /
|
|
76
|
+
"IN", "Preposition / Subordinating conjunction",
|
|
77
77
|
"JJ", "Adjective",
|
|
78
78
|
"JJR", "Adjective, comparative",
|
|
79
79
|
"JJS", "Adjective, superlative",
|
|
80
|
-
"LS", "
|
|
80
|
+
"LS", "List item marker",
|
|
81
81
|
"MD", "Verb, modal",
|
|
82
82
|
"NN", "Noun",
|
|
83
83
|
"NNP", "Noun, proper",
|
|
84
84
|
"NNPS", "Noun, proper, plural",
|
|
85
85
|
"NNS", "Noun, plural",
|
|
86
|
-
"PDT", "
|
|
87
|
-
"POS", "Possessive",
|
|
88
|
-
"PRP", "
|
|
86
|
+
"PDT", "Predeterminer",
|
|
87
|
+
"POS", "Possessive ending",
|
|
88
|
+
"PRP", "Pronoun, personal",
|
|
89
89
|
"PRPS", "Determiner, possessive",
|
|
90
90
|
"RB", "Adverb",
|
|
91
91
|
"RBR", "Adverb, comparative",
|
|
92
92
|
"RBS", "Adverb, superlative",
|
|
93
|
-
"RP", "
|
|
93
|
+
"RP", "Particle",
|
|
94
94
|
"SYM", "Symbol",
|
|
95
|
-
"TO", "
|
|
95
|
+
"TO", "Infinitive marker",
|
|
96
96
|
"UH", "Interjection",
|
|
97
|
-
"VB", "Verb,
|
|
97
|
+
"VB", "Verb, base form",
|
|
98
98
|
"VBD", "Verb, past tense",
|
|
99
99
|
"VBG", "Verb, gerund or present participle",
|
|
100
|
-
"VBN", "Verb, past
|
|
101
|
-
"VBP", "Verb,
|
|
102
|
-
"VBZ", "Verb, present
|
|
103
|
-
"WDT", "
|
|
104
|
-
"WP", "
|
|
105
|
-
"WPS", "
|
|
106
|
-
"WRB", "
|
|
100
|
+
"VBN", "Verb, past participle",
|
|
101
|
+
"VBP", "Verb, present, non-3rd-person singular",
|
|
102
|
+
"VBZ", "Verb, present, 3rd-person singular",
|
|
103
|
+
"WDT", "Wh-determiner",
|
|
104
|
+
"WP", "Wh-pronoun",
|
|
105
|
+
"WPS", "Possessive wh-pronoun",
|
|
106
|
+
"WRB", "Wh-adverb",
|
|
107
107
|
"PP", "Punctuation, sentence ender",
|
|
108
108
|
"PPC", "Punctuation, comma",
|
|
109
109
|
"PPD", "Punctuation, dollar sign",
|
|
110
110
|
"PPL", "Punctuation, quotation mark left",
|
|
111
111
|
"PPR", "Punctuation, quotation mark right",
|
|
112
|
-
"PPS", "Punctuation, colon, semicolon,
|
|
112
|
+
"PPS", "Punctuation, colon, semicolon, ellipsis",
|
|
113
113
|
"LRB", "Punctuation, left bracket",
|
|
114
114
|
"RRB", "Punctuation, right bracket"
|
|
115
115
|
]
|