Mapping of additional RIS fields from Bookends


(jmm) #1

I wonder if it would be possible to map additional RIS types into Tinderbox when dragging with CMD + OPT.

I have included additional RIS types, and their corresponding Bookends fields, in an Extended RIS format, created with Bookend’s format manager, and set as the default bibliography format.

The RIS types I have included are Language (LA), Original Publication (OP), Link to PDF (L1) and Label (LB). The Bookend’s fields are: Language (u7), Orig Pub (OP), Attachment File Paths (m) and Citation Key / User1 (u1). The Tinderbox’s attributes would be: Language, OriginalPublication, ReferenceURL, CitationKey.

$LA  - $u7 
$OP  - $u11 
$L1  - $m 
$LB  - $u1

Sense-making of Academic Literature Using Tinderbox
(Mark Anderson) #2

My understanding is the mapping is fixed - insofar as the extraction mapping isn’t exposed to the user (for modification) in Tinderbox.

I would suggest an email to support explaining what you need.

In the meantime, it looks like AppleScript could provide a workaround. Although neither Bookends not Tinderbox have a an AppleScript dictionary (i.er. fine level in-app access), Bookends manual pp23-5 indicates you can interrogate BooKends fields. From that you could make a string of tab-fdelim data that could then be pasted to Tinderbox.

Note that regardless of method there is no automatic method for merging info into existing Tinderbox notes. Paste or drag/drop will make a new note. But - again, a workaround - you could then use action code to find the right existing note in your doc and copy across the imported attribute data then move the data import note to an archive container for later (manual) deletion.


(Grant Lotter) #3

It’s possible, though it requires a bit of spadework.

There are a number of ways to approach it, including using agents, but I’ll illustrate it using a Prototype Rule, adding in this case just the L1 (Link to PDF) data.

(1) You need to create a User variable to hold the data. I’ll call it PDF, of type url – this will make it clickable.
(2) I’ll assume you’ve already got a Reference prototype in your Prototype container – one is created automatically when you first drag in a Reference. Modify/create the rule for the Reference to:

$ReferenceRIS.contains("L1 - ([^\n]*)\n"); $PDF=$1; $PDF=$PDF.replace("L1 - ","").replace("\n","")
Make sure the reference rule is not enabled in the prototype, else the PDF KAs will all end up displaying $1 – this caught me when I was testing the code!

(3) Add the PDF variable as a KA to the Reference prototype.

Existing and new references will now have a link to the PDF file as a clickable KA.

The other variables can be done in a similar fashion.


(jmm) #4

Thank you for your replies.
@GrantLotter: I have included the suggested rule below in the Reference prototype, and checked RuleDisabled. Yet when I CMD-OPT-drag or OPT-drag, the imported reference is populated with $1 in the ReferenceURL fied. Am I missing any step?

$ReferenceRIS.contains(“L1 - (\n*)\n”);
$ReferenceURL=$1;
$ReferenceURL=$ReferenceURL.replace(“L1 - “,””).replace("\n","")

By the way, is there a way to set a prototype as default? In this case, to get Tinderbox to automatically apply my own reference prototype to ReferenceRIS, instead of TB’s default Reference prototype?


(Mark Anderson) #5

Not sure about the first (in a conference just now) but you can do the latter. Although there’s no way to pre-set your own prototype, you can add the default one and then edit it to your own specification (but don’t change the prototype’s name!).


(Grant Lotter) #6

@jmm There are two problems.

One is a mangling of code by the board; it turns out there is a difference between L1
and L1 This should not make a difference since the Rule text should not see any difference, but it does. (this may be a bug.) I’ve altered the code above to

$ReferenceRIS.contains("L1 - ([^\n]*)\n"); $PDF=$1; $PDF=$PDF.replace("L1 - ","").replace("\n","")

If I use this with bog-standard RIS exported from BibDesk it works. However, Bookends cmd-opt dragged items are still displaying $1 instead of the file path. The problem here is I suspect that styled text is being sent out by Bookends.

I’ll need to debug. Will update later.

Re: changing prototypes. Yes, something is possible. I’ll post examples later too if you want. I routinely do this: I have separate prototypes for books, articles, Conf Procs etc.


(Grant Lotter) #7

@jmm Try the following:

  1. Select a single item in Bookends;
  2. Select Bibliography… in Biblio and choose your modified RIS format (the one containing the L1 data);
  3. Select Plain text (ASCII) and Send the bibliography to Disk;
  4. Make Bib. Choose Bib.txt as the output file (extension important here);
  5. Drag Bib.txt into Tinderbox.

Do you now get your ReferenceURL KA populated correctly?


(Bart Lubaszka) #8

Hi,

I’m trying to get the same thing done here (but just with a single KA for a link that will go to a DT destination). I’m pretty sure I set up the KA and put the code in the correct place: Document Inspector, User, Gear, New User Attribute, Name, “PDF”, Type: “url”, Key attribute for selected notes (the Reference prototype is selected). Then Action Inspector, Rule, “…”, not enabled.

I’m getting the $1 in the PDF KA for references dragged across no matter how I do it. I may have not set it up correctly on the Bookends side: formats manager, RIS.fmt, added “$L1 - $u12” (without “” of course) to each type (book, article, etc). I added a url to field “User12” to test it out.

Thanks for any suggestions. Doing my best but can’t jump over being new. :slight_smile:


(Grant Lotter) #9

Dear Bart,

You’re right: neither method (cmd-opt drag or save to file and then drag) works anymore. The problem seems to be specific to Bookends since my old code works for RIS-drags from BibDesk to Tinderbox.

Ask Jon at Sonny Software if something has changed?

Grant


(Bart Lubaszka) #10

Actually, I can see the link just fine in Tbx in the text body. It would seem that I’m just not properly setting the variable up. My understanding of this ‘code’ is limited.

It’s checking if the note contains a string that is L1 in a particular format. I can’t figure out what ([^\n]*)\n" is doing exactly.

I can’t say I know. It appears that $1 becomes a variable, but we don’t call or set anything using $1 later on.

KA $PDF is being replaced with the value of L1. I don’t know what the ^/n and /n refer to, and couldn’t figure anything else out by looking at the cookbook.

Is there a better place to look than the cookbook for a beginner to figure it out and do you still think it’s a Bookends change causing what we want to not work or is it my bad implementation of the code?

:slight_smile: Thanks!


(Bart Lubaszka) #12

OK. So why doesn’t the last line work to put the contents of $1 into $PDF? The unformatted text as follows:

 L1  - http://forum.eastgate.com/t/mapping-of-additional-ris-fields-from-
 bookends/639/10

is sitting in the body of the note text.


(Grant Lotter) #13

No idea. It works with RIS dragged in from BibDesk, so the problem lies in the tbx/bookends interface.


(Bart Lubaszka) #14

But isn’t there a way to get text from a note to be automatically put into a KA? The text is sitting in the note. The KA $PDF is there at the top of the note. I obviously have limited understanding of all this, but isn’t TB being asked to find text starting with L1 and input that paragraph after it into a KA field? I can’t figure out how to do that, but I assume the proper rule would get it done?


(Paul Walters) #15

If the text is in the body, then you need to operate on the right attribute – i.e., $Text – e.g., a stamp such as

$PDF=$Text.replace("L1 - ","").replace("\n","")

If $Text contains more text than your example, then you’ll need to add logic to parse / search the text – which is what @GrantLotter was pointing you to by showing the operands to parse an attribute other than $Text – i.e., $ReferenceRIS in his example.

Also, make sure $PDF exists otherwise this will fail silently.


(Mark Anderson) #16

Actually, [^] means a ‘not’ group, thus the code above means match:

  • literal string "L1 - "
  • a back-reference to zero or more of any character that is not a new-line character; the back-reference is due to the parentheses
  • a single line break

As the first/only back reference the contents of the second bullet are available via the placeholder $1.

$PDF=$PDF.replace("L1 - ","").replace("\n","")

Here $PDF is doing a replace on it’s own contents, or in this case removing 2 different strings each being defined in one of the two chained .replace() operations. The first removes all instance of the literal string "L1 - ". The second removes all new-line characters (i.e. line breaks).

$ReferenceRIS.contains("L1 - ([^\n]*)\n");
$PDF=$1;
$PDF=$PDF.replace("L1 - ","").replace("\n","")

Therefore this makes no sense as $1 contains neither of the two strings the last line seeks to remove from $PDF.

All that said, my understanding was back-references are only populated in agent queries, if(query) statements, or the first term in a .replace() operation. The first line above isn’t one of these.

I don’t believe there is an operation that can simply return a back reference string from a String.contains(pattern), though I wish there was.


(Grant Lotter) #17

Paul,

The confusing bit is that the relevant text is being placed in $Text as the RIS format is selected in Bookends but is also, always, placed in $ReferenceRIS. So you don’t have to parse $Text, though you could be perverse and do so!

Now the interesting thing I’ve just noticed: If you either restartTbx (cmd-q, restart) or save, close and reload the file then the $PDF KA is populated with the contents of L1 in place of $1.

No such restart/reload is needed for other bib managers (bibdesk and zotero are the two I’ve tried). So the problem lies somewhere in the tbx/bookends relationship – tbx does more for bookends imports than other bib manangers. Report to eastgate.


(Grant Lotter) #18

@mwra
It’s not an agent query, it’s a rule.


(Mark Anderson) #19

In that case, I believe you need to put the .contains evaluation in an if() statement, qv my comment above about back-references & context, in order to access $! from the .contains() test… A rule something like (not tested):

if($ReferenceRIS.contains("L1 - ([^\n]*)\n")){
$PDF=$1;
};
$PDF=$PDF.replace("L1 - ","").replace("\n","")

The last list above could be inside the if clause - it’s moot as it doesn’t need access to the $1 back-reference.


(Grant Lotter) #20

Right! It was sloppy of me to assume that the L1 field even exists in an arbitrary RIS record. Though if it’s empty then Bookends won’t even include an L1 line, so you can just set $PDF to be null. (I did do this properly in another related RIS thread a while back.)