Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLR realisation #30

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
as yet unclassified
listOfDuplicatesKey: aBibSet
"Returns a set with duplicated keys entries based on keys"
| listDoublon |
listDoublon := CZSet new.
prioritaryBibSet := aBibSet.
withoutDuplications := CZSet new.
prioritaryBibSet do: [:each |
(withoutDuplications includesKey: each key)
ifFalse: [ withoutDuplications addEntry: each ]
ifTrue: [ listDoublon entryAt: #Dupplication put: (each)]].
^ listDoublon

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
as yet unclassified
listOfDuplicatesKey

1 change: 1 addition & 0 deletions src/Citezen-Tools.package/CZFileFilter.class/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
** TODO **
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
filter: fileName in: file

^self subclassResponsibility
11 changes: 11 additions & 0 deletions src/Citezen-Tools.package/CZFileFilter.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "sortFile 12/7/2022 13:09",
"super" : "CZTool",
"category" : "Citezen-Tools",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "CZFileFilter",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
** TODO **
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
accessing
filter: author in: aString
|fileRef filterSet|
fileRef := (FileLocator workingDirectory / aString) asFileReference.
fileRef exists ifFalse: [
Stdio stdout
nextPutAll: 'The file ';
nextPutAll: aString;
nextPutAll: ' is not found.'.
^ self ].
bibset := [ CZBibParser bibFromFileReference: fileRef ]
on: SmaCCParserError
do: [ :ex |
| context |
context := ex signalerContext.
[
context sender isNil or: [
context sender selector = #buildEntry: ] ] whileFalse: [
context := context sender ].
"super ugly isn't!"
context sender isNil
ifTrue: [
Stdio stdout nextPutAll: 'Citezen cannot parse the file.'.
^ self ]
ifFalse: [
context := context sender.
Stdio stdout
nextPutAll: 'Citezen cannot parse: ';
nextPutAll:
((context at: 1) at: 3) value allButFirst allButLast.
^ self ] ].
filterSet := CZSet new.
(bibset entries) do: [:each | author = ((each at: #author value) rawValue)
ifTrue: [ filterSet addEntry: each ]].

^ CZFileSaver new bibset: filterSet ; saveTo: aString
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "sortFile 12/7/2022 13:58",
"super" : "CZFileFilter",
"category" : "Citezen-Tools",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "CZFileFilterByAuthor",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
** TODO **
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
accessing
filter: key in: aString
|fileRef filterSet|
fileRef := (FileLocator workingDirectory / aString) asFileReference.
fileRef exists ifFalse: [
Stdio stdout
nextPutAll: 'The file ';
nextPutAll: aString;
nextPutAll: ' is not found.'.
^ self ].
bibset := [ CZBibParser bibFromFileReference: fileRef ]
on: SmaCCParserError
do: [ :ex |
| context |
context := ex signalerContext.
[
context sender isNil or: [
context sender selector = #buildEntry: ] ] whileFalse: [
context := context sender ].
"super ugly isn't!"
context sender isNil
ifTrue: [
Stdio stdout nextPutAll: 'Citezen cannot parse the file.'.
^ self ]
ifFalse: [
context := context sender.
Stdio stdout
nextPutAll: 'Citezen cannot parse: ';
nextPutAll:
((context at: 1) at: 3) value allButFirst allButLast.
^ self ] ].
filterSet := CZSet new.
(bibset entries) do: [:each | (key = each key value)
ifTrue: [ filterSet addEntry: each ]].

^ CZFileSaver new bibset: filterSet ; saveTo: aString
11 changes: 11 additions & 0 deletions src/Citezen-Tools.package/CZFileFilterByKey.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "sortFile 12/7/2022 14:01",
"super" : "CZFileFilter",
"category" : "Citezen-Tools",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "CZFileFilterByKey",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
** TODO **
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
accessing
filter: title in: aString
|fileRef filterSet|
fileRef := (FileLocator workingDirectory / aString) asFileReference.
fileRef exists ifFalse: [
Stdio stdout
nextPutAll: 'The file ';
nextPutAll: aString;
nextPutAll: ' is not found.'.
^ self ].
bibset := [ CZBibParser bibFromFileReference: fileRef ]
on: SmaCCParserError
do: [ :ex |
| context |
context := ex signalerContext.
[
context sender isNil or: [
context sender selector = #buildEntry: ] ] whileFalse: [
context := context sender ].
"super ugly isn't!"
context sender isNil
ifTrue: [
Stdio stdout nextPutAll: 'Citezen cannot parse the file.'.
^ self ]
ifFalse: [
context := context sender.
Stdio stdout
nextPutAll: 'Citezen cannot parse: ';
nextPutAll:
((context at: 1) at: 3) value allButFirst allButLast.
^ self ] ].
filterSet := CZSet new.
(bibset entries) do: [:each | title = ((each at: #title value) rawValue)
ifTrue: [ filterSet addEntry: each ]].

^ CZFileSaver new bibset: filterSet ; saveTo: aString
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "sortFile 12/7/2022 14:02",
"super" : "CZFileFilter",
"category" : "Citezen-Tools",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "CZFileFilterByTitle",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
action
merge: fileName

^self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
A CZFileMergerWithDuplicate takes a list of bib files and generate one single bibset without check of duplication.

CZFileMergerWithDuplicate new
inputFiles: #('lse.bib' 'scg.bib');
merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
action
merge: fileName
|fileSaver|
inputFiles do: [:each | self load: each].
fileSaver := CZFileSaver new.
fileSaver bibset: bibset ; saveTo: fileName
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "LouisDeloffre 12/5/2022 15:44",
"super" : "CZFileMerger",
"category" : "Citezen-Tools",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "CZFileMergerWithDuplicate",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
A CZFileMergerWithDuplicateWarning takes a list of bib files and generate one single bibset with check on duplication elements.
Return in the bibset a comment type. He say how many duplication are there and who.

CZFileMergerWithDuplicateWarning new
inputFiles: #('lse.bib' 'scg.bib');
merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
actions
merge: fileName
|duplicateIdentifier stream listDoublon|
inputFiles do: [:each | self load: each].
listDoublon := CZSet new.
stream := WriteStream on: ByteString new.
duplicateIdentifier := CZDuplicateIdentifier new.
listDoublon := duplicateIdentifier listOfDuplicatesKey: bibset.
(listDoublon entries) printElementsOn: stream.

('Vous avez ', (listDoublon size asString), ' doublon(s) qui ont comme clef : ', (stream contents)) asMorph openInWindow.

bibset addEntry: ((CZEntry type:'COMMENT')
key: #Comment;
at: #comment put: 'Dupplication';
at: #number_Of_Dupplication put: listDoublon size;
at: #Key_Of_Dupplication_Item put: stream contents).

CZFileSaver new bibset: bibset ; saveTo: fileName
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "LouisDeloffre 12/5/2022 15:46",
"super" : "CZFileMerger",
"category" : "Citezen-Tools",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "CZFileMergerWithDuplicateWarning",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
A CZFileMergerWithoutDuplicate takes a list of bib files and generate one single bibset with check on duplication elements.
Return in the bibset a single reference of duplicate items.

CZFileMergerWithoutDuplicate new
inputFiles: #('lse.bib' 'scg.bib');
merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
action
merge: fileName
| duplicateIdentifier fileSaver |
inputFiles do: [:each | self load: each].
duplicateIdentifier := CZDuplicateIdentifier new.
fileSaver := CZFileSaver new.
bibset := duplicateIdentifier withoutInternalKeyDuplicates: bibset.
fileSaver bibset: bibset ; saveTo: fileName
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "LouisDeloffre 12/5/2022 15:48",
"super" : "CZFileMerger",
"category" : "Citezen-Tools",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "CZFileMergerWithoutDuplicate",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
isAbstract

^ self == CZFileSorter
55 changes: 2 additions & 53 deletions src/Citezen-Tools.package/CZFileSorter.class/instance/sortFile..st
Original file line number Diff line number Diff line change
@@ -1,55 +1,4 @@
actions
sortFile: aString
sortFile: fileName

| bs oldSize fileRef |
fileRef := (FileLocator workingDirectory / aString) asFileReference.
fileRef exists
ifFalse: [
Stdio stdout
nextPutAll: 'The file ';
nextPutAll: aString;
nextPutAll: ' is not found.'.
^ self ].
bs := [ CZBibParser bibFromFileReference: fileRef ]
on: SmaCCParserError do: [ :ex |
| context |
context := ex signalerContext.
[ context sender isNil or: [ context sender selector = #buildEntry: ] ]
whileFalse: [ context := context sender ].
"super ugly isn't!"
(context sender isNil)
ifTrue: [
Stdio stdout nextPutAll: 'Citezen cannot parse the file.'.
^ self ]
ifFalse: [
context := context sender.
Stdio stdout nextPutAll: 'Citezen cannot parse: ', ((context at: 1) at: 3) value allButFirst allButLast.
^ self ]
]


.
oldSize := bs size.
bs sortByKey.
bs size.
oldSize = bs size
ifFalse: [
Stdio stdout
nextPutAll: 'Problem identified! The original file: ';
nextPutAll: aString ;
nextPutAll: ' contained ';
print: oldSize printString ;
nextPutAll: ' entries and the sorted version contains ';
print: bs size printString ;
nextPutAll: ' entries. So we saved the file to a new name:'.
CZFileSaver new bibset: bs ; saveTo: aString, 'Sorted.bib', '.'
].
Stdio stdout
nextPutAll: 'Sorted file: ';
nextPutAll: aString;
nextPutAll: ' .';
nextPutAll: ' It contains ';
print: bs size;
nextPutAll: ' entries.'.
CZFileSaver new bibset: bs ; saveTo: aString

^ CZFileSorterByKey sortFile: fileName
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sort by **author**
Loading