;;;; -*- Mode: LISP; Syntax: Common-Lisp; Base: 10 -*- ;;;; --------------------------------------------------------------------------- ;;;; File name: africa_clusters.lsp ;;;; System: ;;;; Author: Praveen Paritosh ;;;; Created: February 9, 2004 13:44:04 ;;;; Purpose: ;;;; --------------------------------------------------------------------------- ;;;; Modified: Wednesday, February 11, 2004 at 00:14:42 by paritosh ;;;; --------------------------------------------------------------------------- (in-package :data) (defun generate-dimensional-facts (&optional (countries *wfb-africa-countries*) (fields *wfb-africa-fields*) (clusters *wfb-africa-dimensional-clusters*) (cluster-value-mapping *cluster-value-mapping*) (context 'data::ContinentOfAfrica)) ;; For each country, generate all the facts corresponsing to each predicate (let ((generated-facts nil) (num-countries (length countries)) (num-fields (length fields))) (dolist (country countries) (dolist (field fields) ;; Given a country and a field, there is a cluster ID -- 0, 1, 2, or 3 (let* ((cluster-id (nth (+ (* (position country countries) num-fields) (position field fields)) clusters)) (value (cdr (assoc cluster-id cluster-value-mapping)))) (if value (push (generate-dimensional-fact country field value context) generated-facts))))) generated-facts)) (defun generate-dimensional-fact (country field value context) `(data::isa ,country (,value ,field ,context))) (defparameter *cluster-value-mapping* '((0 . nil) (1 . LowValueContextualizedFn) (2 . MediumValueContextualizedFn) (3 . HighValueContextualizedFn))) (defparameter *wfb-africa-fields* '(importValue exportValue literacyRateForGroupInRegion lifeExpectancyForGroupInRegion infantMortalityRate deathRate birthRate populationGrowthRate populationDuring areaOfRegion)) (defparameter *wfb-africa-countries* '(Algeria Angola Benin Botswana BurkinaFaso Burundi Cameroon CapeVerde CentralAfricanRepublic Chad Comoros-TheNation Congo-Brazzaville IvoryCoast Djibouti Egypt EquatorialGuinea Eritrea Ethiopia Gabon Gambia Ghana Guinea Guinea-Bissau Kenya Lesotho Liberia Libya Madagascar Malawi Mali Mauritania Mauritius Morocco Mozambique Namibia Niger Nigeria Rwanda SaoTome-Island Senegal Seychelles SierraLeone Somalia SouthAfrica Sudan Swaziland Tanzania Togo Tunisia Uganda WesternSahara Congo-Kin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