public function normalize($input, $options) {
    global $jsonld_default_load_document;
    self::setdefaults($options, array(
      'base' => is_string($input) ? $input : '',
      'documentLoader' => $jsonld_default_load_document));

    if(isset($options['inputFormat'])) {
      if($options['inputFormat'] != 'application/nquads') {
         throw new JsonLdException(
           'Unknown normalization input format.', 'jsonld.NormalizeError');
      }
      $dataset = $this->parseNQuads($input);
    } else {
      try {
        // convert to RDF dataset then do normalization
        $opts = $options;
        if(isset($opts['format'])) {
          unset($opts['format']);
        }
        $opts['produceGeneralizedRdf'] = false;
        $dataset = $this->toRDF($input, $opts);
      } catch(Exception $e) {
        throw new JsonLdException(
          'Could not convert input to RDF dataset before normalization.',
          'jsonld.NormalizeError', null, null, $e);
      }
    }

    // do normalization
    return $this->_normalize($dataset, $options);
  }
public function normalize($input, $options) {
    global $jsonld_default_load_document;
    self::setdefaults($options, array(
      'base' => is_string($input) ? $input : '',
      'documentLoader' => $jsonld_default_load_document));

    if(isset($options['inputFormat'])) {
      if($options['inputFormat'] != 'application/nquads') {
         throw new JsonLdException(
           'Unknown normalization input format.', 'jsonld.NormalizeError');
      }
      $dataset = $this->parseNQuads($input);
    } else {
      try {
        // convert to RDF dataset then do normalization
        $opts = $options;
        if(isset($opts['format'])) {
          unset($opts['format']);
        }
        $opts['produceGeneralizedRdf'] = false;
        $dataset = $this->toRDF($input, $opts);
      } catch(Exception $e) {
        throw new JsonLdException(
          'Could not convert input to RDF dataset before normalization.',
          'jsonld.NormalizeError', null, null, $e);
      }
    }

    // do normalization
    return $this->_normalize($dataset, $options);
  }
public function normalize ( $ input , $ options ) { global $ jsonld_default_load_document ; self :: setdefaults ( $ options , array ( 'base' => is_string ( $ input ) ? $ input : '' , 'documentLoader' => $ jsonld_default_load_document ) ) ; if ( isset ( $ options [ 'inputFormat' ] ) ) { if ( $ options [ 'inputFormat' ] != 'application/nquads' ) { throw new JsonLdException ( 'Unknown normalization input format.' , 'jsonld.NormalizeError' ) ; } $ dataset = $ this -> parseNQuads ( $ input ) ; } else { try { // convert to RDF dataset then do normalization $ opts = $ options ; if ( isset ( $ opts [ 'format' ] ) ) { unset ( $ opts [ 'format' ] ) ; } $ opts [ 'produceGeneralizedRdf' ] = false ; $ dataset = $ this -> toRDF ( $ input , $ opts ) ; } catch ( Exception $ e ) { throw new JsonLdException ( 'Could not convert input to RDF dataset before normalization.' , 'jsonld.NormalizeError' , null , null , $ e ) ; } } // do normalization return $ this -> _normalize ( $ dataset , $ options ) ; }
Performs JSON-LD normalization.

@param mixed $input the JSON-LD object to normalize.
@param assoc $options the options to use:
[base] the base IRI to use.
[expandContext] a context to expand with.
[inputFormat] the format if input is not JSON-LD:
'application/nquads' for N-Quads.
[format] the format if output is a string:
'application/nquads' for N-Quads.
[documentLoader(url)] the document loader.

@return mixed the normalized output.
Performs JSON - LD normalization .