<commit_before>require 'rdf'
require 'rdf/rdfxml'
require 'open-uri'
require 'csv'
require './osgbconvert'

include RDF

COUNCIL = "salford"

# add the data to the graph
graph = RDF::Graph.new

# set up the vocabulary
RDFS = RDF::RDFS
GEO = RDF::GEO
VCARD = RDF::VCARD
OS = RDF::Vocabulary.new("http://data.ordnancesurvey.co.uk/ontology/admingeo/")

# our new vocabulary
PARKING = RDF::Vocabulary.new("http://data.gmdsp.org.uk/id/" + COUNCIL + "/parking/")

def idify(s)
  rs = s.downcase
  rs.gsub!(" ", "-")
  rs
end


CSV.foreach('CarParks.csv', { headers:true }) do |csv_obj|
  label = csv_obj["Name"]
  # create a unique name
  subject = PARKING[idify(label)]
  # add the label
  graph << [subject, RDFS.label, label]
  # add the recycling centre type
  graph << [subject, RDF.type, RDF::URI("http://data.gmdsp.org.uk/def/parking")]
  # add the address location
  graph << [subject, VCARD.hasStreetAddress, csv_obj["Address"]]
  # location information
  osgb36point = convertWGS84toOSGB36(csv_obj["Latitude"].to_f, csv_obj["Longitude"].to_f, 0)
  locations = LatLongToOSGrid(osgb36point[0], osgb36point[1])
  graph << [subject, OS.easting, locations[0]]
  graph << [subject, OS.northing, locations[1]]

  # parking type
  #graph << [subject, PARKING.type, csv_obj["Type"]]

  # Operator info - should this be a organisation type?
  #graph << [subject, PARKING.operator, csv_obj["Operator"]]
  #graph << [subject, PARKING.operatorUrl, csv_obj["URL"]]


end


RDF::RDFXML::Writer.open("carparks.rdf") do |writer|
  writer << graph
end<commit_msg>Finish parking-fixes<commit_after>require 'rdf'
require 'rdf/rdfxml'
require 'open-uri'
require 'csv'
require './osgbconvert'

include RDF

COUNCIL = "salford"

# add the data to the graph
graph = RDF::Graph.new

# set up the vocabulary
RDFS = RDF::RDFS
GEO = RDF::GEO
VCARD = RDF::VCARD
OS = RDF::Vocabulary.new("http://data.ordnancesurvey.co.uk/ontology/admingeo/")

# our new vocabulary
PARKING = RDF::Vocabulary.new("http://data.gmdsp.org.uk/id/" + COUNCIL + "/parking/")

def idify(s)
  rs = s.downcase
  rs.gsub!(" ", "-")
  rs
end


CSV.foreach('CarParks.csv', { headers:true }) do |csv_obj|
  label = csv_obj["Name"]
  # create a unique name
  subject = PARKING[idify(label)]
  # add the label
  graph << [subject, RDFS.label, label]
  # add the recycling centre type
  graph << [subject, RDF.type, RDF::URI("http://data.gmdsp.org.uk/def/parking")]
  # add the address location
  graph << [subject, VCARD.hasStreetAddress, csv_obj["Address"]]
  # location information
  osgb36point = convertWGS84toOSGB36(csv_obj["Latitude"].to_f, csv_obj["Longitude"].to_f, 0)
  locations = LatLongToOSGrid(osgb36point[0], osgb36point[1])
  graph << [subject, OS.easting, locations[0]]
  graph << [subject, OS.northing, locations[1]]

  # parking type
  graph << [subject, PARKING.type, csv_obj["Type"]] unless csv_obj["Type"].nil?

  # Operator info - should this be a organisation type?
  graph << [subject, PARKING.operator, csv_obj["Operator"]] unless csv_obj["Operator"].nil?
  graph << [subject, PARKING.operatorUrl, csv_obj["URL"]] unless csv_obj["URL"].nil?


end


RDF::RDFXML::Writer.open("carparks.rdf") do |writer|
  writer << graph
end
{'fraction_non_alphanumeric': 0.16180620884289745, 'fraction_numerical': 0.00940733772342427, 'mean_word_length': 4.656028368794326, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7527282', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1192, 'n_words': 266}