SlideShare a Scribd company logo
rdfapi.js and js3.js by webr3
rdfapi.js and js3.js by webr3
$ git clone https://github.com/webr3/js3.git
$ git checkout origin/rdfa-api-integration



<script type=”text/javascript” src=”js3.js”></script>




var js3 = require(‘./js3.node.js’);
rdfapi.js and js3.js by webr3
rdfapi.js and js3.js by webr3
var context = new rdfapi.Context();
var parser = new rdfapi.parsers.Turtle(context);
var serializer = new rdfapi.serializers.Turtle(context);

var turtle_text = ‘@prefix ex: <http://example.com/people/> .¥
    @prefix foaf: <http://xmlns.com/foaf/0.1/> .¥
¥
    ex:taro a foaf:Person;¥
        foaf:name “Taro”;¥
        foaf:age 25 .’;

parser.parse(turtle_text, function(graph){
    console.log(serializer.serialize(graph));
});
parser.parse(turtle_text, function(graph){
    graph.forEach(function(triple){ // show each triples
        console.log(triple.toString());
    })

      graph.add(triple2); // add a triple to the graph

      // use filter
      var filter = rdfapi.filters.p(“owl:sameAs”);
      graph.some(filter);
      graph.every(filter);
      graph.filter(filter);

      graph.merge(other_graph);
});
rdfapi.js and js3.js by webr3
rdfapi.js and js3.js by webr3
var taro = {
    a: “foaf:Person”,
    name: “Taro Yamada”,
    age: new Date().getFullYear() - 1984,
    homepage: “http://example.com/home/taro”
}.ref(“http://example.com/rdf/taro”);

console.log(taro.n3());
var taro = {
    a: “foaf:Person”,
    name: “Taro Yamada”,
    age: new Date().getFullYear() - 1984,
    homepage: “http://example.com/home/taro”
}.ref(“http://example.com/rdf/taro”);

console.log(taro.n3());
var taro = {
    a: “foaf:Person”,
    name: “Taro Yamada”,
    age: new Date().getFullYear() - 1984,
    homepage: “http://example.com/home/taro”
}.ref(“http://example.com/rdf/taro”);

console.log(taro.n3());
var taro = {
    a: “foaf:Person”,
    name: “Taro Yamada”,
    age: new Date().getFullYear() - 1984,
    homepage: “http://example.com/home/taro”
}.ref(“http://example.com/rdf/taro”);

console.log(taro.n3());
var taro = {
    a: “foaf:Person”,
    name: “Taro Yamada”,
    age: new Date().getFullYear() - 1984,
    homepage: “http://example.com/home/taro”
}.ref(“http://example.com/rdf/taro”);

console.log(taro.n3());


                           ↓
var taro = {
    a: “foaf:Person”,
    name: “Taro Yamada”,
    age: new Date().getFullYear() - 1984,
    homepage: “http://example.com/home/taro”
}.ref(“http://example.com/rdf/taro”);

console.log(taro.n3());


                           ↓
   <http://example.com/rdf/taro> rdf:type foaf:Person;
       foaf:name “Taro Yamada”;
       foaf:age 27;
       foaf:homepage <http://example.com/home/taro> .
rdfapi.js and js3.js by webr3
rdfapi.js and js3.js by webr3
// TypedLiteral    .type      IRI            (       CURIE   )
(true).type;         //=>   xsd:boolean
(new Date()).type;   //=>   xsd:dateTime
(10).type;           //=>   xsd:integer
(3.14).type;         //=>   xsd:decimal

// .nodeType()    TypedLiteral, PlainLiteral, BlankNode, IRI
(10).nodeType();                      //=>   TypedLiteral
“hello”.nodeType();                   //=>   PlainLiteral
“_:b12”.nodeType();                   //=>   BlankNode
“foaf:name”.nodeType();               //=>   IRI
“http://example.com/”.nodeType();     //=>   IRI
// foaf:name   2
var me1 = { “foaf:nick”: [“nick”, “name”] }.ref();

// RDF List
var me2 = { “foaf:nick”: [“nick”, “name”].toList() }.ref();
var taro = {
    name: “Taro”,
    holdsAccount: {
        accountName: ‘xxx’,
        homepage: ‘http://twitter.com/xxx’,
    }
}.ref(“:taro”);




var jiro = { “foaf:knows”: taro }.ref(“:jiro”);
var me = { name: “Taro”, age: 27 }.ref(“:me”);
console.log(typeof me.age);                       //=> number
console.log((new Date()).getFullYear() - me.age); //=> 1984
console.log(me.name.toUpper());                   //=> “TARO”
// parsing by rdfapi.js
parser.parse(“SOME RDF STRING”, function(graph){
    var data = {
        a: “foaf:Document”,
        ...,
    }.ref(“:book”);

      graph.merge(data.graphify()); //
});
rdfapi.js and js3.js by webr3
rdfapi.js and js3.js by webr3

More Related Content

PDF
20th.陈晓鸣 百度海量日志分析架构及处理经验分享
PDF
JSON Schema in Web Frontend #insideFE
PPT
spug_2008-08
PPT
php file uploading
PPTX
MongoDB (Advanced)
PPT
PHP - Introduction to File Handling with PHP
TXT
Logrotate sh
PPTX
Php File Operations
20th.陈晓鸣 百度海量日志分析架构及处理经验分享
JSON Schema in Web Frontend #insideFE
spug_2008-08
php file uploading
MongoDB (Advanced)
PHP - Introduction to File Handling with PHP
Logrotate sh
Php File Operations

What's hot (20)

PDF
MongoDB Advanced Topics
PDF
Files in c
DOCX
Php files
PDF
Mengembalikan data yang terhapus atau rusak pada hardisk menggunakan ubuntu
DOC
Agente Inteligente Ontologia y Tripletas
PPT
Files and Directories in PHP
PDF
scdevsumit 2016 - Become a jedi with php streams
PPTX
R- create a table from a list of files.... before webmining
PDF
TDC São Paulo 2016 - Become a jedi with php streams
PDF
Sparql
PPT
Filing system in PHP
PDF
Creating a phar
PDF
Scala and big data in ICM. Scoobie, Scalding, Spark, Stratosphere. Scalar 2014
PDF
Php file handling in Hindi
PDF
PHP file handling
PPT
Php File Operations
PPTX
Be Lazy & Scale
PPTX
Non-Relational Databases
PDF
TDC2016SP - Become a jedi with PHP streams
PDF
Class 7b: Files & File I/O
MongoDB Advanced Topics
Files in c
Php files
Mengembalikan data yang terhapus atau rusak pada hardisk menggunakan ubuntu
Agente Inteligente Ontologia y Tripletas
Files and Directories in PHP
scdevsumit 2016 - Become a jedi with php streams
R- create a table from a list of files.... before webmining
TDC São Paulo 2016 - Become a jedi with php streams
Sparql
Filing system in PHP
Creating a phar
Scala and big data in ICM. Scoobie, Scalding, Spark, Stratosphere. Scalar 2014
Php file handling in Hindi
PHP file handling
Php File Operations
Be Lazy & Scale
Non-Relational Databases
TDC2016SP - Become a jedi with PHP streams
Class 7b: Files & File I/O
Ad

Viewers also liked (11)

PPTX
第1回Linked Data勉強会:ReDeFer
PPTX
Linkeddata.jp study meeting #1
PDF
第1回LinkedData勉強会
PDF
XLWrapについてのご紹介
PDF
SPARQL Timelinerの使い方
PDF
Linked data the next 5 years - From Hype to Action
PDF
SPARQLを利用した逆マッシュアップ-プログラミングを必要としないアプリ作成方法-
PDF
第7回 Linked Data 勉強会 @yayamamo
PDF
Chainerの使い方と 自然言語処理への応用
PDF
自然言語処理のためのDeep Learning
PPTX
深層学習による自然言語処理の研究動向
第1回Linked Data勉強会:ReDeFer
Linkeddata.jp study meeting #1
第1回LinkedData勉強会
XLWrapについてのご紹介
SPARQL Timelinerの使い方
Linked data the next 5 years - From Hype to Action
SPARQLを利用した逆マッシュアップ-プログラミングを必要としないアプリ作成方法-
第7回 Linked Data 勉強会 @yayamamo
Chainerの使い方と 自然言語処理への応用
自然言語処理のためのDeep Learning
深層学習による自然言語処理の研究動向
Ad

Similar to rdfapi.js and js3.js by webr3 (20)

PDF
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
PDF
Jarrar: RDFa
PDF
2016-02 Graphs - PG+RDF
PDF
Introduction to Graph Databases
PPT
Ks2007 Semanticweb In Action
PDF
XSPARQL Tutorial
KEY
Ruby semweb 2011-12-06
PDF
Tutorial for RDF Graphs
PDF
Two graph data models : RDF and Property Graphs
PDF
Rdf data-model-and-storage
PPTX
Sparql
PDF
Tools and Projects Dec 2018 Edition
PPTX
Jarrar: RDFa
PDF
The Semantic Web Client Library - Consuming Linked Data in Your Applications
PDF
SPARQL and Linked Data
PPTX
What’s new in ECMAScript 6.0
PDF
Semantic Web(Web 3.0) SPARQL
PPTX
SPARQL
PPTX
Triplestore and SPARQL
PPTX
Transformational Tricks for RDF.pptx
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
Jarrar: RDFa
2016-02 Graphs - PG+RDF
Introduction to Graph Databases
Ks2007 Semanticweb In Action
XSPARQL Tutorial
Ruby semweb 2011-12-06
Tutorial for RDF Graphs
Two graph data models : RDF and Property Graphs
Rdf data-model-and-storage
Sparql
Tools and Projects Dec 2018 Edition
Jarrar: RDFa
The Semantic Web Client Library - Consuming Linked Data in Your Applications
SPARQL and Linked Data
What’s new in ECMAScript 6.0
Semantic Web(Web 3.0) SPARQL
SPARQL
Triplestore and SPARQL
Transformational Tricks for RDF.pptx

Recently uploaded (20)

PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Electronic commerce courselecture one. Pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
Advanced Soft Computing BINUS July 2025.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Per capita expenditure prediction using model stacking based on satellite ima...
Empathic Computing: Creating Shared Understanding
Electronic commerce courselecture one. Pdf
Review of recent advances in non-invasive hemoglobin estimation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Mobile App Security Testing_ A Comprehensive Guide.pdf
Chapter 3 Spatial Domain Image Processing.pdf
20250228 LYD VKU AI Blended-Learning.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
“AI and Expert System Decision Support & Business Intelligence Systems”
Understanding_Digital_Forensics_Presentation.pptx
GamePlan Trading System Review: Professional Trader's Honest Take

rdfapi.js and js3.js by webr3

  • 3. $ git clone https://github.com/webr3/js3.git $ git checkout origin/rdfa-api-integration <script type=”text/javascript” src=”js3.js”></script> var js3 = require(‘./js3.node.js’);
  • 6. var context = new rdfapi.Context(); var parser = new rdfapi.parsers.Turtle(context); var serializer = new rdfapi.serializers.Turtle(context); var turtle_text = ‘@prefix ex: <http://example.com/people/> .¥ @prefix foaf: <http://xmlns.com/foaf/0.1/> .¥ ¥ ex:taro a foaf:Person;¥ foaf:name “Taro”;¥ foaf:age 25 .’; parser.parse(turtle_text, function(graph){ console.log(serializer.serialize(graph)); });
  • 7. parser.parse(turtle_text, function(graph){ graph.forEach(function(triple){ // show each triples console.log(triple.toString()); }) graph.add(triple2); // add a triple to the graph // use filter var filter = rdfapi.filters.p(“owl:sameAs”); graph.some(filter); graph.every(filter); graph.filter(filter); graph.merge(other_graph); });
  • 10. var taro = { a: “foaf:Person”, name: “Taro Yamada”, age: new Date().getFullYear() - 1984, homepage: “http://example.com/home/taro” }.ref(“http://example.com/rdf/taro”); console.log(taro.n3());
  • 11. var taro = { a: “foaf:Person”, name: “Taro Yamada”, age: new Date().getFullYear() - 1984, homepage: “http://example.com/home/taro” }.ref(“http://example.com/rdf/taro”); console.log(taro.n3());
  • 12. var taro = { a: “foaf:Person”, name: “Taro Yamada”, age: new Date().getFullYear() - 1984, homepage: “http://example.com/home/taro” }.ref(“http://example.com/rdf/taro”); console.log(taro.n3());
  • 13. var taro = { a: “foaf:Person”, name: “Taro Yamada”, age: new Date().getFullYear() - 1984, homepage: “http://example.com/home/taro” }.ref(“http://example.com/rdf/taro”); console.log(taro.n3());
  • 14. var taro = { a: “foaf:Person”, name: “Taro Yamada”, age: new Date().getFullYear() - 1984, homepage: “http://example.com/home/taro” }.ref(“http://example.com/rdf/taro”); console.log(taro.n3()); ↓
  • 15. var taro = { a: “foaf:Person”, name: “Taro Yamada”, age: new Date().getFullYear() - 1984, homepage: “http://example.com/home/taro” }.ref(“http://example.com/rdf/taro”); console.log(taro.n3()); ↓ <http://example.com/rdf/taro> rdf:type foaf:Person; foaf:name “Taro Yamada”; foaf:age 27; foaf:homepage <http://example.com/home/taro> .
  • 18. // TypedLiteral .type IRI ( CURIE ) (true).type; //=> xsd:boolean (new Date()).type; //=> xsd:dateTime (10).type; //=> xsd:integer (3.14).type; //=> xsd:decimal // .nodeType() TypedLiteral, PlainLiteral, BlankNode, IRI (10).nodeType(); //=> TypedLiteral “hello”.nodeType(); //=> PlainLiteral “_:b12”.nodeType(); //=> BlankNode “foaf:name”.nodeType(); //=> IRI “http://example.com/”.nodeType(); //=> IRI
  • 19. // foaf:name 2 var me1 = { “foaf:nick”: [“nick”, “name”] }.ref(); // RDF List var me2 = { “foaf:nick”: [“nick”, “name”].toList() }.ref();
  • 20. var taro = { name: “Taro”, holdsAccount: { accountName: ‘xxx’, homepage: ‘http://twitter.com/xxx’, } }.ref(“:taro”); var jiro = { “foaf:knows”: taro }.ref(“:jiro”);
  • 21. var me = { name: “Taro”, age: 27 }.ref(“:me”); console.log(typeof me.age); //=> number console.log((new Date()).getFullYear() - me.age); //=> 1984 console.log(me.name.toUpper()); //=> “TARO”
  • 22. // parsing by rdfapi.js parser.parse(“SOME RDF STRING”, function(graph){ var data = { a: “foaf:Document”, ..., }.ref(“:book”); graph.merge(data.graphify()); // });

Editor's Notes