SemWebProgrammingLanguage

From W3C Wiki

A Semantic Web Programming Language

wikiname:: SemWebProgrammingLanguage

unixname:: aspl (hint to apl)

author:: LeoS, Jean Rohmer, and you?

Abstract

Inspired by a talk by Jean Rohmer on artificial intelligence and his use of APL in the Thales product Ideliance. In a session after the talk, we discussed programming languages for the Semantic Desktop, also we wanted to know how he did that bugfixing magic and what these weird symbols were. We were flattened about the statement that Ideliance was completly programmed using APL (A programming language).

Related Wok

Approach

We asked him to show us code, and he replied that he will instead teach us how to code APL. behold, this is what Jean Rohmer has written on a Flip-Chart:

148674163_66ccb4bb13_m.jpg

The explanation is: that code selects all classes CS of an instance X, for each class C in CS, selects all other instances CI, for all these instances I select all triples, from the triples select all properties.

Then group these properties in a matrix, sort them and only return top X of them.

To do this in SPARQL, you would roughly do:

SELECT p WHERE x rdf:type C. I rdf:type C. I p o.

But then you would need some sorting, merging, splicing.

APL is the weirdest thing I have ever seen, but it has many pieces of code in it that are very useful for handling RDF, though. Jean Rohmer and Gunnar Grimnes are both Prolog fans and they chatted about the relations between ADL and prolog.

  • Epilogue*

Using Java to program Semantic Web applications surely is hell when you have to do things like set operations. At the moment I program bits and pieces of the rebirth-machine, for example this code would be much nicer in APL. So we seriously think about combining SPARQL and prolog into some nice semantic web scripting language.

hier beschreiben...

Example: Michael Sintek's scripting language

Michael Sintek created a scriping language for a DFKI software project, it works like this:


// repair swinto ontology

setDebug false

// directories
abbrev "$ONTDIR" = ".."
abbrev "$SOBADIR" = "../../extraction/results"

// namespaces
abbrev "linginfo:" = "http://smartweb.semanticweb.org/ontology/linginfo#"
abbrev "smartdolce:" = "http://smartweb.semanticweb.org/ontology/smartdolce#"
abbrev "smartsumo:" = "http://smartweb.semanticweb.org/ontology/smartsumo#"
abbrev "sportevent:" = "http://smartweb.semanticweb.org/ontology/sportevent#"

// load kb
loadModel "$ONTDIR/swinto/swinto.rdfs"
loadModel "$ONTDIR/swinto/swinto.rdf"
loadModel "$ONTDIR/swinto/swinto-no-xsd.rdfs"
loadModel "$ONTDIR/swinto/swinto-no-xsd.rdf"
//loadModel "$SOBADIR/soba-facts_small.rdf"
//loadModel "$SOBADIR/soba-facts_small-extension.rdf"
loadModel "$SOBADIR/sobas/soba.rdf"
loadModel "$ONTDIR/sportevent/worldcup.rdf" // temporarily needed (Gerd)
printStatistics

// repair simple syntactic URI problems
repairURIs

// delete unused instances
deleteUnreferencedResources recurse class="linginfo:LingInfo"
printStatistics

// rename instances

renameInstances class="linginfo:LingInfo"
  localName = "LingInfo_"
    + prop("linginfo:term", ERROR) 
    + "_"
    + prop("linginfo:lang", "any")

renameInstances class="smartdolce:natural-person-denomination"
  localName = prop("smartdolce:NAME", ERROR)

renameInstances class="smartsumo:country-denomination"
  localName = prop("smartdolce:NAME", ERROR)

renameInstances class="smartsumo:Man"
  localName = "Man_" + prop("smartdolce:HAS-DENOMINATION")

renameInstances class="smartsumo:Country"
  localName = "Country_" + prop("smartdolce:HAS-DENOMINATION", ERROR)

renameInstances class="smartsumo:City"
  localName = "City_" + prop("smartdolce:IDENTIFIER", ERROR)

renameInstances class="smartsumo:Address"
  localName = "Address_" 
              + prop("smartsumo:hasCountry", ERROR) + "_"
              + prop("smartsumo:hasCity", ERROR)
              // TODO: plus other details if available

renameInstances class="sportevent:Stadium"
  localName = "Stadium_" 
    + prop("smartdolce:IDENTIFIER", "") // randomly, either sd:IDENTIFIER or
    + prop("sportevent:name", "")       // or se:name is used  :-( 
    + "_" 
    + prop("smartsumo:hasAddress", "")  // same problem here  :-( 
    + prop("sportevent:location", "")

renameInstances class="sportevent:FIFAWorldCup"
  localName = "FIFAWorldCup_"  
    + prop(  "smartdolce:HAPPENS-AT" // path to year
           . "smartdolce:BEGINS"
           . "smartdolce:YEAR", ERROR)
    // + prop("sportevent:officialName", ERROR) // Gerd hates the names  :-) 

renameInstances class="sportevent:WorldCupMascot"
  localName = prop("sportevent:inTournament")
    + "_Mascot_"
    + prop("sportevent:name", ERROR)
  /* old version: 
  localName = "WorldCupMascot_"  
    + prop(  "sportevent:inTournament" // path to year
           . "smartdolce:HAPPENS-AT"
           . "smartdolce:BEGINS"
           . "smartdolce:YEAR", ERROR)
    + "_"
    + prop("sportevent:name", ERROR) // name
  */

renameInstances class="sportevent:WorldCupPoster"
  localName = prop("sportevent:inTournament") + "_Poster"
  /* old version: 
  localName = "WorldCupPoster_"
    + prop(  "sportevent:inTournament" // path to year
           . "smartdolce:HAPPENS-AT"
           . "smartdolce:BEGINS"
           . "smartdolce:YEAR", ERROR)
    // no name as posters have no names (I guess)
  */

renameInstances class="sportevent:OfficialWorldCupBall"
  localName = prop("sportevent:inTournament")
    + "_Ball_"
    + prop("sportevent:name", ERROR)
  /* old version: 
  localName = "WorldCupBall_"
    + prop(  "sportevent:inTournament" // path to year
           . "smartdolce:HAPPENS-AT"
           . "smartdolce:BEGINS"
           . "smartdolce:YEAR", ERROR)
    + "_"
    + prop("sportevent:name", ERROR) // name
  */

renameInstances class="sportevent:FootballNationalTeam"
  localName = "NationalTeam_"  
    + prop("sportevent:origin" . "smartdolce:HAS-DENOMINATION", ERROR) // country
    + "_"
    + prop(  "sportevent:inTournament" // path to year
           . "smartdolce:HAPPENS-AT"
           . "smartdolce:BEGINS"
           . "smartdolce:YEAR", ERROR)

setDebug true // here we currently test

renameInstances class="sportevent:GroupStageFootballMatch"
  localName = "FootballMatch_"  
    + prop("smartdolce:HAPPENS-AT" . "smartdolce:YEAR", ERROR)
    + "_"
    + prop("smartdolce:HAPPENS-AT" . "smartdolce:MONTH", ERROR)
    + "_"
    + prop("smartdolce:HAPPENS-AT" . "smartdolce:DAY", ERROR)
    + "_"
    + prop(  "sportevent:team1"  // team 1 country
           . "sportevent:partOf"
           . "sportevent:partOf"
           . "sportevent:origin"
           . "smartdolce:HAS-DENOMINATION", ERROR)
    + "_"
    + prop(  "sportevent:team2"  // team 2 country
           . "sportevent:partOf"
           . "sportevent:partOf"
           . "sportevent:origin"
           . "smartdolce:HAS-DENOMINATION", ERROR)

setDebug false

/* TODO for Gerd
OK -- sportevent:FIFAWorldCup
OK -- sportevent:WorldCupPoster
OK -- sportevent:WorldCupMascot
OK -- sportevent:OfficialWorldCupBall
OK -- sportevent:FootballNationalTeam
sportevent:FootballPlayer
sportevent:GroupStageFootballMatch
sportevent:ScoreGoal
sportevent:ShowingRedCard
*/


printStatistics

// save kb
saveModels suffix=".repaired" syntax="RDF/XML"
//saveModels overwrite syntax="RDF/XML-ABBREV"