• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pharo-ai / NgramModel / 4193419174

pending completion
4193419174

push

github

GitHub
Merge pull request #28 from pharo-ai/follow-naming-conventions

105 of 105 new or added lines in 9 files covered. (100.0%)

529 of 593 relevant lines covered (89.21%)

2.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/AI-NgramModelTextGenerator/AINgramModelTextGenerator.class.st
1
Class {
2
        #name : #AINgramModelTextGenerator,
3
        #superclass : #Object,
4
        #instVars : [
5
                'model',
6
                'history'
7
        ],
8
        #category : #'AI-NgramModelTextGenerator'
9
}
10

11
{ #category : #initialization }
12
AINgramModelTextGenerator >> generateTextOfSize: aNumber [
×
13
        | words |
×
14
        words := OrderedCollection new.
×
15
        
×
16
        (1 to: aNumber) do: [ :i | 
×
17
                words add: self nextWord
×
18
        ] displayingProgress:  [ :each | 'Generating words: ' , each asString ].
×
19

×
20
        ^ ' ' join: words
×
21
]
×
22

23
{ #category : #initialization }
24
AINgramModelTextGenerator >> model: anObject [
×
25
        | order |
×
26
        model := anObject.
×
27
        order := model order - 1.
×
28
        history := ((1 to: order) collect: [ :x | '<s>' ]) asNgram.
×
29
]
×
30

31
{ #category : #initialization }
32
AINgramModelTextGenerator >> nextWord [
×
33
        | word |
×
34
        word := (model mostLikelyContinuations: history top: 5) atRandom.
×
35
        history := (history asArray copyWithoutFirst, { word }) asNgram.
×
36
        ^ word
×
37
]
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc