How to use the n3.Util.getLiteralLanguage function in n3

To help you get started, we’ve selected a few n3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LinkedDataFragments / Client.js / lib / util / SparqlExpressionEvaluator.js View on Github external
'lang': function (a)    {
    return '"' + N3Util.getLiteralLanguage(a).toLowerCase() + '"';
  },
  'langmatches': function (langTag, langRange) {
github Callidon / sparql-engine / src / rdf / rdf-model.ts View on Github external
export function parseTerm (term: string): Term {
  if (term.startsWith('?')) {
    return Variable.allocate(term)
  } else if (term.startsWith('\"')) {
    const value = Util.getLiteralValue(term)
    const lang = Util.getLiteralLanguage(term)
    const type = cleanIRI(Util.getLiteralType(term))
    return parseLiteral(value, type, lang)
  } else if (term.startsWith('<') || term.startsWith('http') || Util.isIRI(term)) {
    return new IRI(term)
  }
  throw new SyntaxError(`Unkown RDF Term found during parsing: ${term}`)
}
github LinkedDataFragments / Server.js / lib / writers / JsonLdWriter.js View on Github external
function createTriple(subject, predicate, object) {
  return {
    subject:   { value: subject,   type: subject[0]   !== '_' ? 'IRI' : 'blank node' },
    predicate: { value: predicate, type: predicate[0] !== '_' ? 'IRI' : 'blank node' },
    object: !N3Util.isLiteral(object) ?
               { value: object,    type: object[0]    !== '_' ? 'IRI' : 'blank node' } :
               { value:    N3Util.getLiteralValue(object),
                 datatype: N3Util.getLiteralType(object),
                 language: N3Util.getLiteralLanguage(object) },
  };
}
github Callidon / sparql-engine / src / utils / SparqlExpressionEvaluator.js View on Github external
'lang': function (a) {
    return '"' + N3Util.getLiteralLanguage(a).toLowerCase() + '"'
  },
  'langmatches': function (langTag, langRange) {
github Callidon / sparql-engine / src / utils.js View on Github external
function parseTerm (term) {
  let parsed = null
  if (n3utils.isIRI(term)) {
    parsed = terms.IRIDescriptor(term)
  } else if (n3utils.isLiteral(term)) {
    const value = n3utils.getLiteralValue(term)
    const lang = n3utils.getLiteralLanguage(term)
    const type = stripDatatype(n3utils.getLiteralType(term))
    if (lang !== null && lang !== undefined && lang !== '') {
      parsed = terms.LangLiteralDescriptor(value, lang)
    } else if (term.indexOf('^^') > -1) {
      parsed = terms.TypedLiteralDescriptor(value, type)
    } else {
      parsed = terms.RawLiteralDescriptor(value)
    }
  } else {
    throw new Error(`Unknown RDF Term encoutered during parsing: ${term}`)
  }
  return parsed
}
github LinkedDataFragments / Server.js / lib / JsonLdFragmentWriter.js View on Github external
return { '@default': triples.map(function (triple) {
          var subject = triple.subject, predicate = triple.predicate, object = triple.object;
          return {
            subject:   { value: subject,   type: getTypeName(object) },
            predicate: { value: predicate, type: getTypeName(object) },
            object:    !N3Util.isLiteral(object) ? { value: object, type: getTypeName(object) }
                                                 : { value: N3Util.getLiteralValue(object),
                                                     datatype: N3Util.getLiteralType(object),
                                                     language: N3Util.getLiteralLanguage(object) }
          };
        })};
      }},