Click here to Skip to main content
15,881,613 members
Articles / Web Development / ASP.NET

Music and the Semantic Web

Rate me:
Please Sign up or sign in to vote.
4.64/5 (14 votes)
10 Aug 2006CPOL7 min read 108.1K   3.7K   58  
An article on the semantic Web and a simple music application
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SemWeb;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //A place where the triples will be stored. 
        Store store = new MemoryStore();
        Store store2 = new MemoryStore();
     

        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        doc.Load("http://www.example.org/mp3/music.xml");
        store.Import(new RdfXmlReader(doc));

        System.Xml.XmlDocument doc3 = new System.Xml.XmlDocument();
        doc3.Load("http://itsp.science.anglia.ac.uk/portal/student/temp/tracks.xml");
        store.Import(new RdfXmlReader(doc3));


        //Define some representations (Entities)
        const string RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
        const string GEN = "http://www.example.org/genre.xml";

        Entity rdftype = RDF + "type";
        Entity GENjazz = GEN + "#jazz";
        
        System.Xml.XmlDocument doc2 = new System.Xml.XmlDocument();
        doc2.Load("http://itsp.science.anglia.ac.uk/apum3/1.0/genre.xml");

        SemWeb.Inference.RDFS rdfs = new SemWeb.Inference.RDFS(new RdfXmlReader(doc2), store);
        rdfs.Select(new Statement(null, rdftype, GENjazz), store2);

        foreach (Statement s in store2.Select(new Statement(null, null, null)))
        {
            output1.Text += s.Subject.Uri + s.Predicate.Uri + s.Object.Uri + "\n";
        }
        output1.Text += "\n";

        foreach (Statement s in store.Select(new Statement(null, null, null)))
        {
            output2.Text += s.Subject.Uri + s.Predicate.Uri + s.Object.Uri + "\n";
        }
        output2.Text += "\n";
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
Chris is a PhD research student working on machine learning in the area of music information systems. His current incarnation lecturers and researches at Anglia Ruskin University as part of the Audio music technology pathway. He has published in journals and has worked as a network consultant to finance his research. He entered the world of windows programming while writing a piece of software for music genre recognition. A passion for music technology has lead him to explore some of the fundamentals of audio programming.

Comments and Discussions