Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 02-11-2012, 03:03 PM   #1
Noughty
Addict
Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.
 
Posts: 352
Karma: 103850
Join Date: Apr 2011
Device: Kindle NT
Hierarchical tags and their format on book details

Is it possible to view hierarchical tags in book details neatly? I mean now it takes insane amount of place if you have a tag under which there are other tags. For example you have tag Paranormal. It is the first tag in hierarchy. Under it there is vampire, magic, ghost and whatever. If a book has a few elements from this one tag it lists word Paranormal a few times which makes it impossible to view data since it takes up a lot of space.

I have a structure like this:
Genre.[all genre types]
Character.Description.[all description tags]
Character.Type.[all possible character types]
Character.Profession.[all professions]
Ending...
Length...

So in book details if book has even a few tags it looks very messy while in tag view it looks very neat. Could it be somehow fixed that in both views it looks nice? If tag browser can distinguish the meaning of the "." maybe it's possible to do that in book details window. So instead of something like this:

Book.Type.Reviewed, Character.Character.Alien, Character.Character.Human, Character.Character.Vampire, Character.Description.YA, Character.Description.Slave, Book.Ending.Bad, Genre.Fantasy, Genre.Sci-Fi, Character.Profession.Outlaw, Character.Profession.Royalty, Character.Profession.Thief, Book.Setting.Alternative World

It could look like this:
Book, type, reviewed, character, alien, human, vampire, ya, description, slave, ending, bad, fantasy, sci-fi, profession, outlaw, royalty, thief, setting, alternative world.
(alphabetically or no, I just written them as they are in the first example)

It's not perfect since tags like book, genre, type, ending, character shouldn't even be there, but it's way better than the one above. (would be nice to be able to choose tags which shouldn't be shown in book details window, it would solve this little problem)

I am using hierarchical tags in an unique way I think, but this could look ugly even if it's used in a normal way. The example with the Paranormal. It would look like:

Paranormal.Magic, Paranormal.Ghost, Paranormal.Vampire - There are two words here unnecessary. If there are more tags the number increases and takes a lot of space.

instead of:
Paranormal, magic, ghost, vampire

I think it's the biggest problem of hierarchical tags. They only look nice in the tag browser. If it were fixed their use would greatly improve.
Noughty is offline   Reply With Quote
Old 02-11-2012, 11:07 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 26,122
Karma: 5101571
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I dont see how that can be fixed. Suppse you have Paranormal.Retro and SciFi.Retro. Stripping the prefixes will means you have Retro and Retro.

One possibility is to have something like:

Character [Profession [Doctor, Lawyer], Type [Male, Female]], Paranormal [Vampire, Romance]

But this becomes really hard to understand if you scheme has several levels.

There is no good way to represent a hierarchical tree as a flat list that I can think of.
kovidgoyal is offline   Reply With Quote
Old 02-12-2012, 06:47 AM   #3
Noughty
Addict
Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.
 
Posts: 352
Karma: 103850
Join Date: Apr 2011
Device: Kindle NT
Thanks for explaining. I guess I'll just have to not view tags in book details for now. And figure out something else since it's not an option to not be able to see all book tags.

Maybe some custom column extracting all tags and breaking them into single tags at every dot. If it's even possible. And use that column for neat view

Any help with that is appreciated
I work best with examples

For now the solution I think of in my case would be just leaving only the initials for the categories. Like instead of Book.Type. post B.T. this way it saves the space.

Or buy a computer with a normal sized screen

Here looks like something I could use:
http://manual.calibre-ebook.com/sub_groups.html the last paragraph

Is it possible to somehow make it extract the tags like this only if there are sublevels. If there is a singe tag Anthology to leave it alone? With tags which have levels it should work fine now. I can make sure levels match so only what I don't need is removed. But the one level tags make a problem since they dissapear

Last edited by Noughty; 02-12-2012 at 09:14 AM.
Noughty is offline   Reply With Quote
Old 02-12-2012, 01:31 PM   #4
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,632
Karma: 857074
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by Noughty View Post
Here looks like something I could use:
http://manual.calibre-ebook.com/sub_groups.html the last paragraph

Is it possible to somehow make it extract the tags like this only if there are sublevels. If there is a singe tag Anthology to leave it alone? With tags which have levels it should work fine now. I can make sure levels match so only what I don't need is removed. But the one level tags make a problem since they dissapear
Assuming you really want to do this and you are willing to use a column built from other columns, there are ways to do it. For example, the template
Code:
{#genre:'list_sort(list_union('', re(subitems($, 0, 2), '(^|,)([^,]*?)\.', '\1 '), ','), '0', ',')'}
will give you all single-level tags and the second item in a hierarchical tag (the B in A.B.C). The subitems function gives the first two levels (or first if there is only one). The re function strips everything from the beginning of the item to the period. The list_union removes duplicates, and the list_sort sorts the resulting list.

If you want everything except the first item (A.B.C returns B.C) then try this
Code:
{#genre:'list_sort(list_union('', re($, '(^|,)([^,]*?)\.', '\1 '), ','), '0', ',')'}
The subitems isn't needed because the entire tag is processed to remove the first element.
chaley is offline   Reply With Quote
Old 02-13-2012, 01:38 PM   #5
Noughty
Addict
Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.
 
Posts: 352
Karma: 103850
Join Date: Apr 2011
Device: Kindle NT
I tried the
{tags:'list_sort(list_union('', re(subitems($, 0, 0), '(^|,)([^,]*?)\.', '\1 '), ','), '0', ',')'}

This works best if tags are two level, like Genre.Mystery, But if it is something like Character.Profession.Law enforcement it gives me Profession.Law enforcement and I would like to get only the last tag no matter how many levels there are.
How to edit it so it does that?
Here's the expected result:
Mystery>Mystery
Genre.Mystery>Mystery
Character.Profession.Law enforcement>Law enforcement
Book.Type.Anthology>Anthology

So if a book had these tags I would see final result as:
Anthology, Law enforcement, Mystery

I'm not sure I want to sort as it will give tags in category order, first all about the book, when character, when genre and so on. So I think it's better that sorting alphabetically. I removed sorting function but it still gives result sorted:
{#shelf:'list_union('', re(subitems($, 2, 4), '(^|,)([^,]*?)\.', '\1 '), ',')'}

Last edited by Noughty; 02-13-2012 at 01:48 PM.
Noughty is offline   Reply With Quote
Old 02-14-2012, 03:04 AM   #6
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,632
Karma: 857074
Join Date: Jan 2010
Location: France
Device: Many android devices
Use the following to get the last (or only) item of a hierarchy
Code:
{#genre:'list_union('', subitems($, -1, 0), ',')'}
This says get the first item from the end (-1) to the last item (0). As before, the list_union removes duplicates. Remove it to improve performance if you don't mind dups.

Regarding the sort -- there is no way to avoid it. The subitems function sorts the result. If it did not then the order of items would be random, not the original order. And in any event, the original order of #shelf is probably semi-random, not what is displayed.

Because subitems sorts, the list_sort I used simply wasted time.

Note also that list_union can change the order of the items, although in this case it does not.
chaley is offline   Reply With Quote
Old 02-14-2012, 11:29 AM   #7
Noughty
Addict
Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.Noughty is cognizant of many things which escape those who dream only by night.
 
Posts: 352
Karma: 103850
Join Date: Apr 2011
Device: Kindle NT
Thanks for the help. I kind of learned the use of functions like list_union and so on, but still bad about using $, '(^|,)([^,]*? and similar
Will have to expand my knowledge. Maybe time will come when I can do all my custom columns without any help... It's not forbidden to dream

I changed it into program like this:

program:
list_union(
subitems(field('#shelf'),-1,0),
subitems(field('tags'),-1,0),',')

This should give me one nice list of tags and shelves for book detail window and for kindle collections.

Last edited by Noughty; 02-14-2012 at 01:26 PM.
Noughty is offline   Reply With Quote
Old 02-17-2012, 06:58 PM   #8
Joanna
Connoisseur
Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.
 
Posts: 65
Karma: 41772
Join Date: Feb 2012
Location: Poland
Device: none
I have a similar problem. I have created a hierarchical custom column for genres. The genres include no more than three levels:

linguistics.sociolinguistics.gender

In book details, I would like to have the following genres displayed: linguistics, sociolinguistics, gender.

Analogically, if there are some genres with two or one level only, I would like to have all the parts displayed separated by comma in the book details.

linguistics.sociolinguistics => linguistics, sociolinguistics

I would like to create a separate custom column based for that. What code should I use?
Joanna is offline   Reply With Quote
Old 02-18-2012, 05:44 AM   #9
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,632
Karma: 857074
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by Joanna View Post
I would like to create a separate custom column based for that. What code should I use?
Code:
{#genre:'list_union('', re($, '\.', ', '), ',')'}
See the documentation for template program mode, list_union and re for details on how this template works.
chaley is offline   Reply With Quote
Old 02-18-2012, 07:06 PM   #10
Joanna
Connoisseur
Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.
 
Posts: 65
Karma: 41772
Join Date: Feb 2012
Location: Poland
Device: none
Thank you so much for the code!

I am new to Calibre (which is an amazing piece of software!) and have spent the last couple of days reading the manual, forums, building my own library and experimenting with it but I gotta admit Calibre is still a bit overwhelming , with all the options and customization possibilities. I try to learn one thing at a time, and templates still look kinda complicated .

Just one more question: would it be possible to leave out the first level of a genre hierarchical list in book details just in some cases (depending on this first element). I don't know if I've made myself clear. Let's say I have:

linguistics.sociolinguistics.gender and want to have linguistics, sociolinguistics, gender displayed in the book details (like above).

But then I have:

somegenre.othergenre.yetanothergenre and I'd like to have only othergenre, yetanothergenre displayed in the book details.

Is there any way to exclude somegenre from the general rule? Or do I need to create a separate custom column for such genres/groups of books?
Joanna is offline   Reply With Quote
Old 02-19-2012, 03:51 AM   #11
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,632
Karma: 857074
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by Joanna View Post
Is there any way to exclude somegenre from the general rule? Or do I need to create a separate custom column for such genres/groups of books?
Code:
{#genre:'list_difference(re($, '\.', ', '), 'somegenre, someothergenre, etc', ',')'}
The list_difference function removes any item in the second list ('somegenre ...) from the first list (the list returned by the 're' function). Note that somegenre etc will be removed even if it appears as the second or later item (foo.somegenre.bar). If this is unacceptable, then things will get more complicated. Another 're' will be required to remove the undesired prefixes before converting them to a list (what the current 're' does).

Template expressions differ from but are really no more complicated than excel formulae. Unfortunately, excel formulae can easily be incomprehensible.
chaley is offline   Reply With Quote
Old 02-19-2012, 06:04 AM   #12
Joanna
Connoisseur
Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.Joanna is an enigma wrapped up in a mystery.
 
Posts: 65
Karma: 41772
Join Date: Feb 2012
Location: Poland
Device: none
Thanks a lot again! Fortunately, I don't need to have somegenre etc. displayed anywhere, at least not right now. But would it be possible to have somegenre displayed if it is a one-level genre? ("somegenre" only, no other genres separated with points)

I used to love excel formulaes , and I was usually able to get what I wanted even if sometimes it wasn't the most elegant solution . I remember it was quite difficult in the beginning, with understanding how the syntax works and what the symbols for functions are but it was a great deal of fun. Hope to be able to do that with template expressions one day . I start to feel like Calibre is not just a book database, it is more like a hobby .
Joanna is offline   Reply With Quote
Old 02-19-2012, 07:47 AM   #13
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,632
Karma: 857074
Join Date: Jan 2010
Location: France
Device: Many android devices
The complexity of what you want to do has reached the point where the right solution is to write a custom python template function. That requires some python programming skills.

The following template will work:
Code:
{#genre:'list_union('', re(list_re($, ',', '(?i)^(?:thrillers\.|history\.)?(.*)', '\1'), '\.', ', '), ',')'}
This template will have a significant performance impact as your library grows. My guess is that you won't notice much until you cross a thousand books or so, but it will be there. A custom template function will probably be some 100 times faster than this template.

Working from the inside out, the template uses list_re to prepare a list with the undesired prefixes removed. In the example, if it finds "thrillers." or "history.", then it removes it. The word "thrillers" by itself is left because it doesn't have a period after it. The 're' at the next level out converts all dots to commas. The list_union removes duplicates.

For completeness, here is a custom template function that does the job (I think). You can use preferences -> template functions to define it.
Code:
name: whatever you want to call it. I called it "myFunc"
arg count: 2
documentation: whatever you want to say
program code:
def evaluate(self, formatter, kwargs, mi, locals, l, excludes):
	from calibre.utils.icu import sort_key
	excl = [v.strip() for v in excludes.split(',')]
	items = [v.strip() for v in l.split(',')]
	result = set()
	for item in items:
		parts = item.split('.')
		if len(parts) > 1 and parts[0].lower() in excl:
			start = 1
		else:
			start = 0
		result.update(parts[start:])
	return ', '.join(sorted(result, key=sort_key))
You call the function using a template like the following:
Code:
{#genre:'myFunc($, 'thrillers, history')'}
The template uses template program mode because the second argument contains commas inside the string value.

The function returns a sorted list of items with all genres split into separate items at the period. Genre prefixes in the second argument ('thrillers, history' in the example) are removed from the result, but genres exactly equaling one of these items are not removed.
chaley is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Book Details Pane Missing RainIntoRainbows Calibre 2 09-08-2011 03:44 AM
Show book details error firewolf Calibre 3 07-27-2011 02:09 PM
Touch View Book Details Gone? BookJunkieLI Barnes & Noble NOOK 2 07-03-2011 11:48 AM
Can't Open Book Details with 0.7.36 oldbwl Calibre 9 01-03-2011 02:43 PM
Book Details - Size of Font adrian1944 Calibre 1 02-18-2010 06:12 PM


All times are GMT -4. The time now is 11:58 AM.


MobileRead.com is a privately owned, operated and funded community.