Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Overview

Some of the pipeline processing elements enable you to use javascript to obtain metadata, create entities/associations, and perform various other operations.

For example, the following list of elements can make use of javascript:

  • docMetadata
  • contentMetadata
  • text extraction
  • criteria
  • Follow Web Links/split

For the most part, examples involving javascript are described on the individual pages that define and describe these elements.

This page serves to set out some general guidelines and best practices for using javascript.

It is a best practice to always code in the JS editor, as opposed to using the JSON editor.

About The Javascript Framework

The Infinit.e platform supports scripting the transformation of source data using JavaScript via Rhino, Mozilla's open-source JavaScript implementation (http://www.mozilla.org/rhino/).

Note that unless turned off from the configuration files (via the "harvest.security" property), Javascript is prevented by the Java security manager from doing the following:

  • "Internal" network access (ie to addresses 127.*.*.*, 10.*.*.* or 192.168.*.*)
  • File access.

Importing

The Infinit.e Structured Analysis Harvester supports importing of JavaScript functions in two ways currently:

  • specifying a javascript code block
  • a lit or urls of javascript locations that can be imported.

 

JavaScript functions imported via either of the two means described above are passed to the Rhino script engine via the ScriptEngine.eval method which allows the functions to be called within the scope of the current document being harvested.

Javascript Use Cases

In general terms, the use of javascript for IKANOWs falls into several major categories

  • obtaining metadata
  • creating entities and associations
  • using javascript for criteria, and other miscellaneous scenarios

Obtaining Metadata

When data is ingested into IKANOWs it is converted into documents.  The various elements of the processing pipeline can then act on these documents to get metadata.  Metadata objects can then be made available to functions and inline scripts.

You can get configure how you will get the metadata out of the text or metadata by setting script flags.  For example, you can receive the metadata as _doc, _metadata, or as full text.

Also, when iterating over a JSON array each item in the array is passed into the ScriptEngine and is made accessible via an object named: _iterator.

Examples:

_doc.metadata

"city": "$SCRIPT( return _doc.metadata.location[0].citystateprovince.city; )",

_metadata

 "contentMetadata": [                {
                    "fieldName": "email_meta",
                    "script": "var x=_metadata._FILE_METADATA_[0].metadata;x;",
                    "scriptlang": "javascript",
                    "flags": "m"

iterator

var make = _iterator.make;
var model = _iterator.model;
var year = _iterator.year;

 

For more information about using javascript to get metadata and for detailed examples and descriptions, see Content metadata, Manual text transformation.

Creating Entities and Associations

You can use javascript to create entities and associations by calling the metadata using the $SCRIPT and $FUNC scripting conventions.

For more information about using javascript to create entities and associations, see Manual entities, Manual association of entities.

Criteria

IN PROGRESS

 

 

  • No labels