Skip to content

Commit bc71a77

Browse files
authored
Merge pull request #28 from pharo-ai/follow-naming-conventions
Follow naming conventions
2 parents 6a1476d + 5d741a1 commit bc71a77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+397
-368
lines changed

.smalltalk.ston

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
SmalltalkCISpec {
33
#loading : [
44
SCIMetacelloLoadSpec {
5-
#baseline : 'NgramModel',
6-
#directory : 'src',
7-
#platforms : [ #pharo ]
5+
#baseline : 'AINgramModel',
6+
#directory : 'src'
87
}
98
],
109
#testing : {
1110
#coverage : {
12-
#packages : [ 'NgramModel*' ]
11+
#packages : [ 'AI-NgramModel*' ]
1312
}
1413
}
1514
}

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To install the packages of NgramModel, go to the Playground (Ctrl+OW) in your Ph
1313

1414
```Smalltalk
1515
Metacello new
16-
baseline: 'NgramModel';
16+
baseline: 'AINgramModel';
1717
repository: 'github://pharo-ai/NgramModel/src';
1818
load
1919
```
@@ -72,7 +72,7 @@ This package provides only one class - `Ngram`. It models the n-gram.
7272
You can create n-gram from any `SequenceableCollection`:
7373

7474
```Smalltalk
75-
trigram := Ngram withElements: #(do not like).
75+
trigram := AINgram withElements: #(do not like).
7676
tetragram := #(green eggs and ham) asNgram.
7777
```
7878

@@ -82,13 +82,13 @@ Or by explicitly providing the history (n-gram of lower order) and last element:
8282
hist := #(green eggs and) asNgram.
8383
w := 'ham'.
8484
85-
ngram := Ngram withHistory: hist last: w.
85+
ngram := AINgram withHistory: hist last: w.
8686
```
8787

8888
You can also create a zerogram - n-gram of order 0. It is an empty sequence with no history and no last word:
8989

9090
```Smalltalk
91-
Ngram zerogram.
91+
AINgram zerogram.
9292
```
9393

9494
### Accessing
@@ -115,13 +115,13 @@ brown := file contents.
115115
```
116116
#### 2. Training a 2-gram language model on the corpus
117117
```Smalltalk
118-
model := NgramModel order: 2.
118+
model := AINgramModel order: 2.
119119
model trainOn: brown.
120120
```
121121
#### 3. Generating text of 100 words
122122
At each step the model selects top 5 words that are most likely to follow the previous words and returns the random word from those five (this randomnes ensures that the generator does not get stuck in a cycle).
123123
```Smalltalk
124-
generator := NgramTextGenerator new model: model.
124+
generator := AINgramTextGenerator new model: model.
125125
generator generateTextOfSize: 100.
126126
```
127127
## Result:

src/Ngram-Tests/NgramSequenceableCollectionTest.class.st renamed to src/AI-Ngram-Tests/AINgramSequenceableCollectionTest.class.st

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
Class {
2-
#name : #NgramSequenceableCollectionTest,
2+
#name : #AINgramSequenceableCollectionTest,
33
#superclass : #TestCase,
4-
#instVars : [
5-
'collection'
6-
],
7-
#category : #'Ngram-Tests'
4+
#category : #'AI-Ngram-Tests'
85
}
96

10-
{ #category : #running }
11-
NgramSequenceableCollectionTest >> setUp [
12-
super setUp.
13-
collection := #(I do not like green eggs and ham).
7+
{ #category : #accessing }
8+
AINgramSequenceableCollectionTest >> collection [
9+
10+
^ #( I do not like green eggs and ham )
1411
]
1512

1613
{ #category : #tests }
17-
NgramSequenceableCollectionTest >> testAsNgram [
14+
AINgramSequenceableCollectionTest >> testAsNgram [
1815
| ngram |
19-
ngram := collection asNgram.
16+
ngram := self collection asNgram.
2017
self assert: ngram order equals: 8.
2118
self assert: ngram history equals: #(I do not like green eggs and) asNgram.
2219
self assert: ngram last equals: 'ham'.
2320
]
2421

2522
{ #category : #tests }
26-
NgramSequenceableCollectionTest >> testBigrams [
23+
AINgramSequenceableCollectionTest >> testBigrams [
2724
| expected actual |
2825

2926
expected := {
@@ -35,12 +32,12 @@ NgramSequenceableCollectionTest >> testBigrams [
3532
#(eggs and) asNgram .
3633
#(and ham) asNgram }.
3734

38-
actual := collection bigrams.
35+
actual := self collection bigrams.
3936
self assert: actual equals: expected.
4037
]
4138

4239
{ #category : #tests }
43-
NgramSequenceableCollectionTest >> testBigramsPadWith [
40+
AINgramSequenceableCollectionTest >> testBigramsPadWith [
4441
| expected actual |
4542

4643
expected := {
@@ -54,12 +51,12 @@ NgramSequenceableCollectionTest >> testBigramsPadWith [
5451
#(and ham) asNgram .
5552
#(ham '##') asNgram }.
5653

57-
actual := collection bigramsPadWith: '##'.
54+
actual := self collection bigramsPadWith: '##'.
5855
self assert: actual equals: expected.
5956
]
6057

6158
{ #category : #tests }
62-
NgramSequenceableCollectionTest >> testBigramsWithDefaultPadding [
59+
AINgramSequenceableCollectionTest >> testBigramsWithDefaultPadding [
6360
| expected actual |
6461

6562
expected := {
@@ -73,12 +70,12 @@ NgramSequenceableCollectionTest >> testBigramsWithDefaultPadding [
7370
#(and ham) asNgram .
7471
#(ham '<s>') asNgram }.
7572

76-
actual := collection bigramsWithDefaultPadding.
73+
actual := self collection bigramsWithDefaultPadding.
7774
self assert: actual equals: expected.
7875
]
7976

8077
{ #category : #tests }
81-
NgramSequenceableCollectionTest >> testNgrams [
78+
AINgramSequenceableCollectionTest >> testNgrams [
8279
| expected actual |
8380

8481
expected := {
@@ -89,12 +86,12 @@ NgramSequenceableCollectionTest >> testNgrams [
8986
#(green eggs and) asNgram .
9087
#(eggs and ham) asNgram }.
9188

92-
actual := collection ngrams: 3.
89+
actual := self collection ngrams: 3.
9390
self assert: actual equals: expected.
9491
]
9592

9693
{ #category : #tests }
97-
NgramSequenceableCollectionTest >> testNgramsPadWith [
94+
AINgramSequenceableCollectionTest >> testNgramsPadWith [
9895
| expected actual |
9996

10097
expected := {
@@ -109,12 +106,12 @@ NgramSequenceableCollectionTest >> testNgramsPadWith [
109106
#(and ham '##') asNgram .
110107
#(ham '##' '##') asNgram }.
111108

112-
actual := collection ngrams: 3 padWith: '##'.
109+
actual := self collection ngrams: 3 padWith: '##'.
113110
self assert: actual equals: expected.
114111
]
115112

116113
{ #category : #tests }
117-
NgramSequenceableCollectionTest >> testNgramsWithDefaultPadding [
114+
AINgramSequenceableCollectionTest >> testNgramsWithDefaultPadding [
118115
| expected actual |
119116

120117
expected := {
@@ -129,12 +126,12 @@ NgramSequenceableCollectionTest >> testNgramsWithDefaultPadding [
129126
#(and ham '<s>') asNgram .
130127
#(ham '<s>' '<s>') asNgram }.
131128

132-
actual := collection ngramsWithDefaultPadding: 3.
129+
actual := self collection ngramsWithDefaultPadding: 3.
133130
self assert: actual equals: expected.
134131
]
135132

136133
{ #category : #tests }
137-
NgramSequenceableCollectionTest >> testPentagrams [
134+
AINgramSequenceableCollectionTest >> testPentagrams [
138135
| expected actual |
139136

140137
expected := {
@@ -143,12 +140,12 @@ NgramSequenceableCollectionTest >> testPentagrams [
143140
#(not like green eggs and) asNgram .
144141
#(like green eggs and ham) asNgram }.
145142

146-
actual := collection pentagrams.
143+
actual := self collection pentagrams.
147144
self assert: actual equals: expected.
148145
]
149146

150147
{ #category : #tests }
151-
NgramSequenceableCollectionTest >> testPentagramsPadWith [
148+
AINgramSequenceableCollectionTest >> testPentagramsPadWith [
152149
| expected actual |
153150

154151
expected := {
@@ -165,12 +162,12 @@ NgramSequenceableCollectionTest >> testPentagramsPadWith [
165162
#(and ham '##' '##' '##') asNgram .
166163
#(ham '##' '##' '##' '##') asNgram }.
167164

168-
actual := collection pentagramsPadWith: '##'.
165+
actual := self collection pentagramsPadWith: '##'.
169166
self assert: actual equals: expected.
170167
]
171168

172169
{ #category : #tests }
173-
NgramSequenceableCollectionTest >> testPentagramsWithDefaultPadding [
170+
AINgramSequenceableCollectionTest >> testPentagramsWithDefaultPadding [
174171
| expected actual |
175172

176173
expected := {
@@ -187,12 +184,12 @@ NgramSequenceableCollectionTest >> testPentagramsWithDefaultPadding [
187184
#(and ham '<s>' '<s>' '<s>') asNgram .
188185
#(ham '<s>' '<s>' '<s>' '<s>') asNgram }.
189186

190-
actual := collection pentagramsWithDefaultPadding.
187+
actual := self collection pentagramsWithDefaultPadding.
191188
self assert: actual equals: expected.
192189
]
193190

194191
{ #category : #tests }
195-
NgramSequenceableCollectionTest >> testTetragrams [
192+
AINgramSequenceableCollectionTest >> testTetragrams [
196193
| expected actual |
197194

198195
expected := {
@@ -202,12 +199,12 @@ NgramSequenceableCollectionTest >> testTetragrams [
202199
#(like green eggs and) asNgram .
203200
#(green eggs and ham) asNgram }.
204201

205-
actual := collection tetragrams.
202+
actual := self collection tetragrams.
206203
self assert: actual equals: expected.
207204
]
208205

209206
{ #category : #tests }
210-
NgramSequenceableCollectionTest >> testTetragramsPadWith [
207+
AINgramSequenceableCollectionTest >> testTetragramsPadWith [
211208
| expected actual |
212209

213210
expected := {
@@ -223,12 +220,12 @@ NgramSequenceableCollectionTest >> testTetragramsPadWith [
223220
#(and ham '##' '##') asNgram .
224221
#(ham '##' '##' '##') asNgram }.
225222

226-
actual := collection tetragramsPadWith: '##'.
223+
actual := self collection tetragramsPadWith: '##'.
227224
self assert: actual equals: expected.
228225
]
229226

230227
{ #category : #tests }
231-
NgramSequenceableCollectionTest >> testTetragramsWithDefaultPadding [
228+
AINgramSequenceableCollectionTest >> testTetragramsWithDefaultPadding [
232229
| expected actual |
233230

234231
expected := {
@@ -244,12 +241,12 @@ NgramSequenceableCollectionTest >> testTetragramsWithDefaultPadding [
244241
#(and ham '<s>' '<s>') asNgram .
245242
#(ham '<s>' '<s>' '<s>') asNgram }.
246243

247-
actual := collection tetragramsWithDefaultPadding.
244+
actual := self collection tetragramsWithDefaultPadding.
248245
self assert: actual equals: expected.
249246
]
250247

251248
{ #category : #tests }
252-
NgramSequenceableCollectionTest >> testTrigrams [
249+
AINgramSequenceableCollectionTest >> testTrigrams [
253250
| expected actual |
254251

255252
expected := {
@@ -260,12 +257,12 @@ NgramSequenceableCollectionTest >> testTrigrams [
260257
#(green eggs and) asNgram .
261258
#(eggs and ham) asNgram }.
262259

263-
actual := collection trigrams.
260+
actual := self collection trigrams.
264261
self assert: actual equals: expected.
265262
]
266263

267264
{ #category : #tests }
268-
NgramSequenceableCollectionTest >> testTrigramsPadWith [
265+
AINgramSequenceableCollectionTest >> testTrigramsPadWith [
269266
| expected actual |
270267

271268
expected := {
@@ -280,12 +277,12 @@ NgramSequenceableCollectionTest >> testTrigramsPadWith [
280277
#(and ham '##') asNgram .
281278
#(ham '##' '##') asNgram }.
282279

283-
actual := collection trigramsPadWith: '##'.
280+
actual := self collection trigramsPadWith: '##'.
284281
self assert: actual equals: expected.
285282
]
286283

287284
{ #category : #tests }
288-
NgramSequenceableCollectionTest >> testTrigramsWithDefaultPadding [
285+
AINgramSequenceableCollectionTest >> testTrigramsWithDefaultPadding [
289286
| expected actual |
290287

291288
expected := {
@@ -300,12 +297,12 @@ NgramSequenceableCollectionTest >> testTrigramsWithDefaultPadding [
300297
#(and ham '<s>') asNgram .
301298
#(ham '<s>' '<s>') asNgram }.
302299

303-
actual := collection trigramsWithDefaultPadding.
300+
actual := self collection trigramsWithDefaultPadding.
304301
self assert: actual equals: expected.
305302
]
306303

307304
{ #category : #tests }
308-
NgramSequenceableCollectionTest >> testUnigrams [
305+
AINgramSequenceableCollectionTest >> testUnigrams [
309306
| expected actual |
310307

311308
expected := {
@@ -318,12 +315,12 @@ NgramSequenceableCollectionTest >> testUnigrams [
318315
#(and) asNgram .
319316
#(ham) asNgram }.
320317

321-
actual := collection unigrams.
318+
actual := self collection unigrams.
322319
self assert: actual equals: expected.
323320
]
324321

325322
{ #category : #tests }
326-
NgramSequenceableCollectionTest >> testUnigramsPadWith [
323+
AINgramSequenceableCollectionTest >> testUnigramsPadWith [
327324
| expected actual |
328325

329326
expected := {
@@ -336,12 +333,12 @@ NgramSequenceableCollectionTest >> testUnigramsPadWith [
336333
#(and) asNgram .
337334
#(ham) asNgram }.
338335

339-
actual := collection unigramsPadWith: '##'.
336+
actual := self collection unigramsPadWith: '##'.
340337
self assert: actual equals: expected.
341338
]
342339

343340
{ #category : #tests }
344-
NgramSequenceableCollectionTest >> testUnigramsWithDefaultPadding [
341+
AINgramSequenceableCollectionTest >> testUnigramsWithDefaultPadding [
345342
| expected actual |
346343

347344
expected := {
@@ -354,6 +351,6 @@ NgramSequenceableCollectionTest >> testUnigramsWithDefaultPadding [
354351
#(and) asNgram .
355352
#(ham) asNgram }.
356353

357-
actual := collection unigramsWithDefaultPadding.
354+
actual := self collection unigramsWithDefaultPadding.
358355
self assert: actual equals: expected.
359356
]

0 commit comments

Comments
 (0)