{"id":41,"date":"2011-05-11T22:28:17","date_gmt":"2011-05-11T21:28:17","guid":{"rendered":"http:\/\/muttznutz.net\/muttzblog\/?p=41"},"modified":"2011-06-07T00:07:21","modified_gmt":"2011-06-06T23:07:21","slug":"setting-them-up","status":"publish","type":"post","link":"https:\/\/muttznutz.net\/muttzblog\/post-processing\/setting-them-up","title":{"rendered":"Keyword Classes Pt.2 &#8211; Setting them up"},"content":{"rendered":"<p><a title=\"Part one of Keyword Classes\" href=\"https:\/\/muttznutz.net\/muttzblog\/post-processing\/keyword-classes\/introduction-to-keywords-classes\">In the first article<\/a>, I talked about image metadata, and identified the shortfalls in terms of what I need them to do &#8230;<\/p>\n<p><a title=\"Part 3 - using the keywords\" href=\"https:\/\/muttznutz.net\/muttzblog\/post-processing\/keyword-classes-pt-3-using-the-keywords\">The third article<\/a> demonstrates how I&#8217;ve used these keywords to drive the content of my site. (<em>It might be worth taking a look at that article if you don&#8217;t understand what I&#8217;m going on about<\/em>)<\/p>\n<p>I&#8217;ve called my solution &#8220;Keyword Classes&#8221;, but they could equally be referred to as &#8220;Structured Keywords&#8221; or &#8220;Smart Keywords&#8221;.<\/p>\n<p>This article talks about how I&#8217;ve made &#8217;em work&#8230;<\/p>\n<h3>Disclaimer<\/h3>\n<p>To really use these classes to best effect, you&#8217;ll need to be able to parse the entries using a programming tool. If you don&#8217;t know how to code &#8211; or don&#8217;t know someone that does &#8211; then I&#8217;m afraid you probably won&#8217;t be able to get this done.<\/p>\n<p>For those who want to read on anyway, I should explain the phrase &#8220;parse&#8221; &#8211; which (in programming terms) means splitting up a long string into its individual components, so that each can be processed separately.<\/p>\n<p>So parsing a keyword string that looks like <code>[dn]204;[fi]Humphead wrasse[spf]Cheilinus undulatus<\/code> should give three entries:<\/p>\n<p><code>[dn]204<br \/>\n[fi]Humphead wrasse<br \/>\n[spf]Cheilinus undulatus<\/code><\/p>\n<p>This keyword string would be parsed by php as having two keywords &#8211; the semicolon in front of the [dn] would be the break point.<\/p>\n<h3>Delimiting Class Identifiers<\/h3>\n<p>So that the programs reading the keywords can know 1) that it is a class item and 2) what type of class item it is, I needed to set up an identifier system.<\/p>\n<p>I figured the best way to do this is to start the keyword with a delimited string, containing a class identifier (stay with me &#8211; I&#8217;ll get to this in a minute). Separate start- and end-delimiter characters would work best, and they should ideally be characters which wouldn&#8217;t normally turn up in your keywords.<\/p>\n<p>Just to complicate things a bit more, certain delimiters have specific meanings for HTML (the language that drives browsers). These are often changed by scripting languages &#8211; or may behave unpredictably &#8211; so quote characters are out, as are the GT\/LT angle brackets (&lt;&gt;) Forward- and back-slashes are also out. If you want to geek out a bit, then you can check out the <a title=\"W3Schools Entities page\" href=\"http:\/\/www.w3schools.com\/tags\/ref_entities.asp\">HTML Entities page<\/a> on the W3Schools website for more details.<\/p>\n<p><em>(For the techies : I did try to embed XML, but &#8211; apart from entity encoding &#8211; it got much too unwieldy trying to guarantee closing the entities).<\/em><\/p>\n<p>Ideally, the delimiter at the start of the string would be different from that at the end. The most natural fit is, therefore, either the square brackets (<strong>[]<\/strong>) or curly parentheses (<strong>{}<\/strong>). The former doesn&#8217;t need a shift key, so I&#8217;ve gone with those.<\/p>\n<h3>Class Identifiers<\/h3>\n<p>Now we get to the heart of it. Each class of keyword needs a separate identifier. These can, actually, be of any length (but keeping it to two or three characters is probably more efficient). I like to use abbreviations that are easy to remember.<\/p>\n<p>So for my underwater albums :<\/p>\n<ul>\n<li>dn &#8211; is the <strong>D<\/strong>ive <strong>N<\/strong>umber, a key into my logbook database<\/li>\n<li>sp &#8211; is the binomen &#8211; or &#8220;latin name&#8221; of the <strong>sp<\/strong>ecies<\/li>\n<li>spf &#8211; is like &#8220;<strong>sp<\/strong>&#8220;, but a bit more specific. These are species which can be referenced in the <a href=\"http:\/\/www.fishbase.org\/search.php\"><strong>F<\/strong>ishbase<\/a> database, so I want to link to it (that means different processing, so its a different class).<\/li>\n<li>fi &#8211; is the &#8220;common name&#8221; of the <strong>fi<\/strong>sh, as listed in Fishbase.<\/li>\n<\/ul>\n<p>So entries for my 204th dive will have the keyword<br \/>\n<code>[dn]204<\/code><\/p>\n<p>You can create a keyword\u00a0 with more than one class &#8211; e.g.<\/p>\n<p><code>[fi]Humphead wrasse[spf]Cheilinus undulatus<\/code><br \/>\n.. As all Humphead wrasse belong to the same species, there&#8217;s no point in having two separate Tag items &#8211; they&#8217;d only get out-of-step, and you&#8217;re giving yourself twice as much work.<\/p>\n<p><em>(Just to clarify my terminology, a &#8220;Tag&#8221; &#8211; in PSE &#8211; may incorporate more than one &#8220;Keyword&#8221;)<\/em><\/p>\n<h3>Reusing classes<\/h3>\n<p>After a few years, I decided to show some topside wildlife images on some parts of my site. So I used the same keyword classes for bird, mammal and insect species as I did for Fish. I introduced a new class &#8211; [ln] to denote a non-dive location. A bit of recoding my scripts, and everything appeared in a consistent way.<\/p>\n<h3>Programming considerations<\/h3>\n<p>PSE (and &#8211; probably &#8211; other applications) won&#8217;t necessarily write the tags in any particular order. It may also insert its own delimiters between keywords.<\/p>\n<p>So any software which parses these classes may need to<\/p>\n<ul>\n<li>ignore semicolons which precede a prefix<\/li>\n<li>deal with class instances occurring in any order<\/li>\n<li>potentially deal with multiple instances of a class (more than one fish species in a photo)<\/li>\n<li>potentially deal with the absence of a specific class within a specific image<\/li>\n<\/ul>\n<p>Depending on the software tools you use to create the tags, and to parse them, you may need to ignore delimiters (such as semi-colons or commas) introduced by the software. These are becoming less common now.<\/p>\n<p>If you&#8217;re using the PHP toolkit to generate your web pages, this will parse the individual keywords, which makes everything much easier.<br \/>\nUnstructured comments (or those relating to individual images) can be included in another field &#8211; such as the the &#8220;Caption&#8221; or &#8220;Title&#8221; fields .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Practical stuff about setting up Keyword Classes &#8230; and a few rules, constraints and considerations<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[7,5],"tags":[124,118,117,135,134,83,84,120,91,129],"_links":{"self":[{"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/posts\/41"}],"collection":[{"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":16,"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":522,"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/posts\/41\/revisions\/522"}],"wp:attachment":[{"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}