lib/browser_web_data_entity_sumarization/entity_sumarization_statistics.rb
###
# The method helps to store founded information from nif for given resource.
#
# @param [String] resource_uri
# @param [String] type Type from http://mappings.dbpedia.org/server/ontology/classes/
# @param [Hsah] result_relations Hash generated by method #find_relations
# @option result_relations [Hash] :sections Contains key 'section_type' value 'position'
# @option result_relations [Array<Hash>] :relations Hashes generated by method #get_predicates_by_link
#
# @param [Float] this_time Relative time of find in nif dataset.
The method helps to store founded information from nif for given resource.
The method helps to store founded information from nif for given resource .
def generate_result_file(resource_uri, type, result_relations, this_time)
        section_degradation = result_relations[:sections].map { |section_type, position|
          index = result_relations[:sections].keys.index(section_type)
          position[:degradation] = 1 - ((index / result_relations[:sections].size) / 10.0)
          {section_type => position}
        }.reduce(:merge)
        total_size = section_degradation.max_by { |_, v| v[:to] }[1][:to].to_f
        result_nif_data = result_relations[:relations].map { |relation|
          paragraph_position = section_degradation[relation[:section]]
          position_weight = (1 - ((relation[:indexes][0].to_i) / total_size))
          relation[:weight] = (position_weight * paragraph_position[:degradation]).round(4)
          relation
        }
        result = {
          process_time: {nif_find: this_time, relations_find: result_relations[:time]},
          resource_uri: resource_uri,
          nif_data: result_nif_data
        }
        result_path = get_resource_file_path(resource_uri, type)
        File.open(result_path, 'w:utf-8') { |f| f << JSON.pretty_generate(result) }
      end
def generate_result_file ( resource_uri , type , result_relations , this_time ) section_degradation = result_relations [ :sections ] . map { | section_type , position | index = result_relations [ :sections ] . keys . index ( section_type ) position [ :degradation ] = 1 - ( ( index / result_relations [ :sections ] . size ) / 10.0 ) { section_type => position } } . reduce ( :merge ) total_size = section_degradation . max_by { | _ , v | v [ :to ] } [ 1 ] [ :to ] . to_f result_nif_data = result_relations [ :relations ] . map { | relation | paragraph_position = section_degradation [ relation [ :section ] ] position_weight = ( 1 - ( ( relation [ :indexes ] [ 0 ] . to_i ) / total_size ) ) relation [ :weight ] = ( position_weight * paragraph_position [ :degradation ] ) . round ( 4 ) relation } result = { process_time : { nif_find : this_time , relations_find : result_relations [ :time ] } , resource_uri : resource_uri , nif_data : result_nif_data } result_path = get_resource_file_path ( resource_uri , type ) File . open ( result_path , 'w:utf-8' ) { | f | f << JSON . pretty_generate ( result ) } end
The method helps to store founded information from nif for given resource.
The method helps to store founded information from nif for given resource .
# recognize value of degradation by relative position paragraphs in document # weight is lowest by relative distance from document start # weight is also degraded by index of paragraph
resource_uri
<not_specific>
type
<not_specific>
result_relations
:relations Hashes generated by method #get_predicates_by_link
: relations Hashes generated by method #get_predicates_by_link
this_time
<not_specific>
<not_specific>
this_time Relative time of find in nif dataset.
this_time Relative time of find in nif dataset .