Class: NTriple

Inherits:
Object show all
Defined in:
lib/ontomde-core/triplet.rb

Overview

RDF triplet handling.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNTriple

Initialization of internal cache (performance enchancement)



118
119
120
121
122
123
124
125
126
# File 'lib/ontomde-core/triplet.rb', line 118

def initialize
  # Le cache est remis à zéro à chaque fichier.
  # Les essais avec SID.nt montrent un gain de performance
  # de 10% sur la méthode urialias, les fichiers étant largement disjoints.
  #@@cacheUse=1
  #@@cacheMiss=100
  #log.debug "initialize triplet"
  @uriMappingCache=Hash.new(nil)
end

Instance Attribute Details

#about_uriObject (readonly)

Returns the value of attribute about_uri.



113
114
115
# File 'lib/ontomde-core/triplet.rb', line 113

def about_uri
  @about_uri
end

#predicat_uriObject (readonly)

Returns the value of attribute predicat_uri.



113
114
115
# File 'lib/ontomde-core/triplet.rb', line 113

def predicat_uri
  @predicat_uri
end

#value_litteralObject (readonly)

Returns the value of attribute value_litteral.



113
114
115
# File 'lib/ontomde-core/triplet.rb', line 113

def value_litteral
  @value_litteral
end

#value_uriObject (readonly)

Returns the value of attribute value_uri.



113
114
115
# File 'lib/ontomde-core/triplet.rb', line 113

def value_uri
  @value_uri
end

Instance Method Details

#compute_urialias(uri) ⇒ Object

Internal use

Raises:



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/ontomde-core/triplet.rb', line 146

def compute_urialias(uri)
  #renvoi une uri apres avoir remplacer le chemin par son alias
  raise Warning.new,"Bad NT URI (#{uri})" if uri.nil? || (uri[0] != 60)
  #uri=uri[1,uri.length-2]
  #log.debug "uri[0,1] -> '#{uri[0,1]}'"
  uri=uri[1,uri.length].split(">",2)[0]
  #log.debug "uri-->#{uri}"
  return ::UriNamespace.instance.urialias(uri)

  #a=uri.split("#",2)
  #return uri if a[1].nil?
  #r=::UriNamespace.instance.getNamespaceAlias(a[0])
  #log.debug "urialias="+r+"_"+a[1]
  #return r+"_"+a[1]
  #return "#{r}_#{a[1]}"
end

#urialias(uri) ⇒ Object

Returns an aliases uri uri is in ntriple format: ‘<foo#bar>’ Optimize for ntriple file handling



131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/ontomde-core/triplet.rb', line 131

def urialias(uri)
  #log.debug "#{uri} ??"
  #return nil if uri == nil
  ret=@uriMappingCache[uri]
  #log.debug "cache miss %=#{1.0*@@cacheMiss/@@cacheUse*100} cacheUse=#{@@cacheUse}"
  #@@cacheUse=@@cacheUse+1
  return ret unless ret.nil?
  #log.debug "cache miss"
  #@@cacheMiss=@@cacheMiss+1
  @uriMappingCache[uri]=ret=compute_urialias(uri)
  #log.debug "#{uri} -> #{ret}"
  return ret
end

#valueIsReference?Boolean

Returns:

  • (Boolean)


114
115
# File 'lib/ontomde-core/triplet.rb', line 114

def valueIsReference?
end