Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vocab_trainer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Vennemann
vocab_trainer
Commits
cef58865
Commit
cef58865
authored
1 month ago
by
Peter Vennemann
Browse files
Options
Downloads
Patches
Plain Diff
Sorting saved buffer.
parent
daabc94b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vocab-trainer.el
+22
-13
22 additions, 13 deletions
vocab-trainer.el
with
22 additions
and
13 deletions
vocab-trainer.el
+
22
−
13
View file @
cef58865
...
...
@@ -2,13 +2,17 @@
;; class for single phrase
(
defclass
vocab-entry
()
((
native
:initarg
:native
:initform
""
:type
string
:documentation
"phrase in native lang"
)
(
foreign
:initarg
:foreign
:initform
""
:type
string
:documentation
"phrase in foreign lang"
)
(
score
:initarg
:score
:initform
0
:type
integer
:documentation
"score"
)))
((
native
:initarg
:native
:initform
""
:type
string
:documentation
"phrase in native lang"
)
(
foreign
:initarg
:foreign
:initform
""
:type
string
:documentation
"phrase in foreign lang"
)
(
score
:initarg
:score
:initform
0
:type
integer
:documentation
"score"
)))
;; class for trainer
(
defclass
vocab-trainer
()
((
entries
:initarg
:entries
:initform
nil
:type
list
:documentation
"list of phrases"
)))
((
entries
:initarg
:entries
:initform
nil
:type
list
:documentation
"list of phrases"
)))
(
defmethod
load-vocab
((
trainer
vocab-trainer
))
"Reading phrases from current buffer and saving as objecst."
...
...
@@ -21,24 +25,28 @@
(
native
(
nth
0
parts
))
(
foreign
(
nth
1
parts
))
(
score
(
string-to-number
(
nth
2
parts
))))
(
push
(
vocab-entry
:native
native
:foreign
foreign
:score
score
)
(
oref
trainer
entries
)))
(
push
(
vocab-entry
:native
native
:foreign
foreign
:score
score
)
(
oref
trainer
entries
)))
(
forward-line
1
))))
(
defmethod
save-vocab
((
trainer
vocab-trainer
))
"Saving phrases with actual scores back to current buffer."
(
with-current-buffer
(
current-buffer
)
(
erase-buffer
)
(
dolist
(
entry
(
oref
trainer
entries
))
(
insert
(
format
"%s | %s | %d\n"
(
oref
entry
native
)
(
oref
entry
foreign
)
(
oref
entry
score
))))
(
let
((
sorted_entries
(
cl-sort
(
copy-sequence
(
oref
trainer
entries
))
'<
:key
(
lambda
(
e
)
(
oref
e
score
)))))
(
dolist
(
entry
sorted_entries
)
(
insert
(
format
"%s | %s | %d\n"
(
oref
entry
native
)
(
oref
entry
foreign
)
(
oref
entry
score
)))))
(
save-buffer
)))
(
defmethod
select-weakest
((
trainer
vocab-trainer
))
"Selecting phrases with lowest score."
(
cl-subseq
(
cl-sort
(
copy-sequence
(
oref
trainer
entries
))
#'
<
:key
(
lambda
(
e
)
(
oref
e
score
)))
0
12
))
(
cl-subseq
(
cl-sort
(
copy-sequence
(
oref
trainer
entries
))
'<
:key
(
lambda
(
e
)
(
oref
e
score
)))
0
12
))
(
defmethod
train
((
trainer
vocab-trainer
))
"Start training."
...
...
@@ -53,7 +61,8 @@
(
oset
entry
score
(
1+
(
oref
entry
score
)))
(
setq
words
(
cdr
words
)))
(
progn
(
message
"Wrong! Correct answer: %s (press key...)"
(
oref
entry
foreign
))
(
message
"Wrong! Correct answer: %s (press key...)"
(
oref
entry
foreign
))
(
read-char
)
(
oset
entry
score
(
1-
(
oref
entry
score
))))))))
(
save-vocab
trainer
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment