Tagging Semantic Articles Outside of the Factbox

One of my favorite Semantic MediaWiki features is the factbox. It’s a quick way to browse wiki content by property values.

What if you want a similar browsing interface within a wiki page? For example, let’s say you want a value for a property you use to ‘tag’ an article to provide a link to a list of all pages with that property/value pair. Here’s one way how. 1

For the past year one of the ways we’ve been using our wiki is to publish an internal monthly newsletter. Each newsletter article is a wiki page, with a template providing consistent navigation.

Screen Shot 2014-12-17 at 1.19.10 PM

 

Along the right hand column of every article are the tags for the audience and topic areas related to the article.

linked-list

Recently I made an addition to the list of Audience and Topic Area tags to provide dynamic links to all pages with that property value. I’m leveraging the SMW Special:SearchByPropertySpace special page.

In the article template, with the property “Facets Article Topic Areas” you’ll want to use an arraymaptemplate 2 to format the comma separated list of values. 3

'''Topic Areas''': {{#arraymaptemplate:{{{Facets Article Topic Areas|}}}|SearchByPropertySpace-FacetsArticleTopicAreas|,|, }}

What this will do is take every value for the property Facets Article Topic Areas and use the SearchByPropertySpace-FacetsArticleTopicAreas 4 template to format each value. Each value is separated by comma, and our final output will be separated by a comma and a space.

In the template “SearchByPropertySpace-FacetsTopicAreas” we have the following.

[[Special:SearchByProperty/Facets-20Article-20Topic-20Areas/{{#replace:{{{1}}}| |-20}}|{{{1}}}]]

This creates a link to Special:SearchByProperty where the property name is Facets Article Topic Areas and the value is each comma separated value from our arraymaptemplate.

The replace parser function converts values with spaces to URL encoded characters.

SearchByProperty

The result is that every topic area listed on the page becomes a link to Special:SearchByProperty that shows all pages with that value.

Screen Shot 2014-12-17 at 5.02.52 PM

When editors add a new article they only have to add a list of topic areas. 5 This makes in-article links to all other articles a click away without having to scroll to the bottom of the page to view the factbox.

SMWCon Spring 2014 in Review

SMW-Logo

A few weeks ago my colleague Nancy and I went to Montreal Canada for the Semantic MediaWiki Conference. We both attended and presented. It was three days of insightful conversation, interesting perspectives, and amazing uses cases for leveraging semantic data. I wanted to write down a few of my thoughts before they escape me. The short version is thus, “Montreal is beautiful and unique, the conference was well worth the time, and I feel ever more encouraged that Semantic MediaWiki and related technologies are necessary as we develop new ways of creating and sharing information”.

Montreal

14054936288_a4003a32c7_z

This trip was my first time out of the US and I have to say I couldn’t have picked a better city as my first experience. It was an amazing comparison to my home town of St. Louis – which since most people moved to the suburbs 60 years ago often feels empty and beleaguered in the evenings. Montreal is a lively city with people of all walks coming and going. I felt safe at all times I was out and was in love with the amount of diversity. Languages, culture, fashion – and food!

Speaking of food, we ate at a few places similar to what we’d have back home (Mexican, Thai, Pub) but everything tasted better. Better spices, ingredients, or something in the water made everything more enjoyable. Perhaps this is some sort of travel placebo, but I’m already wanting to go back just for the food.

Montreal also was more colorful than I expected. Clothing, architecture, and graffiti were all vibrant indicators of a living, functional city.

The only downside, and this is not specific to Montreal, is the number of people smoking. None of the places we visited allowed for indoor smoking, but as soon as you stepped onto the sidewalk you’d be guaranteed to smell someone smoking. There was an amazing number of young people smoking as well, which struck me as both unfortunate and baffling.

SMWCon

 

From Pierre Deschênes

The conference was well-organized with a great group of diverse speakers. The schedule had ample wiggle room for speakers that went long or short and at every frequent break there were refreshment to keep us going. Concordia University played host to our merriment and their facilities were astounding. We spent most of the week in their business school, just a few short blocks from the hotel.

 

People & Presentations

Before I mention any individual I want to say that everyone was very pleasant and helpful. I know I’m going to miss names, as is the risk of lists like this, but I’m going to try to include a few highlights.

Yolanda Gil’s presentation kicked off what ended up being an underlying current through the entire week. The adoption and use of semantic information is less technical and more cultural. It’s important to be able to easily and succinctly explain the value of ontologies and semantic data. We also must be good stewards (to steal a phrase from my employer) of the communities we create. Make things easy, make them show value and deliver on the promise quickly and as iteratively as possible.

Rene Witte & Bahar Sateli played host to the conference. As a professor and research respectively they followed Yolanda’s presentation with a great overview of their work in adapting Natural Language Processing to Semantic MediaWiki. The idea of using NLP to summarize and extract information and infuse the knowledge within wiki was very interesting. As I watched their presentation I was waiting for them to say that their work was some how limited by licensing or technology – nope! It’s all built upon open-source libraries and can be used and extended by anyone!

David Mason was not only another member of our hosting party, but provided a great beginner’s guide to Semantic MediaWiki. Something I felt as being very useful even having used the software for many years now. I learned in later conversations that it was also much appreciated by newcomers to SMW who came to the conference to learn more.

Guillaume Coulombe is not only a fine fiddle player but along with Pierre Deschênes are trying their hardest to leverage SMW in numerous business settings – including healthcare! It was both endearing and frustrating to learn they too butt up against some of the same issues when trying to convince subject matter experts to contribute their knowledge.

Ali King and her mentor Joel Sachs introduced many of us to the concept of semantic triples. Something I was aware of tangentially when using SMW, but never had a formal introduction. Their presentation (both planned and ad-hoc) where useful to bringing further understanding to RDF and the concepts of semantic data.

Marcus Krötzsch is the first person from SMW I had the chance to meet in person. His very knowledgeable and level-headed presentation on Wikidata left me thinking that the future of both SMW and Wikidata are in good hands. I think he’s a good person to be championing for the semantic web (whether he is intentionally or not).

Yaron Koren literally wrote the book on MediaWiki and Semantic MediaWiki in particular. Always helpful, his presentation on the future of Semantic Forms was an interesting insight into the future of the extension and a lot of the underlying thoughts behind its intention. I encourage him to take a look at VisualEditor support in future releases. My only thought is that I wish I had the smarts or means to make it happen myself.

I was happy to meet Mark Hershberger. He’s someone who has worked closely with Wikimedia and sees the need for growing the community around 3rd party wiki. As someone who works almost exclusively with a third-party wikis, I found his work to be encouraging and I hope I can personally help move things forward when it comes to helping to better articulate the impact WikiMedia has on MediaWiki, and by exchange the thousands of wiki that aren’t Wikipedia.

Small side note – his brother works at Express Scripts, a local company here in St. Louis. Stranger still, quite a few of my current co-workers at Mercy came from Express Scripts. It is very likely Mark and I were twice or thrice removed before we met at SMWCon. The world is small.

Matt Hall is a disgustingly handsome Brit who works in geosciences. He was a great presenter and humorously presented the first end-of-presentation “Questions?” slide that asked the audience questions he had. Luckily I think we were able to answer a number of them.

Did I mention Peter Woudsma who works at NATO and uses a wiki to track their work around enterprise architecture? Or Frank Taylor who is seeking to develop tools for those in need to help translate legal information? How about Jimmy St-Germain, and his astounding collection of musical knowledge for Cirque du Soleil? The conference was filled with wonderful people who are all doing good stuff.

At last I’d like to thank Nancy Krautmann, my colleague who I traveled with for this conference. Thanks for putting up with me for the entire week, even after I got sick on our last day and turned into a pile of useless goo. I had a great time in your company and was once again reminded why I like working with you so much.

Final Thoughts

The conference covered many technical aspects (triples, NLP integration, even a few new extensions I never heard of), but the biggest value was spending some time with people who are working toward the same goals, documenting and sharing information in one of the most collaborative environments possible. I’m grateful that I was able to attend and take back the collective experience of everyone who shared. I have a plan to put that knowledge to good use and make my own work better. I am filled with confidence that collaborative workspaces and culture are ever more important than bits and bytes. People make the difference in our endeavors and technology – even technology as good as SMW – only help to enable the further enlightenment we can provide one another.

A stream of the conference can be found on YouTube. I believe a higher quality version is being worked on as we speak. Here’s the part with our presentation.

Using External Data and the MediaWiki API to Build a List of Popular Wiki Pages

popular

For one of our internal MediaWiki installations we used the DynamicPageList extension to show a list of the most popular page on our wiki’s main page. We found it to be handy to have an at-a-glance view into what’s the most utilized content. However, we recently upgraded to a newer version of MediaWiki (1.23) and were having issues with DPL. As such our list disappeared while I worked on another solution.

What I discovered is that you can use the External Data extension paired with the MediaWiki API to produce a dynamic list of Special:PopularPages6

First to understand what the API query looks like. Here’s what I’m using:

https://yourwiki.org/w/api.php?action=query&list=querypage&qppage=Popularpages&qplimit=10&format=xml

Breaking that down, we’re asking to query (action=query) the API, return a list from a page (list=querypage) and defining which page (qppqge=Popularpages). Then we set some limits and formats (qplimit=10 and format=xml). Note: You can even use an offset (qpoffset=5) to display multiple selections of data combined with the limits.

Then, on the page you want the list to appear add the following External Data syntax.

{{#get_web_data:url=https://yourwiki.org/w/api.php?action=query&list=querypage&qppage=Popularpages&qplimit=10&format=xml
|format=XML
|data=Title=title
}}

<div>{{#display_external_table:
template=PopularPagesExtAPITable
|data=title=Title}}</div>

That syntax says get the data from the API query, format it as XML, and match up the value for Title to a local variable of title.

Then, we use #display_external_table to format the results using a template. The <div> and other syntax is for styling the results.

In the template, this case named PopularPagesExt, we have the following:

<li style="list-style-type: none;">[[{{{title}}}|{{{title}}}]]</li>

This says for each result returned in our #get_web_data query make it a list item, apply some styles (in this case removing bullets), and then use the returned value as a standard wiki link – [[Page Name|Link Text]]

The link text is the same as the name of the page. Makes sense, no?

The result is a dynamic list of Popular pages that you can place on any wiki page.