lib/cultural_network/import/feature_data.rb
# ##################################################################### #
#
# Creates Feature from doc: Given an hpricot doc (the kind produced by 
# fetch_feature_docs, for example), parse the hpricot object into the 
# relevant gazetteer type objects (Feature, FeatureName, FeatureRelation, etc.)
# and write these to the database. 
#
Creates Feature from doc: Given an hpricot doc (the kind produced by
fetch_feature_docs, for example), parse the hpricot object into the
relevant gazetteer type objects (Feature, FeatureName, FeatureRelation, etc.)
and write these to the database.
Creates Feature from doc : Given an hpricot doc ( the kind produced by fetch_feature_docs for example ) parse the hpricot object into the relevant gazetteer type objects ( Feature FeatureName FeatureRelation etc . ) and write these to the database .
def parse_document(file)
      hpricot_doc = create_doc(file)
      raise "Feature not saved!" if hpricot_doc.nil?
      feature = extract_feature(hpricot_doc)
      xml_document = store_xml_document(feature)
      feature_object_types = extract_feature_object_types(hpricot_doc, feature)
      feature_relations = extract_feature_relations(hpricot_doc, feature)
      extract_feature_names(hpricot_doc, feature)
      features = Feature.all
      features.each do |f|
        f.save
      end
    end
def parse_document ( file ) hpricot_doc = create_doc ( file ) raise "Feature not saved!" if hpricot_doc . nil? feature = extract_feature ( hpricot_doc ) xml_document = store_xml_document ( feature ) feature_object_types = extract_feature_object_types ( hpricot_doc , feature ) feature_relations = extract_feature_relations ( hpricot_doc , feature ) extract_feature_names ( hpricot_doc , feature ) features = Feature . all features . each do | f | f . save end end
Creates Feature from doc: Given an hpricot doc (the kind produced by
fetch_feature_docs, for example), parse the hpricot object into the
relevant gazetteer type objects (Feature, FeatureName, FeatureRelation, etc.)
Creates Feature from doc : Given an hpricot doc ( the kind produced by fetch_feature_docs for example ) parse the hpricot object into the relevant gazetteer type objects ( Feature FeatureName FeatureRelation etc . )
#feature_names = extract_feature_names(hpricot_doc, feature) # When a feature is saved, it caches all of its ancestor ids.  # You need to make sure this happens for all of the features every time # a new batch has been imported. 
file
<not_specific>