![]() |
#1 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
|
Sorting hierarchical tags
I love that the tag browser supports hierarchical tags. Tags make it much easier for me to organize my books, and hierarchical tags make it much easier for me to organize my tags.
I notice that the tags/categories appear to be sorted before adding to the tag browser. On the face of it I think this is a sound design decision... but I see a possible improvement. Hierarchical tags use the period ('.', 0x2e) as the level delimiter. This character is almost immediately before the digit characters (0 is 0x30) and after many other characters such as space (' ', 0x20), hyphen ('-', 0x2d), and comma (',', 0x2c). This means when my library has 'RPG.D&D', 'RPG.Pathfinder', 'RPG unsorted', and 'RPG-new', they show up in the following order:
I suggest, before sorting the strings, replacing '.' (0x2e) with tab (0x09 -- which does not appear in tag text as best I can see). Then split on tab instead of period to populate the tag browser (applying the original strings -- periods rather than tabs -- so the existing tag filtering works). This would cause the tag browser to look like:
I think this is a more obvious and user-friendly layout, in this scenario. In my example I obviously could change the tag strings (replace 'RPG unsorted' and 'RPG-new' with other values), but that approach isn't always available. |
![]() |
![]() |
![]() |
#2 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Uh! Hierarchical tags sort just fine. The delimiter is a period
AND You need to declare what fields are hierarchical in preferences:Look&Feel:Tag Browser:Hierarchy... (a tab): tick columns (that are valid for this mode) |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
|
Yes, I understand how to get the hierarchies to appear. And the entries do sort in a consistent manner. I have observed that the consistent manner is not necessarily what people might expect, in that if you have 'RPG.Something' and 'RPG Group.Something Else', you might expect at the top level to see 'RPG' before 'RPG Group'... which is not what happens.
|
![]() |
![]() |
![]() |
#4 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
|
|
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,627
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
![]() |
![]() |
![]() |
#7 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
|
|
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The change is in calibre source.
|
![]() |
![]() |
![]() |
#9 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 863
Karma: 4097942
Join Date: Jun 2012
Location: London, UK
Device: Sony PRS-505, Pocketbook TL3, TL4, TL5
|
Quote:
![]() An alternative way would be to remove all the spaces in the tags before sorting. It also means that users who have templates etc which parse the tag using a period wouldn't have to update their code. If the field is a custom column a "tag sort" field could be added to the table which could act in the same way as the 'author sort' and 'title sort' fields. In addition it should be possible to add a tweak which would allow users to decide how they want their tags to sort - existing or new. Hopefully this should avoid all those bug reports for something that isn't a bug. |
|
![]() |
![]() |
![]() |
#10 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
The change I made is similar to the one suggested -- ensure that X.Y sorts below Xanything.Y. There was no need to change the value of the tag other than when computing the "sort key", and this only when the column is hierarchical. Templates etc don't need to be updated unless they depend on order, which isn't easy to do. |
||
![]() |
![]() |
![]() |
#11 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
|
Quote:
The change I really want is to be able to specify my own tag and hierarchy delimiters (comma and period both happen in real strings!) but that's a much scarier change. (Another one I'd like, also intended for use with tags and hierarchies, is the option in the bulk regex editor to say "if the tag doesn't match the RE, remove it"... AKA "if you find a tag like this, change it in this way, else remove it". It would be very useful when the tags contain metadata I want in another field, but it might be entirely a 'me' problem.) |
|
![]() |
![]() |
![]() |
#12 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
You can do it yourself today with templates, either in bulk edit or action chains single field edit. In bulk edit you would use "template" as the source. In action chains you would use a template to compute the resulting value. The template would fetch all the tags for a book, filter and modifiy them as desired using regexp or whatever, then return that result. Bulk edit would have the search regexp '^(.*)$', replace regexp '\1', and the destination field of tags. Action chains would be operating on tags. A third way is to use action chains "python code" and write what you want directly against calibre's db. In this case you would fetch the tags from the db, filter and modify them as needed, then store them back into the db. This process processes tag-by-tag not book-by-book, which may or may not be what you want to do. |
||
![]() |
![]() |
![]() |
#13 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
|
Quote:
I've added a custom column to most of my libraries, #scratch (long text, not in tag browser) specifically so I've got a place to mess it up a few times while I figure it out... I haven't added #scratchtag yet, but I'm thinking about it. And I agree, getting this one right could be a bit fiddly. It's why I didn't submit a ticket for it. What I really need to do is buckle down and get better at Python. It's on my List (of things to do), but it's not close enough to the top yet. |
|
![]() |
![]() |
![]() |
#14 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
|
|
![]() |
![]() |
![]() |
Tags |
tag browser |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Question about using Hierarchical Tags | phossler | Library Management | 4 | 01-08-2021 04:12 PM |
Limitations for hierarchical tags | ownedbycats | Library Management | 1 | 12-26-2020 10:04 PM |
Hierarchical tags and sorting in tag browser | ownedbycats | Calibre | 4 | 06-08-2020 07:01 PM |
Hierarchical Tags | elfed | Calibre | 0 | 07-18-2019 04:39 AM |
Getting hierarchical tags to show up in FBReader? | taratears | Devices | 0 | 10-29-2016 11:07 AM |