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);
  }