The SWS Library contains the core functionality for developing agents that use Semantic Web Search to locate information on the Semantic Web. The SWS Library makes it easy for you, as an agent developer, to querying our service to find important information and quickly process it with very few lines of code. The SWS Library is a RDF Gateway library package that can only be used by agents running on RDF Gateway. The SWS Library can be downloaded and installed from this site (click here).
The SWS Library provides RDF Gateway agent developers with a simple object model for accessing the features of Semantic Web Search. The table below provides an overview of the objects in the SWS Library. To use any of these objects in your scripts you must import the file /sws/webapi.rql .
| Object | Description |
| SWSQuery | This object is used to query our service for documents and resource description we've indexed on the Semantic Web. |
| SWSDocument | Zero or more SWSDocument objects are returned as the result of querying our service. A SWSDocument object can also be used to submit a URL to our service so it can be added to our Semantic Web Index. |
The SWSQuery object is used to query our service for documents on the Internet that contain the information specified in the query. This object allows you define all of the parameters for the query, execute it, and iterate over the resulting documents (see SWSDocument). Results are returned from our service one page at a time (see pageSize property). This object encapsulates the logic for fetching query results that are contained in multiple pages.
| Contructors | |
| SWSQuery( condition ) | |
|
|
| Properties | |
| condition | |
This string property specifies the condition for the query. This property
must be set to valid query condition.
|
|
| document | |
This property specifies the URL of document document to be queried. If this value is null
then all documents are searched. By default this property is null.
|
|
| domain | |
This property specifies the domain that a document must be located in. This value can be
a single string or an array of strings to specify multiple domains. If this value is null
then all domains are searched. By default this property is null.
|
|
| format | |
This property specifies the content format of documents to be included in the query. It is specified using
one of the following predefined values.
If this value is null then all formats are searched. By default this property is null.
|
|
| minDate | |
Only documents modified after this date property are included in the search. If this property is
set to null it will not effect the search;
|
|
| maxDate | |
Only documents modified before this date property are included in the search. If this property is
set to null it will not effect the search;
|
|
| pageSize | |
| This property specifies the maximum number of documents that are returned in a single web service request. If the number of documents that are matched in a query exceeds the page size then the query results are split into multiple pages. Only a single page of results are returned from Semantic Web Search at a time so that each page must be individually fetched to obtain the all of the query results. If this property value is null then the default page size of 10 is used. | |
| subject | |
This property must be set to a non-null value if you want the concise bounded description for the resources matched
by the query to be returned in the resulting documents (see SWSDocument.descriptions).
The value of this property can be set to either the URI of resource or a name of a variable used in the query condition.
If a URI is specified then only the description of that resource is returned with each document. If a variable name is
specified then the descriptions of all of the resources matching the URI of bound value of the variable are returned
with each document.
|
|
| Methods | |
| current ( ) | |
| Returns the current SWSDocument object from the current page of query results. If there are no more documents in the current page this method will return null. | |
| first ( ) | |
| Returns the first SWSDocument object from the current page of query results. If there are no documents in the current page this method will return null. | |
| next ( [auto_page] ) | |
Returns the next SWSDocument object from the query results. If there
are no more are documents in the query results this method will return null.
|
|
| run ( ) | |
| Executes the query using Semantic Web Search and returns true if there are results. | |
In this example we implement an agent that uses Semantic Web Search to gather all the RDF schemas at the W3C site.
To implement this we use the SWSQuery object to execute a Semantic Web Search query for documents that are located in
the domain www.w3.org and contain resources of type rdf:Class. We set the subject
property to the variable
"?s" that is used in the query condition. When the query is executed this variable is bound to the URI of each RDF Class found.
The returned SWSDocument objects will contain concise bounded descriptions for each RDF Class in the document.
All of resource descriptions are inserted into a database table.
The agent reports on all of the RDF classes it found by selecting the URI and name of
each RDF class that are in its database table.
A SWSDocument object is returned as the result of a Semantic Web Search query that is performed using the SWSQuery object. Its properties include the URL and format of the document that can be used to download and parse the document contents from the Web. The SWSDocument object can be used to submit a URL of a RDF document to be added to the Semantic Web Search index.
| Contructors | |
| SWSDocument( url ) | |
|
|
| Properties | |
| bytes | |
| The count of bytes in the document. (read-only) | |
| descriptions | |
An array of RDFNode objects each containing a concise bounded description for a resource in the document that
was matched by the query. This property is set to null is no descriptions were returned by the query. Descriptions
are only returned if the subject property is set on the SWSQuery object. (read-only)
|
|
| rank | |
| The numeric Semantic Web Search Relevancy Ranking of the document. The higher the number the more references there are on the Semantic Web to the document. | |
| scanDate | |
| The date the document was last indexed. (read-only) | |
| triples | |
| The count of RDF triples in the document. (read-only) | |
| url | |
| This string property specifies the URL of the document. This property must be set to valid URL. | |
| Methods | |
| submit ( ) | |
| Submits the URL of the document to Semantic Web Search be added to the index. | |
In this example we implement a simple agent that uses the SWSDocument object to submit the URL of RSS document to Semantic Web Search so that it will indexed.