Tuesday, September 20, 2011

Copy and Paste with Semantics...

Copy and Paste now preserves RDF between both Calligra and abiword in both directions. This lets you select some text in a document in either application, copy it, and paste it into the other application and have the RDF that is associated with that part of the document go along with the text you selected.

In the below screencast, the document that Calligra is editing has some contact and event information stored in RDF. The three people in the first sentence all have contact information associated. As you can see, the RDF sidepanel in Calligra lets you know about this as the cursor moves around. James has his phone number captured in RDF which the edit dialog shows. If I select one or more of these contacts and "Copy" them to the clipboard, Calligra creates an ODF file with embedded RDF in it and offers that on the clipboard.

Abiword is happy to accept that ODF content and when you paste it into a document you can see that the RDF links are preserved, and that there are 7 RDF triples associated with James. Of course, you want full disclosure of this information, so clicking show RDF lets you examine and edit those RDF triples.

Copy and Paste of RDF from Calligra to Abiword from Ben Martin on Vimeo.



I put a little trick in going the other way just to spice things up a little bit. The multi.odt file that I have open in abiword has two RDF links in scope at the Wing-B link. RDF is associated with the whole paragraph and explicitly with the link itself. In particular, the uri:widetime is associated with the paragraph while the uri:wingb is associated with the RDF link itself. Once I grab that RDF link and copy it to the clipboard, again an ODF file is offered (as well as text and rtf), and again Calligra is more than happy to accept an ODF file on the clipboard. Notice that when I show all the RDF in Calligra both the widetime and wingb RDF triples have now become part of the document.

Copy and Paste from Abiword to Calligra from Ben Martin on Vimeo.



I made some changes in both calligra and abiword to get this to happen. Changes to the former were quite small. You'll have to grab trunk from both applications if you want to play along at home. The code is committed in both trees.

9 comments:

Dion Moult said...

Clever, very clever. Now we just need to make it useful enough to the end-user.

Where does it store/index this rdf information? What if there were multiple people called James? Does it automatically assign the data as you type in "James" or do you have to do it manually?

monkeyiq said...

The RDF is stored in RDF/XML inside the ODF container. See the manifest.rdf file etc in the ODF file format spec.

In calligra, to insert a contact or other RDF object use the menu Insert/Semantic Object/Create/...

If two people are called James, they can either reference the same RDF if they are the same James, or you can have as many Jameses as you like, each with their own proper detail.

But you have to assign the extra data, which can be done using Drag and Drop from your favourite PIM application.

Marty McK said...

How about Nepomuk integration? And using Nepomuk's ontologies? Is it planned?

monkeyiq said...

Calligra already uses soprano so adding closer Nepomuk integration there should be fairly simple. It was and is on my TODO list for Calligra, though that list seems to grow and shuffle a lot :/

For both apps, using Sem Web services will be a great boost. Tapping into the Linking Open Data project and others.

AGui said...

This is very interesting. Seeing more interoperability between word processors is a very news. Do you know if there are plans to make it possible with LibreOffice?

From a user point-of-view however, I think the term RDF is not adapted. In Calligra, naming the sidepanel "RDF" won't tell the user anything. Same thing in Abiword in the right-click menu.

RDF is a term used to describe a technology while I think the user is expecting a term describing the usage. Even "semantic" is not clear for most users. Maybe "contextual information" would be adapted, but I don't know if this covers all the applications of RDF.

Anyway, I'm really looking forward to using Calligra 2.4 !

ingwa said...

Is it also possile to drag&drop from LibreOffice or OOo?

monkeyiq said...

@ingwa: LibreOffice and OOo are on my radar for upcoming interoperability. OOo supports RDF so things *should* work. I need to update my LO/OO to the latest versions so comparisons are on an equal starting ground and I'm not discovering things that are already fixed.

monkeyiq said...

@AGui: I'm planning to tinker with LO soon.

I'm always open to ways to present these sorts of things to users which make them easier to use and get into. One area is how to link RDF to content in the document. On a technical angle, this is usually done by having a triple link to an xml:id attached to something in content.xml. In abiword I've called them "RDF Links" for now. You can make them with a user interface that is similar to bookmarks, and then associate meaning with them. I could call the RDF links "semantic associations" instead but it seems to mostly be longer and perhaps not more friendly either.

Perhaps other use cases like drag and drop to create RDF in document are things that can create a desire to use the technology. If folks can quickly see what they might get out of using RDF then that might widen the user base... Hopefully.

Sujay said...

This site is very good.Thank you.