-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Note: Currently, officially we only support Chrome.
Assuming that your application wants to use the BigSemantics Web Service to extract semantic information:
var bs = new BSService();
bs.onReady(function(err, bs) {
if (err) {
console.warn("Cannot initialize BigSemantics: %O", err);
return;
}
var url = "http://www.amazon.com/gp/product/B00I8BIBCW/";
var options = {};
bs.loadMetadata(url, options, function(err, result) {
if (err) {
console.warn("Failed to load metadata: %O", err);
return;
}
var metadata = result.metadata;
var mmd = result.mmd;
console.log("Metadata received: %O", metadata);
console.log("Accompanying meta-metadata: %O", mmd);
});
});
Clients interact with different implementations of the IBigSemantics
interface to use the core functionalities of BigSemantics, including metadata extraction and meta-metadata lookup. There are different implementations of the IBigSemantics
interface for different use cases.
The IBigSemantics
interface contains the following methods:
Returns a boolean value indicating if the implementation has done initialization (including repository loading) and is ready for use.
Calls callback
when the implementation is ready for use. Parameters of callback
:
-
err
: Error object if error happens during initialization. Otherwisenull
. -
bigsemantics
: TheIBigSemantics
implementation ready for use. If error happened during initialization,null
.
Loads semantics information (or ''metadata'') from document indicated by location
, and calls callback
with results. Parameters:
-
location
: The URL of the target document. -
options
: An object containing additional options. Currently supported options:-
mmd
: An prepared meta-metadata object which will be used for extraction. This skips the normal meta-metadata lookup process. -
mmdName
: A meta-metadata name. The meta-metadata object with this name will be looked up in the repository, and used for extraction. This skips the normal meta-metadata lookup process.
-
-
callback
: Callback function to receive results. Parameters:-
err
: Error object.null
if no errors happened. -
result
: An object containing both metadata and corresponding meta-metadata, in two fieldsmetadata
andmmd
respectively.null
if errors happened.
-
Loads meta-metadata with specified name
from repository, and calls callback
with result. Parameters:
-
name
: The name of the meta-metadata type. -
options
: An object containing additional options. No specific options supported right now. -
callback
: Callback function to receive results. Parameters:-
err
: Error object.null
if no errors happened. -
mmd
: The result meta-metadata.null
if errors happened.
-
Looks up meta-metadata for specified location
using the selector mechanism, and calls callback
with result. Note that if there isn't a meta-metadata specifically authored for the target document, a generic meta-metadata (usually rich_document
) will be used. Parameters:
-
location
: The URL of the target document. -
options
: An object containing additional options. No specific options supported right now. -
callback
: Callback function to receive results. Parameters:-
err
: Error object.null
if no errors happened. -
mmd
: The result meta-metadata.null
if errors happened.
-
Reports the ''canonical'' form of the specified location
using the location filter mechanism, through callback
. The canonical form aims to provide a unique identifier for a document by removing session tracking parameters, anchors, and other parts from the original URL.
Note: by default, this method does not actually connect to the target document, thus does not handle redirections. The result is supposed to be an initial guess, usually used for hinting the type of many outlinks.
Parameters:
-
location
: The URL to be canonicalized -
options
: An object containing additional options. No specific options supported right now. -
callback
: Callback function to receive results. Parameters:-
err
: Error object.null
if no errors happened. -
canonicalLocation
: The result canonical location.null
if errors happened.
-