Jun 11 2009

항소심서 “티맥스서 개작” 판결… 손해배상ㆍ배포금지는 기각

지난 2004년 말 시작된 이번 소송은 티맥스소프트의 제품이 FNS사의 제품을 개작, 즉 소스코드를 도용했는 지가 핵심으로, 1심에서 프로뱅크의 개작이 인정된 이후 이번 2심에서는 프로프레임까지 개작한 것으로 판결해 재판부는 사실상 큐로컴과 FNS의 손을 들어줬다.

이번 판결에는 티맥스소프트가 두 제품의 자체개발 근거 자료를 충분히 제시하지 못한 것이 주요 요인이었던 것으로 알려졌다. 또한 티맥스소프트 제품 소스코드에 경쟁제품 제작 언어로 만들어진 주석이 다수 존재하고 있고 컴퓨터프로그램보호위원회가 두 제품간 유사도를 검증한 결과 높은 유사도를 보인 점도 고려됐다.

그러나 재판부는 티맥스소프트를 대상으로 신청한 손해배상과 배포 금지 요청은 대부분 기각했다. 큐로컴이 주장한 30억원 손해배상과 배포금지는 모두 기각됐고 호주 FNS의 피해만 일부 인정, 티맥스소프트가 1억100만원을 배상하라고 판결했다.

2심에서 개작 판결이 나옴에 따라 큐로컴은 가능한 모든 민형사상 대응에 나설 방침이다. 김동준 큐로컴 대표는 “티맥스 두 제품에 대해 개작이라고 판결된 것이 가장 중요하다”며 “티맥스소프트는 물론 프로프레임 사용 업체에 대해서도 적절한 법적 조치를 취할 것”이라고 말했다. 큐로컴은 이번 재판 결과가 대법원에서 확정될 경우 매년 1000억원 이상의 매출과 300억원 이상의 영업이익을 기대하고 있다.

전문; http://www.dt.co.kr/contents.html?article_no=2009061002010660744001

프로프레임이란

http://enc.daum.net/dic100/contents.do?query1=10XX129404
서울고등법원 민사4부가 지난달 27일 “티맥스소프트의 ‘프로뱅크’와 ‘프로프레임’은 큐로컴의 ‘뱅스’를 불법으로 개작한 것”이라며 “해당 프로그램의 배포를 금지하라”고 판결했다는 것. 1심에서 불법 개작이 입증됐던 티맥스소프트의 ‘프로뱅크’뿐만 아니라 ‘프로프레임’도 ‘뱅스’를 불법 개작했음이 명백하게 드러났다는 게 큐로컴의 설명이다.

큐로컴은 특히 “티맥스소프트 측이 ‘프로뱅크’와 ‘프로프레임’을 자체 개발했는 주장을 입증할 만한 근거자료를 전혀 제시하지 못했고, 터무니없이 짧은 기간에 결함 없는 금융 관련 소프트웨어를 개발했다는 주장을 신뢰할 수 없다는 게 재판부의 판결”이라고 전했다.

또 “‘C 언어’로 작성한 소프트웨어 원천코드에 ‘코볼언어’ 주석이 다수 존재하는 게 명백한 ‘개작의 증거’라는 주장을 재판부가 받아들였다”고 덧붙였다.

큐로컴은 이 판결을 바탕으로 티맥스소프트의 저작권 침해 행위와 핵심기술을 도용한 책임을 물을 계획이다.

전문; http://heygoodman7.tistory.com/675

쩝 그나마 IT기업중 중소기업중에서 돈좀주고 24시간 빢시게 돌리는 티맥스 지지요-_-;;

May 20 2009

개발자 일상 생활

개발자생각

ㅡ_- 일상 생활 논문 시한 마추기 커피빼고 다 같네 나랑 하루에 3시간자기

May 14 2009

4. SPARQL Protocol

4.1. Can I receive the results of SPARQL queries as RDF?

The SPARQL protocol requires that the results of SPARQL CONSTRUCT and DESCRIBE queries be RDF graphs.

SELECT and ASK queries, on the other hand, usually have their results returned as XML (or sometimes as JSON). However, as part of the group’s test suite, the DAWG includes an RDF vocabulary which can be used to represent the results of SELECT or ASK queries in RDF.

4.2. Can I receive the results of SPARQL queries as XML?

The DAWG defines an XML serialization format, the SPARQL Query Results XML Format, which is used to return the results of SPARQL SELECT and ASK queries. The SPARQL protocol requires that the results of SPARQL CONSTRUCT and DESCRIBE queries be RDF graphs, which can be represented using the XML-based RDF/XML syntax.

4.3. Can I receive the results of SPARQL queries as JSON?

JSON is a lightweight serialization format which is a subset of JavaScript’s literal-object notation. It is a useful format to use for SPARQL results when a Web client is issuing the queries and processing the results. The DAWG has published a Note defining a JSON format that closely follows the SPARQL Query Results XML Format, and which can be used to return the results of SPARQL SELECT and ASK queries.

May 13 2009

3. SPARQL Language

3.1. Can I use SPARQL to search for substring matches within literal values?

SPARQL provides the function, regex(), which can be used to test whether a literal value contains a certain substring:

   SELECT ?title
   WHERE {
     _:book :title ?title .
     FILTER (regex(?title, "SPARQL")) .
   }

3.2. Why don’t I get any matches when I use regex() to match typed literals or plain literals with language tags?

The regex() function expects its first argument to be either a plain literal without a language tag or else a typed literal with a datatype of xsd:string. Plain literals with a language tag or typed literals of other datatypes will evaluate to a type error which causes the filter to fail. If you wish regex() to match solely based upon a literal’s lexical value, use the str() function, which converts typed and plain literals to simple literals—i.e., plain literals without a language tag:

   SELECT ?title
   WHERE {
     _:book :title ?title .
     FILTER (regex(str(?title), "SPARQL")) .
   }

3.3. How can I query transitive closures / trees / hierarchies / RDF lists in SPARQL?

There is no built-in support within SPARQL to query hierarchical structures of an unknown depth (e.g. trees or lists), to query transitive relations, or to query via XPath like paths. The Data Access Working Group postponed this issue in early 2005.

There are several workarounds to perform these queries using SPARQL:

  • Repeated queries. A repeating structure can be queried via a series of queries. If the structure’s internal nodes have URIs (or if the SPARQL endpoint supports blank node identifiers which are stable across queries (”told bnodes”), then the same query can be issued repeatedly to explore the structure. Alternatively, an ever-growing query can be created which repeatedly queries the structure from its root to an increasing, fixed depth (until a desired value is found or the end of the structure is reached).
  • Inference. In an environment which supports querying over an inferred graph, inference rules can be used to specify transitive closures or hierarchy membership relations that can then be queried with SPARQL. Jos De Roo has sketched examples of such SPARQL queries using cwm and Euler and a suitable set of N3 rules.
  • Implementation-specific approaches. Several SPARQL implementations provide ways to address this question. In ARQ, for example, there are two approaches:
    1. A filter function named <java:com.hp.hpl.jena.query.function.library.listMember> which takes an RDF list node and a resource as parameters and returns true if the resource is a member of the list.
    2. A special predicate named <http://www.jena.hpl.hp.com/ARQ/list#member> can be used inside the SPARQL query pattern (the WHERE clause) to associate an RDF list head with all the list members.

3.4. Can I include subqueries in a SPARQL query?

While SPARQL does support nested graph patterns, it does not directly support subqueries (for example, the FROM clause of a SPARQL query cannot itself contain a CONSTRUCT query which generates the dataset to be queried against). The Data Access Working Group postponed this issue in early 2005. A very limited form of subqueries can be accomplished with SPARQL engines that will perform HTTP GETs upon graphs named in FROM or FROM NAMED clauses by creating a URL consisting of an embedded SPARQL CONSTRUCT query submitted to a SPARQL endpoint and supplying this URL as part of the RDF dataset being queried. In practice, this technique is often inefficient and is subject to possible URL-maximum-length restrictions of the involved software.

3.5. Can I bind a variable to a specific value (e.g., the result of a function call)?

SPARQL does not support setting variable bindings except via graph pattern matching or via the GRAPH ?g construct. Expressions are not allowed in the SELECT list of a SPARQL query.

3.6. How can I use SPARQL to query maximum/minimum values or other universally quantified criteria?

A combination of the SPARQL OPTIONAL keyword and the bound(...) filter function can be used to mimic some universally quantified queries. As an example, consider this query which finds the minimum price of every book in the underlying default graph:

  PREFIX ex: <http://example.org/>
  SELECT ?book ?minprice
  WHERE {
    ?book a ex:book ; ex:price ?minprice .
    OPTIONAL {
      ?book ex:price ?otherprice .
      FILTER( ?otherprice < ?minprice ) .
    } .
    FILTER ( !bound(?otherprice) ) .
  }

<!– @@ Needs settling of RDF term equal function situation.

How can I use SPARQL to distinguish between plain and typed literals?

use RDFTerm-equal? how is that surfaced in the syntax?

–>

3.7. Can I use SPARQL to select a single value based on an ordered list of predicates which might appear in the data?

When writing SPARQL queries against heterogeneous data sources, one often wants to select a value for a certain purpose without knowing which one of several predicates might be used in the data. The SPARQL OPTIONAL keyword can be used to accomplish this. Suppose we are selecting a human-readable label for a Web page, and we want to use the value of the Dublin Core title predicate (dc:title) if it exists, and otherwise use the value of the rdfs:label predicate. This can be accomplished with SPARQL idiom:

  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  PREFIX dc: <http://purl.org/dc/elements/1.1/>
  SELECT ?text
  WHERE {
    OPTIONAL { <http://example.org/myWebPage> dc:title ?text . }
    OPTIONAL { <http://example.org/myWebPage> rdfs:label ?text . }
  }

More information on this idiom is available in this blog post.

3.8. Can I use SPARQL to query RDFS entailments?

It is sometimes desirable to use SPARQL to query triples entailed from subclass, subproperty, range, domain, and other relations which can be represented using RDF Schema.

The SPARQL specification defines the results of queries based on RDF simple entailment. However, the specification does present a general, parametrized definition of graph pattern matching that can be expanded to other entailments beyond RDF simple entailment.

As an alternative, the SPARQL specification acknowledges that queries are often performed against a virtual graph which may not be fully materialized. Because RDFS entailment rules will always lead to a unique, deductive closure of a base graph, a query engine can treat the RDFS deductive closure of a base graph as the virtual graph against which (simple-entailment based) SPARQL queries are executed.

Whether or not a particular query endpoint supports RDFS entailment is implementation defined. Such a property might be advertised as part of the endpoint’s functional description.

For more information, see information on SPARQL extensions for other entailment regimes.

3.9. Can I use SPARQL to query OWL entailments?

For the most part, the answer to this question is the same as the above answer regarding RDFS entailment. However, OWL-DL axioms do not always result in a unique deductive closure, and as such querying OWL-DL entailments requires instantiating the parametrized SPARQL basic graph pattern definition with values appropriate for OWL-DL entailment. The open-source OWL-DL reasoner, Pellet, will answer SPARQL queries while considering OWL-DL entailments.

For more information, see information on SPARQL extensions for other entailment regimes.

3.10. What do blank nodes mean in a SPARQL query?

For the most part, blank nodes in SPARQL queries function exactly as variables which cannot be returned to the user/client. So, the following two queries behave identically:

  SELECT ?title WHERE { _:book :hasTitle ?title }
  SELECT ?title WHERE { ?book :hasTitle ?title }

However, a SPARQL query may not reuse the same blank node label twice in different basic graph patterns. That is, the following is not a legal SPARQL query:

  SELECT ?title WHERE {
    _:book rdfs:seeAlso ?g .
    GRAPH ?g { _:book dc:title ?title }
  }

In most cases, it is best practice to use the [] and [ :prop :o bj ] syntaxes for blank nodes and to only use explicit blank node labels for constructs that cannot be expresed otherwise.

3.12. Why don’t I get any matches when I search for numbers?

Numbers in RDF data can be represented as plain literals or as typed literals (using XML Schema datatypes such as xsd:int). Numbers written in a SPARQL query with surrounding quotation marks (e.g., "4") will only match plain literals in the dataset. Numbers written without quotation marks (e.g. 4) will only match typed literals. Be sure to use the appropriate form for the data you are querying.

If your data contains numbers as plain literals, then they will be compared as strings not numbers, and you may have to cast them to typed literals to get the desired results. For example, to check if a number expressed as a plain literal is less than 100, you’d say:

  ...
  FILTER (xsd:int(?number) < 100)
  ...

Many thanks to Richard Cyganiak for contributing this question and answer.

3.13. Can I use SPARQL to insert, update, or delete RDF data?

The current, standardized version of SPARQL deals only with retrieving selected data from RDF graphs. There is no equivalent of the SQL INSERT, UPDATE, or DELETE statements. Most RDF-based applications handle new, changing, and stale data directly via the APIs provided by specific RDF storage systems. Alternatively, RDF data can exist virtually (i.e. created on-demand in response to a SPARQL query). Also, there are systems which create RDF data from other forms of markup, such as Wiki markup or the Atom Syndication Format.

However, there is significant active work going on to extend SPARQL to support update operations. See the SPARQL extension wiki page dealing with update for more details.

May 12 2009

2. W3C and the Data Access (DAWG) and SPARQL Working Groups

2.1. What is the status of the W3C SPARQL specifications?

On January 15, 2008, the W3C published the three SPARQL specifications as Recommendations. This means that the specifications have been endorsed by the W3C membership and should be considered stable documents.

In February 2009, the W3C re-chartered the SPARQL Working Group (new name) to produce specifications for extensions to the SPARQL language, protocol, and landscape. This new Working Group has an 18-month timeframe.

2.2. Will there be a SPARQL 2? When will feature X be standardized?

The in-progress SPARQL Working Group is working on a new version of SPARQL. The group’s work can be followed on two public mailing lists:

May 11 2009

1. General SPARQL Discussion

1.1. What is SPARQL?

SPARQL is a recursive acronym standing for SPARQL Protocol and RDF Query Language. As the name implies, SPARQL is a general term for both a protocol and a query language.

Most uses of the SPARQL acronym refer to the RDF query language. In this usage, SPARQL is a syntactically-SQL-like language for querying RDF graphs via pattern matching. The language’s features include basic conjunctive patterns, value filters, optional patterns, and pattern disjunction.

The SPARQL protocol is a method for remote invocation of SPARQL queries. It specifies a simple interface that can be supported via HTTP or SOAP that a client can use to issue SPARQL queries against some endpoint.

Both the SPARQL query language and the SPARQL protocol are products of the W3C’s RDF Data Access Working Group. The latest released versions of the Working Group’s specifications (excluding intermediate working drafts) can be found here:

1.2. How can I learn SPARQL?

There are a variety of SPARQL tutorials and introductions scattered around the Web. Some notable ones include:

1.3. What are the benefits/drawbacks of SPARQL vis a vis SQL and XQuery?

The jury is still out on best practices surrounding using SPARQL compared to other query languages. Some benefits of SPARQL include:

  • Queries RDF data. If your data is in RDF, then SPARQL can query it natively.
  • Implicit join syntax. SPARQL queries RDF graphs, which consist of various triples expressing binary relations between resources, by specifying a subgraph with certain resources replaced by variables. Because all relationships are of a fixed size and data lives in a single graph, SPARQL does not require explicit joins that specify the relationship between differently structured data. That is, SPARQL is a query language for pattern matching against RDF graphs, and the queies themselves look and act like RDF. This is one main point made by Oracle’s Jim Melton in his analysis of SPARQL vis a vis SQL and XQuery: SQL, XQuery, and SPARQL: What’s Wrong With This Picture?.
  • SPARQL has strong support for querying semistructured and ragged data—i.e., data with an unpredictable and unreliable structure. Variables may occur in the predicate position to query unknown relationships, and the OPTIONAL keyword provides support for querying relationships that may or may not occur in the data (a la SQL left joins).
  • SPARQL is often an appropriate query language for querying disparate data sources (not sharing a single native representation) in a single query. Because RDF represents all data as a collection of simple binary relations, most data can be easily mapped to RDF and then queried and joined using SPARQL. Often, these mappings can be performed on the fly, meaning that SPARQL can be used to join heterogeneous data at a higher level than that of the native structure of the data.
  • SPARQL is built to support queries in a networked, web environment. SPARQL introduces the notion of an RDF dataset, which is the pairing of a default graph and zero or more named graphs. As both the default graph and the named graphs are identified by URIs, it is common for SPARQL implementations to retrieve a graph by performing an HTTP GET on the graph’s URI. This allows a single query to join information from multiple data sources accessible across different Web sites.
  • Similarly, the SPARQL GRAPH keyword allows data to be queried along with its provenance information. GRAPH can be used to discover the URI of the graph that contains the data that matches the query.

Some drawbacks are:

  • Lack of wide deployment. SPARQL is relatively young, and as such there are not many data stores which can be directly queried with SPARQL (as compared with SQL or XPath).
  • Immaturity. As a young query language, SPARQL lacks the explicit processing model of XQuery or the decades of SQL-optimization research. As with the above point, this is likely to improve as current and new research and implementations contribute to a body of knowledge surrounding SPARQL.
  • Lack of support for transitive/hierarchical queries. While SPARQL is designed to query RDF graphs, SPARQL has no facilities for easily querying transitive relations or hierarchical structures within a graph. There are some workarounds for this, but SPARQL does not approach the power of, for instance, XQuery’s axes.

1.4. What SPARQL implementations are available?

The community maintains a list of SPARQL implementations at the W3C ESW Wiki.

1.5. Can I use SPARQL to query data that’s not stored in RDF?

Several software packages exist which allow SPARQL queries to generate answers from data sources other than RDF, such as relational databases, LDAP servers, or XML data. The community maintains a list of these tools at the W3C ESW Wiki.

The W3C recently completed an incubator group examining the state of the art in accessing relational databases via SPARQL. As a result of this incubator group, a new Working Group may be established to produce specifications in this area.

1.6. How can I tell what dataset, functions, or extensions a SPARQL endpoint supports?

There is currently no established, interoperable method for representing or accessing functional descriptions of SPARQL endpoints. (This is not to be confused with the WSDL which describes the SPARQL Protocol itself.)

The Data Access Working Group postponed this topic in 2005, leaving behind a draft “of historical interest only.” In the meantime, implementations have devised their own vocabularies and techniques for specifying and advertising the services and datasets supported by a SPARQL endpoint. For example, HP Labs’ Joseki allows service descriptions to be specified with an RDF configuration vocabulary. See the SPARQL service description wiki page for more information.

1.7. Do SPARQL queries perform well against small datasets? Large datasets?

The performance of a SPARQL query against any particular dataset depends not only upon the size of the dataset but also on the nature of the dataset’s storage (a relational store, a native triple store, LDAP, etc.), the complexity of the query itself, optimizations in use by the SPARQL engine, the distribution of the data, and other environmental factors. To date, little work has been done in analyzing SPARQL query performance in particular, and the field of SPARQL query optimization is relatively inchoate.

Some analysis has been done on the topic of RDF stores which can handle large datasets. (A large dataset in this context is usually considered one on the order of tens or hundreds of millions of triples). The W3C ESW wiki contains information on a variety of RDF stores which can scale to large numbers of triples, but does not speak specifically to the performance of SPARQL queries against these stores.

1.8. Is there anywhere on the Web where I can try out SPARQL queries?

The creators of several SPARQL implementations provide online services where SPARQL queries can be input and executed against either canned datasets or arbitrary datasets (identified by URLs). The community maintains a list of SPARQL endpoints on the W3C ESW Wiki.

May 08 2009

[JENA] Tutorial – Controlling Prefixes

Tutorial 5 에 이어 Controlling Prefixes 설명 부분이다.

전에 정의한 네임스페이스를 전처리기 처럼 미리 정의하여 코드를 간략히 하는 예제이다.
Jena는 이러한 긴 URI들을 간략히 하여 표현하는 간단한 예제를 보여준다.

//모델 생성
Model m = ModelFactory.createDefaultModel();

//스트링형 URIs
String nsA = “http://hacks.wo.to/ju0e#”;
String nsB = “http://hackscd.goanygate.com/ju0e#”;

//리소스 생성
Resource root = m.createResource( nsA + “root” );

//프로퍼티 생성
Property P = m.createProperty( nsA + “P” );
Property Q = m.createProperty( nsB + “Q” );
Property x = m.createProperty( nsA + “x” );
Property y = m.createProperty( nsA + “y” );
Property z = m.createProperty( nsA + “z” );

//모델 등록
m.add( root, P, x )
.add( root, P, y )
.add( y, Q, z );

System.out.println( “# — no special prefixes defined” );
m.write( System.out );
System.out.println( “# — nsA defined” );

//네임스페이스 세팅
m.setNsPrefix( “nsA”, nsA );

m.write( System.out );
System.out.println( “# — nsA and cat defined” );

//네임스페이스 세팅
m.setNsPrefix( “cat”, nsB );

m.write( System.out );

결과는 코드에 비해 상당히 많은 내용들이 출력되어 진다.

# — no special prefixes defined
<rdf:RDF
xmlns:rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”
xmlns:j.0=”http://hackscd.goanygate.com/ju0e#”
xmlns:j.1=”http://hacks.wo.to/ju0e#” >
<rdf:Description rdf:about=”http://hacks.wo.to/ju0e#root“>
<j.1:P rdf:resource=”http://hacks.wo.to/ju0e#y”/>
<j.1:P rdf:resource=”http://hacks.wo.to/ju0e#x”/>
</rdf:Description>
<rdf:Description rdf:about=”http://hacks.wo.to/ju0e#y“>
<j.0:Q rdf:resource=”http://hacks.wo.to/ju0e#z”/>
</rdf:Description>
</rdf:RDF>

# — nsA defined
<rdf:RDF
xmlns:rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”
xmlns:j.0=”http://hackscd.goanygate.com/ju0e#”
xmlns:nsA=”http://hacks.wo.to/ju0e#” >
<rdf:Description rdf:about=”http://hacks.wo.to/ju0e#root“>
<nsA:P rdf:resource=”http://hacks.wo.to/ju0e#y”/>
<nsA:P rdf:resource=”http://hacks.wo.to/ju0e#x”/>
</rdf:Description>
<rdf:Description rdf:about=”http://hacks.wo.to/ju0e#y“>
<j.0:Q rdf:resource=”http://hacks.wo.to/ju0e#z”/>
</rdf:Description>
</rdf:RDF>

# — nsA and cat defined
<rdf:RDF
xmlns:rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”
xmlns:cat=”http://hackscd.goanygate.com/ju0e#”
xmlns:nsA=”http://hacks.wo.to/ju0e#” >
<rdf:Description rdf:about=”http://hacks.wo.to/ju0e#root“>
<nsA:P rdf:resource=”http://hacks.wo.to/ju0e#y”/>
<nsA:P rdf:resource=”http://hacks.wo.to/ju0e#x”/>
</rdf:Description>
<rdf:Description rdf:about=”http://hacks.wo.to/ju0e#y“>
<cat:Q rdf:resource=”http://hacks.wo.to/ju0e#z”/>
</rdf:Description>
</rdf:RDF>

May 07 2009

[JENA] Tutorial05

Reading RDF

Tutorial 5 는 모델로부터 RDF에 있는 내용을 읽는법을 설명한다.
이미 만들어져 있는 RDF파일을 InputStream형태의 객체로 읽어 화면에 출력해주는 간단한 내용이다.

파일메니저를 이용하여 RDF파일을 읽는다.
InputStream in = FileManager.get().open(inputFileName);

만약 파일이 없다면 IllegalArgumentException오류를 발생하도록 한다.
if(in == null) {
throw new IllegalArgumentException(” RDF File not found”);
}

RDF/XML파일을 읽는 메소드로 RDF 내용을 읽어온다.
model.read(in, “”);

Tutorial04에서 표준으로 화면에 쓰는 메소드를 사용하여 읽어온 내용을 확인한다.
model.write(System.out);

[ SOURCE : vc-db-1.rdf ]

<rdf:RDF
xmlns:rdf=’http://www.w3.org/1999/02/22-rdf-syntax-ns#’
xmlns:vCard=’http://www.w3.org/2001/vcard-rdf/3.0#’
>

<rdf:Description rdf:about=”http://hacks.wo.to/ju0e/“>
<vCard:FN>Ju-young Noh</vCard:FN>
<vCard:N rdf:parseType=”Resource”>
<vCard:Family>Noh</vCard:Family>
<vCard:Given>Ju-young</vCard:Given>
</vCard:N>
</rdf:Description>

<rdf:Description rdf:about=”http://hacks.wo.to/phd/“>
<vCard:FN>Hae-dong Park</vCard:FN>
<vCard:N rdf:parseType=”Resource”>
<vCard:Family>Park</vCard:Family>
<vCard:Given>Hae-dong</vCard:Given>
</vCard:N>
</rdf:Description>

<rdf:Description rdf:about=”http://hacks.wo.to/hjy/“>
<vCard:FN>Jong-hyun</vCard:FN>
<vCard:N rdf:parseType=”Resource”>
<vCard:Family>Ha</vCard:Family>
<vCard:Given>Jong-hyun</vCard:Given>
</vCard:N>
</rdf:Description>

<rdf:Description rdf:about=”http://hacks.wo.to/kjw/“>
<vCard:FN>Jun-wook Kang</vCard:FN>
<vCard:N
vCard:Family=”Kang”
vCard:Given=”Jun-wook”/>
</rdf:Description>

</rdf:RDF>

[ SOURCE : Tutorial05.java ]

import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.util.*;

import java.io.*;

public class Test extends Object
{
static final String inputFileName = “data/vc-db-1.rdf”;

public static void main(String args[])
{
Model model = ModelFactory.createDefaultModel();

InputStream in = FileManager.get().open(inputFileName);
if(in == null)
{
throw new IllegalArgumentException(” File : ” + inputFileName + ” not found”);
}

model.read(in, “”);
model.write(System.out);
}
}

[ EXECUTE ]

<rdf:RDF
xmlns:rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”
xmlns:vCard=”http://www.w3.org/2001/vcard-rdf/3.0#” >
<rdf:Description rdf:about=”http://hacks.wo.to/hjy/“>
<vCard:N rdf:nodeID=”A0″/>
<vCard:FN>Jong-hyun</vCard:FN>
</rdf:Description>
<rdf:Description rdf:about=”http://hacks.wo.to/phd/“>
<vCard:N rdf:nodeID=”A1″/>
<vCard:FN>Hae-dong Park</vCard:FN>
</rdf:Description>
<rdf:Description rdf:about=”http://hacks.wo.to/kjw/“>
<vCard:N rdf:nodeID=”A2″/>
<vCard:FN>Jun-wook Kang</vCard:FN>
</rdf:Description>
<rdf:Description rdf:nodeID=”A3″>
<vCard:Given>Ju-young</vCard:Given>
<vCard:Family>Noh</vCard:Family>
</rdf:Description>
<rdf:Description rdf:about=”http://hacks.wo.to/ju0e/“>
<vCard:N rdf:nodeID=”A3″/>
<vCard:FN>Ju-young Noh</vCard:FN>
</rdf:Description>
<rdf:Description rdf:nodeID=”A2″>
<vCard:Given>Jun-wook</vCard:Given>
<vCard:Family>Kang</vCard:Family>
</rdf:Description>
<rdf:Description rdf:nodeID=”A1″>
<vCard:Given>Hae-dong</vCard:Given>
<vCard:Family>Park</vCard:Family>
</rdf:Description>
<rdf:Description rdf:nodeID=”A0″>
<vCard:Given>Jong-hyun</vCard:Given>
<vCard:Family>Ha</vCard:Family>
</rdf:Description>
</rdf:RDF>

May 06 2009

[JENA] Tutorial04

Writing RDF

Jena에서는 RDF로 쓰고 읽는 것을 XML형태로 볼 수 있다.
XML형태로 출력되는 것을 확인해보자.
구분은 아래와 같이 간단하다.

model.write(System.out)’;

Tutorial03에서 N-Triples 형태로 보기위해 get 함수를 이용하였다.
Jena에 기록되는 내용을 XML로 화면에 출력하고 모델에 기록하는 코드이다.

import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.vocabulary.*;

public class Test extends Object
{
static String personURI  = “http://hacks.wo.to/ju0e“;
static String hacksName  = “Ju-young Noh”;
static String hacksEmail1 = “hacks@korea.com“;
static String hacksEmail2 = “hacks@hacks.wo.to“;
static String title   = “An Introduction to RDF and the Jena API”;
static String date   = “13/8/2006″;

public static void main(String args[])
{
String personURI = “http://hacks.wo.to/ju0e“;
String givenName = “Ju-young”;
String familyName = “Noh”;
String fullName  = givenName + ” ” + familyName;

Model model = ModelFactory.createDefaultModel();

Resource ju0e
= model.createResource(personURI)
.addProperty(VCARD.FN, fullName)
.addProperty(VCARD.N,
model.createResource()
.addProperty(VCARD.Given, givenName)
.addProperty(VCARD.Family, familyName));

model.write(System.out);
}
}

model.write(System.out); 구분에 RDF/XML-ABREV 나 N-TRIPLE을 사용하면 XML형태를 다르게도 표현할 수 있다.

위 코드의 결과는 기본값으로 출력물이 길고 복잡하다.

<rdf:RDF
xmlns:rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”
xmlns:vcard=”http://www.w3.org/2001/vcard-rdf/3.0#” >
<rdf:Description rdf:about=”http://hacks.wo.to/ju0e“>
<vcard:N rdf:nodeID=”A0″/>
<vcard:FN>Ju-young Noh</vcard:FN>
</rdf:Description>
<rdf:Description rdf:nodeID=”A0″>
<vcard:Family>Noh</vcard:Family>
<vcard:Given>Ju-young</vcard:Given>
</rdf:Description>
</rdf:RDF>

만약 model.write(System.out, “RDF/XML-ABBREV”); 를 사용하게 된다면 심플한 형태로 축약되어 결과를 볼 수 있다.

<rdf:RDF
xmlns:rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”
xmlns:vcard=”http://www.w3.org/2001/vcard-rdf/3.0#”>
<rdf:Description rdf:about=”http://hacks.wo.to/ju0e“>
<vcard:N rdf:parseType=”Resource”>
<vcard:Family>Noh</vcard:Family>
<vcard:Given>Ju-young</vcard:Given>
</vcard:N>
<vcard:FN>Ju-young Noh</vcard:FN>
</rdf:Description>
</rdf:RDF>

model.write(System.out, “N-TRIPLE”); 을 사용하게 되면 결과를 N-TRIPLE 형태로 볼 수 있다.

_:A302520d0X3aX10d06c16345X3aXX2dX8000 <http://www.w3.org/2001/vcard-rdf/3.0#Family> “Noh” .
_:A302520d0X3aX10d06c16345X3aXX2dX8000 <http://www.w3.org/2001/vcard-rdf/3.0#Given> “Ju-young” .
<http://hacks.wo.to/ju0e> <http://www.w3.org/2001/vcard-rdf/3.0#N> _:A302520d0X3aX10d06c16345X3aXX2dX8000 .
<http://hacks.wo.to/ju0e> <http://www.w3.org/2001/vcard-rdf/3.0#FN> “Ju-young Noh” .

N-TRIPLE 형태로 보게 될  때 결과에서 알수 없는 부분이 출력되는 것은 Jena에서 임의로 노드를 지정한 것이다.

May 05 2009

[JENA] Tutorial03

Resource, Property, Value(Resource)를 구현한 내용을 N-Triples 형태로 보도록 하자.
Tutorial02 소스에 출력부분을 추가하면 된다.

// list the statements in the Model
StmtIterator iter = model.listStatements();

// print out the predicate, subject and object of each statement
while(iter.hasNext()) {
Statement stmt  = iter.nextStatement();      // get next statement
Resource subject = stmt.getSubject();       // get the subject
Property predicate = stmt.getPredicate();   // get the predicate
RDFNode object  = stmt.getObject();         // get the object
System.out.println();
System.out.println(”ⓡ ” + subject.toString());
System.out.println(”ⓟ ” + predicate.toString());
if(object instanceof Resource) {
System.out.println(”ⓥ ” + object.toString());
} else {
System.out.println(”ⓡ ” + “”" + object.toString() + “”");
}
}

get을 이용하여 해당 위치의 값을 가져와서 화면에 출력해주는 내용이다.
출력되는 화면은 N-Triples 형태로 출력된다.

본래의 소스에서 출력형태를 보기 쉽도록 약간 수정하였다.
ⓡ은 Resource, ⓟ는 Property, ⓥ는 Value를 의미한다.
Value위치의 값이 Value가 될 경우 “”안에 표기되어 출력된다.
총 4개의 N-Triples로 구성된 것을 알 수 있다.

다시 말하면 기본 R-P-V 형태이지만 R-P-R형태로 자원이 자원을 가리킬 수 있도록 의미를 부여한다.
알아볼 수 없는 문자들은 Namespace가 지정돼지 않았기 때문에 Jena에서 임의적으로 부여한 것이다.

import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.vocabulary.*;

public class Test extends Object
{
static String personURI = “http://hacks.wo.to/ju0e”;
static String givenName = “Ju-young”;
static String familyName = “Noh”;
static String fullName = givenName + ” ” + familyName;
public static void main(String args[]) {
Model model = ModelFactory.createDefaultModel();
Resource ju0e = model.createResource(personURI)
.addProperty(VCARD.FN, fullName)
.addProperty(VCARD.N,
model.createResource()
.addProperty(VCARD.Given, givenName)
.addProperty(VCARD.Family, familyName));
StmtIterator iter = model.listStatements();
while(iter.hasNext()) {
Statement stmt = iter.nextStatement();
Resource subject = stmt.getSubject();
Property predicate = stmt.getPredicate();
RDFNode object = stmt.getObject();
System.out.println();
System.out.println(”ⓡ ” + subject.toString());
System.out.println(”ⓟ ” + predicate.toString());
if(object instanceof Resource) {
System.out.println(”ⓡ ” + object.toString());
} else {
System.out.println(”ⓥ ” + “”" + object.toString() + “”");
}
}
}
}

WordPress Themes