tasks/jsonld/js/jsonld.js
function _createInverseContext() {
    var activeCtx = this;

    // lazily create inverse
    if(activeCtx.inverse) {
      return activeCtx.inverse;
    }
    var inverse = activeCtx.inverse = {};

    // handle default language
    var defaultLanguage = activeCtx['@language'] || '@none';

    // create term selections for each mapping in the context, ordered by
    // shortest and then lexicographically least
    var mappings = activeCtx.mappings;
    var terms = Object.keys(mappings).sort(_compareShortestLeast);
    for(var i = 0; i < terms.length; ++i) {
      var term = terms[i];
      var mapping = mappings[term];
      if(mapping === null) {
        continue;
      }

      var container = mapping['@container'] || '@none';

      // iterate over every IRI in the mapping
      var ids = mapping['@id'];
      if(!_isArray(ids)) {
        ids = [ids];
      }
      for(var ii = 0; ii < ids.length; ++ii) {
        var iri = ids[ii];
        var entry = inverse[iri];

        // initialize entry
        if(!entry) {
          inverse[iri] = entry = {};
        }

        // add new entry
        if(!entry[container]) {
          entry[container] = {
            '@language': {},
            '@type': {}
          };
        }
        entry = entry[container];

        // term is preferred for values using @reverse
        if(mapping.reverse) {
          _addPreferredTerm(mapping, term, entry['@type'], '@reverse');
        }
        // term is preferred for values using specific type
        else if('@type' in mapping) {
          _addPreferredTerm(mapping, term, entry['@type'], mapping['@type']);
        }
        // term is preferred for values using specific language
        else if('@language' in mapping) {
          var language = mapping['@language'] || '@null';
          _addPreferredTerm(mapping, term, entry['@language'], language);
        }
        // term is preferred for values w/default language or no type and
        // no language
        else {
          // add an entry for the default language
          _addPreferredTerm(mapping, term, entry['@language'], defaultLanguage);

          // add entries for no type and no language
          _addPreferredTerm(mapping, term, entry['@type'], '@none');
          _addPreferredTerm(mapping, term, entry['@language'], '@none');
        }
      }
    }

    return inverse;
  }
function _createInverseContext() {
    var activeCtx = this;

    // lazily create inverse
    if(activeCtx.inverse) {
      return activeCtx.inverse;
    }
    var inverse = activeCtx.inverse = {};

    // handle default language
    var defaultLanguage = activeCtx['@language'] || '@none';

    // create term selections for each mapping in the context, ordered by
    // shortest and then lexicographically least
    var mappings = activeCtx.mappings;
    var terms = Object.keys(mappings).sort(_compareShortestLeast);
    for(var i = 0; i < terms.length; ++i) {
      var term = terms[i];
      var mapping = mappings[term];
      if(mapping === null) {
        continue;
      }

      var container = mapping['@container'] || '@none';

      // iterate over every IRI in the mapping
      var ids = mapping['@id'];
      if(!_isArray(ids)) {
        ids = [ids];
      }
      for(var ii = 0; ii < ids.length; ++ii) {
        var iri = ids[ii];
        var entry = inverse[iri];

        // initialize entry
        if(!entry) {
          inverse[iri] = entry = {};
        }

        // add new entry
        if(!entry[container]) {
          entry[container] = {
            '@language': {},
            '@type': {}
          };
        }
        entry = entry[container];

        // term is preferred for values using @reverse
        if(mapping.reverse) {
          _addPreferredTerm(mapping, term, entry['@type'], '@reverse');
        }
        // term is preferred for values using specific type
        else if('@type' in mapping) {
          _addPreferredTerm(mapping, term, entry['@type'], mapping['@type']);
        }
        // term is preferred for values using specific language
        else if('@language' in mapping) {
          var language = mapping['@language'] || '@null';
          _addPreferredTerm(mapping, term, entry['@language'], language);
        }
        // term is preferred for values w/default language or no type and
        // no language
        else {
          // add an entry for the default language
          _addPreferredTerm(mapping, term, entry['@language'], defaultLanguage);

          // add entries for no type and no language
          _addPreferredTerm(mapping, term, entry['@type'], '@none');
          _addPreferredTerm(mapping, term, entry['@language'], '@none');
        }
      }
    }

    return inverse;
  }
function _createInverseContext ( ) { var activeCtx = this ; // lazily create inverse if ( activeCtx . inverse ) { return activeCtx . inverse ; } var inverse = activeCtx . inverse = { } ; // handle default language var defaultLanguage = activeCtx [ '@language' ] || '@none' ; // create term selections for each mapping in the context, ordered by // shortest and then lexicographically least var mappings = activeCtx . mappings ; var terms = Object . keys ( mappings ) . sort ( _compareShortestLeast ) ; for ( var i = 0 ; i < terms . length ; ++ i ) { var term = terms [ i ] ; var mapping = mappings [ term ] ; if ( mapping === null ) { continue ; } var container = mapping [ '@container' ] || '@none' ; // iterate over every IRI in the mapping var ids = mapping [ '@id' ] ; if ( ! _isArray ( ids ) ) { ids = [ ids ] ; } for ( var ii = 0 ; ii < ids . length ; ++ ii ) { var iri = ids [ ii ] ; var entry = inverse [ iri ] ; // initialize entry if ( ! entry ) { inverse [ iri ] = entry = { } ; } // add new entry if ( ! entry [ container ] ) { entry [ container ] = { '@language' : { } , '@type' : { } } ; } entry = entry [ container ] ; // term is preferred for values using @reverse if ( mapping . reverse ) { _addPreferredTerm ( mapping , term , entry [ '@type' ] , '@reverse' ) ; } // term is preferred for values using specific type else if ( '@type' in mapping ) { _addPreferredTerm ( mapping , term , entry [ '@type' ] , mapping [ '@type' ] ) ; } // term is preferred for values using specific language else if ( '@language' in mapping ) { var language = mapping [ '@language' ] || '@null' ; _addPreferredTerm ( mapping , term , entry [ '@language' ] , language ) ; } // term is preferred for values w/default language or no type and // no language else { // add an entry for the default language _addPreferredTerm ( mapping , term , entry [ '@language' ] , defaultLanguage ) ; // add entries for no type and no language _addPreferredTerm ( mapping , term , entry [ '@type' ] , '@none' ) ; _addPreferredTerm ( mapping , term , entry [ '@language' ] , '@none' ) ; } } } return inverse ; }
Generates an inverse context for use in the compaction algorithm, if
not already generated for the given active context.

@return the inverse context.
Generates an inverse context for use in the compaction algorithm if not already generated for the given active context .