Skip to content

Commit

Permalink
semantics: add missing dictionary method
Browse files Browse the repository at this point in the history
  • Loading branch information
LinqLover committed Jun 19, 2024
1 parent ea3c1af commit 414de1b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*SqueakInboxTalkExtras-Semantics-Core-sorting
talkSemanticWithValuesSorted: aSortBlockOrNil

| sorted |
sorted := OrderedDictionary new: self size.
(self associations sorted:
(aSortBlockOrNil
ifNil: [[:someAssoc :otherAssoc | someAssoc value <= otherAssoc value]]
ifNotNil: [[:someAssoc :otherAssoc | aSortBlockOrNil value: someAssoc value value: otherAssoc value]]))
do: [:assoc |
sorted add: assoc].
^ sorted
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"class" : {
},
"instance" : {
"talkSemanticWithValuesSorted:" : "ct 6/20/2024 01:06" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Dictionary" }
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ searchExact: exactTerms semantic: semanticTerms
sum := Dictionary new.
semanticResults do: [:ea |
ea keysAndValuesDo: [:k :v | sum at: k put: (sum at: k ifAbsent: [0]) + v]].
sum := (sum withValuesSorted: #yourself descending) keys.
sum := (sum talkSemanticWithValuesSorted: #yourself descending) keys.

results := (searchers gather: [:searcher | searcher filter: sum]) withoutDuplicates.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"inbox:" : "ct 6/19/2024 17:10",
"initializeConversation:" : "ct 6/8/2024 00:28",
"openResults:" : "ct 6/7/2024 21:04",
"searchExact:semantic:" : "ct 6/19/2024 17:59" } }
"searchExact:semantic:" : "ct 6/20/2024 01:06" } }

0 comments on commit 414de1b

Please sign in to comment.