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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ed56eae37e207da87cd709f4e8d5861912ece8ac0f6027fbc79be6341f03b94
4
- data.tar.gz: 025e100f05c4a9bd034c279b6d4e7a663be6ee755aacad030b37acc1a745dd48
3
+ metadata.gz: b89f4c9aed0238597b71b1f5bd1a32cd99e09448778c4fc486ff281dbbf60d45
4
+ data.tar.gz: 1123bad4fa5901d9f67e5c34a2783487af73dfb5c130999b96ca2b9c3f09b0eb
5
5
  SHA512:
6
- metadata.gz: 484c608422467566ae50f14f4cfb6995e180b2188ebef5ee48ea26ce106c0b2e96e56c82aa9b94ff7abaae7d43786ff7830a8058ce8f8e5f278afe97f153ac76
7
- data.tar.gz: f0c00c4cac25f8a9d8173968716e057f685752b98884de6730ca76bbfc8455fb9bbc04f7dab822adcaefe8b5d3b3c0beade6236f02b98b1a89432e25d0d373e6
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 tokenization and gold sentence boundaries
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, EWT-trained | 96.2 | 97.7 |
45
-
46
- For a fair reading of the numbers:
47
-
48
- * **EngTagger 2.0** is measured with the model file shipped in this gem. It
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, whose tags are valid element names. The text inside the tags is not
133
- escaped.
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 Adjective, cardinal number 3, fifteen
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 / Conjunction for, of, although, that
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 Symbol, list item A, A.
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 Determiner, prequalifier quite, all, half
151
- POS Possessive 's, '
152
- PRP Determiner, possessive second mine, yours
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 Adverb, particle up, off, out
162
+ RP Particle up, off, out
158
163
  SYM Symbol *
159
- TO Preposition to
164
+ TO Infinitive marker to (go)
160
165
  UH Interjection oh, yes, mmm
161
- VB Verb, infinitive take, live
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/passive participle taken, lived
165
- VBP Verb, base present form take, live
166
- VBZ Verb, present 3SG -s form takes, lives
167
- WDT Determiner, question which, whatever
168
- WP Pronoun, question who, whoever
169
- WPS Determiner, possessive & question whose
170
- WRB Adverb, question when, how, however
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, elipsis :, ..., -
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
- Requires Ruby >= 3.0 and nothing else. Pre-release versions are installed with
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, but the
208
- tags themselves are produced by a different, considerably more accurate
209
- engine, so tagged output is not byte-identical to 0.4.x. Tokenization also
210
- follows PTB/UD conventions more closely (e.g. `don't` splits as `do|n't`).
211
- Configuration keys of the retired HMM engine
212
- (`:relax`, `:unknown_word_tag`, lexicon paths) are accepted and ignored with
213
- a warning; `install`, `EngTagger.hmm`, `EngTagger.lexicon` and the
214
- `DEFAULT_LEXPATH`, `DEFAULT_WORDPATH` and `DEFAULT_TAGPATH` constants were
215
- removed. `assign_tag(prev_tag, word)` still tags one word from the tag before
216
- it, but it does not see the surrounding words; use `tag_pairs` or `add_tags`
217
- wherever the whole text is available.
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 in 2009 as a Ruby port of Lingua::EN::Tagger by Aaron Coburn.
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class EngTagger
4
- VERSION = "2.0.0.pre2"
4
+ VERSION = "2.0.0.pre3"
5
5
  end
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", "Adjective, cardinal number",
72
+ "CD", "Cardinal number",
73
73
  "DET", "Determiner",
74
74
  "EX", "Pronoun, existential there",
75
75
  "FW", "Foreign words",
76
- "IN", "Preposition / Conjunction",
76
+ "IN", "Preposition / Subordinating conjunction",
77
77
  "JJ", "Adjective",
78
78
  "JJR", "Adjective, comparative",
79
79
  "JJS", "Adjective, superlative",
80
- "LS", "Symbol, list item",
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", "Determiner, prequalifier",
87
- "POS", "Possessive",
88
- "PRP", "Determiner, possessive second",
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", "Adverb, particle",
93
+ "RP", "Particle",
94
94
  "SYM", "Symbol",
95
- "TO", "Preposition",
95
+ "TO", "Infinitive marker",
96
96
  "UH", "Interjection",
97
- "VB", "Verb, infinitive",
97
+ "VB", "Verb, base form",
98
98
  "VBD", "Verb, past tense",
99
99
  "VBG", "Verb, gerund or present participle",
100
- "VBN", "Verb, past/passive participle",
101
- "VBP", "Verb, base present form",
102
- "VBZ", "Verb, present 3SG -s form",
103
- "WDT", "Determiner, question",
104
- "WP", "Pronoun, question",
105
- "WPS", "Determiner, possessive & question",
106
- "WRB", "Adverb, question",
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, elipsis",
112
+ "PPS", "Punctuation, colon, semicolon, ellipsis",
113
113
  "LRB", "Punctuation, left bracket",
114
114
  "RRB", "Punctuation, right bracket"
115
115
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engtagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre2
4
+ version: 2.0.0.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichiro Hasebe