lib/browser_web_data_entity_sumarization/entity_sumarization_statistics.rb
###
# The method find links in given nif dataset. After find collect relations #find_relations.
# For each resource generate file in @results_dir_path.
#
# @param [Array<String>, String] entity_types Types from http://mappings.dbpedia.org/server/ontology/classes/
# @param [Fixnum] count Count of best ranked resources
# @param [FalseClass, TruesClass] demand_reload
The method find links in given nif dataset. After find collect relations #find_relations.
For each resource generate file in @results_dir_path.
The method find links in given nif dataset . After find collect relations #find_relations . For each resource generate file in @results_dir_path .
def generate_statistics_from_nif(entity_types, count = 10, demand_reload = false)
        unless @nif_file_path
          raise RuntimeError.new('Instance has no defined return nif_dataset_path. Can not start generate from nif datset. Please create new instance.')
        end
        resources = get_best_ranked_resources(entity_types, count)
        resources = keep_unloaded(resources) unless demand_reload
        actual_resource_data = []
        lines_group = []
        begin
          time_start = Time.now
          nif_file = File.open(@nif_file_path, 'r')
          line = nif_file.readline
          until nif_file.eof?
            line = nif_file.readline
            if lines_group.size == 7
              this_resource_uri = NIFLineParser.parse_resource_uri(lines_group[0])
              if resources.keys.include?(this_resource_uri)
                resource_uri = this_resource_uri
                actual_resource_data << NIFLineParser.parse_line_group(lines_group)
              elsif !actual_resource_data.empty?
                resource_hash = resources.delete(resource_uri)
                type = resource_hash[:type]
                this_time = (Time.now - time_start).round(2)
                puts "\n#{resource_uri}\n- nif found in #{this_time}\n- resources to find #{resources.size}" if @console_output
                result_relations = find_relations(resource_uri, actual_resource_data, type)
                generate_result_file(resource_uri, type, result_relations, this_time)
                actual_resource_data = []
                time_start = Time.now
              end
              lines_group = [line]
            else
              lines_group << line
            end
            break if resources.empty?
          end
        ensure
          nif_file.close if nif_file && !nif_file.closed?
        end
      end
def generate_statistics_from_nif ( entity_types , count = 10 , demand_reload = false ) unless @nif_file_path raise RuntimeError . new ( 'Instance has no defined return nif_dataset_path. Can not start generate from nif datset. Please create new instance.' ) end resources = get_best_ranked_resources ( entity_types , count ) resources = keep_unloaded ( resources ) unless demand_reload actual_resource_data = [ ] lines_group = [ ] begin time_start = Time . now nif_file = File . open ( @nif_file_path , 'r' ) line = nif_file . readline until nif_file . eof? line = nif_file . readline if lines_group . size == 7 this_resource_uri = NIFLineParser . parse_resource_uri ( lines_group [ 0 ] ) if resources . keys . include? ( this_resource_uri ) resource_uri = this_resource_uri actual_resource_data << NIFLineParser . parse_line_group ( lines_group ) elsif ! actual_resource_data . empty? resource_hash = resources . delete ( resource_uri ) type = resource_hash [ :type ] this_time = ( Time . now - time_start ) . round ( 2 ) puts "\n#{resource_uri}\n- nif found in #{this_time}\n- resources to find #{resources.size}" if @console_output result_relations = find_relations ( resource_uri , actual_resource_data , type ) generate_result_file ( resource_uri , type , result_relations , this_time ) actual_resource_data = [ ] time_start = Time . now end lines_group = [ line ] else lines_group << line end break if resources . empty? end ensure nif_file . close if nif_file && ! nif_file . closed? end end
The method find links in given nif dataset.
The method find links in given nif dataset .
# evaulate group (7 lines) # process group, is requested # resource changed, process actual_resource_data # start new group # join line to group
entity_types
<not_specific>
count
<not_specific>
demand_reload
<not_specific>
<not_specific>
None