From e5ad5813da2c9b131ea781ae25598afa4977a6cd Mon Sep 17 00:00:00 2001 From: Benn Oshrin Date: Sun, 23 Jun 2019 07:03:33 -0400 Subject: [PATCH] Implement attribute mappings (CO-1759) --- app/config/schema/schema.json | 37 +- app/src/Controller/AppController.php | 94 ++ .../AttributeMappingsController.php | 86 ++ .../Controller/AttributeMapsController.php | 64 + .../Component/AuthorizationComponent.php | 3 +- app/src/Controller/StandardController.php | 43 - app/src/Lib/Enum/SearchTypeEnum.php | 1 + app/src/Lib/Match/MatchService.php | 10 + app/src/Locale/en_US/default.po | 39 + app/src/Model/Entity/AttributeMap.php | 41 + app/src/Model/Entity/AttributeMapping.php | 40 + .../Model/Table/AttributeMappingsTable.php | 157 +++ app/src/Model/Table/AttributeMapsTable.php | 98 ++ app/src/Model/Table/AttributesTable.php | 39 +- app/src/Model/Table/RuleAttributesTable.php | 1 + .../Template/AttributeMappings/columns.inc | 49 + app/src/Template/AttributeMappings/fields.inc | 32 + app/src/Template/AttributeMaps/columns.inc | 40 + app/src/Template/AttributeMaps/fields.inc | 32 + app/src/Template/Attributes/fields.inc | 2 + app/src/Template/Element/menuMain.ctp | 1 + app/vendor/nicknames/JavaParser.java | 29 + app/vendor/nicknames/License.txt | 201 +++ app/vendor/nicknames/README.md | 11 + app/vendor/nicknames/name_lookup.pl | 91 ++ app/vendor/nicknames/names-counter.pl | 120 ++ app/vendor/nicknames/names.csv | 1082 +++++++++++++++++ app/vendor/nicknames/python-parser.py | 31 + 28 files changed, 2423 insertions(+), 51 deletions(-) create mode 100644 app/src/Controller/AttributeMappingsController.php create mode 100644 app/src/Controller/AttributeMapsController.php create mode 100644 app/src/Model/Entity/AttributeMap.php create mode 100644 app/src/Model/Entity/AttributeMapping.php create mode 100644 app/src/Model/Table/AttributeMappingsTable.php create mode 100644 app/src/Model/Table/AttributeMapsTable.php create mode 100644 app/src/Template/AttributeMappings/columns.inc create mode 100644 app/src/Template/AttributeMappings/fields.inc create mode 100644 app/src/Template/AttributeMaps/columns.inc create mode 100644 app/src/Template/AttributeMaps/fields.inc create mode 100644 app/vendor/nicknames/JavaParser.java create mode 100644 app/vendor/nicknames/License.txt create mode 100644 app/vendor/nicknames/README.md create mode 100755 app/vendor/nicknames/name_lookup.pl create mode 100644 app/vendor/nicknames/names-counter.pl create mode 100644 app/vendor/nicknames/names.csv create mode 100644 app/vendor/nicknames/python-parser.py diff --git a/app/config/schema/schema.json b/app/config/schema/schema.json index 633e99509..f7e5b234e 100644 --- a/app/config/schema/schema.json +++ b/app/config/schema/schema.json @@ -12,6 +12,7 @@ "comment": "columns with names matching those defined here will by default inherit these properties", "columns": { + "attribute_map_id": { "type": "integer", "foreignkey": { "table": "attribute_maps", "column": "id" } }, "description": { "type": "string", "size": 128 }, "id": { "type": "integer", "autoincrement": true, "primarykey": true }, "matchgrid_id": { "type": "integer", "foreignkey": { "table": "matchgrids", "column": "id" }, "notnull": true }, @@ -68,6 +69,39 @@ "changelog": false }, + "attribute_maps": { + "columns": { + "id": {}, + "matchgrid_id": {}, + "name": {}, + "description": {} + }, + "indexes": { + "attribute_maps_i1": { + "columns": [ "matchgrid_id" ] + } + }, + "changelog": false + }, + + "attribute_mappings": { + "columns": { + "id": {}, + "attribute_map_id": {}, + "query": { "type": "string", "size": 80 }, + "value": { "type": "string", "size": 80 } + }, + "indexes": { + "attribute_mappings_i1": { + "columns": [ "attribute_map_id" ] + }, + "attribute_mappings_i2": { + "columns": [ "query" ] + } + }, + "changelog": false + }, + "attribute_groups": { "columns": { "id": {}, @@ -98,7 +132,8 @@ "search_distance": { "type": "integer" }, "search_exact": { "type": "boolean" }, "search_substr_from": { "type": "integer" }, - "search_substr_for": { "type": "integer" } + "search_substr_for": { "type": "integer" }, + "attribute_map_id": {} }, "indexes": { "attributes_i1": { diff --git a/app/src/Controller/AppController.php b/app/src/Controller/AppController.php index c30b2c00e..7e3af70a6 100644 --- a/app/src/Controller/AppController.php +++ b/app/src/Controller/AppController.php @@ -33,6 +33,7 @@ use Cake\Datasource\Exception; use Cake\Datasource\Exception\RecordNotFoundException; use Cake\Event\Event; +use Cake\ORM\TableRegistry; use InvalidArgumentException; class AppController extends Controller { @@ -40,6 +41,49 @@ class AppController extends Controller { // and so should not be trusted without further authorization. protected $cur_mg = null; + /** + * Obtain information about the Standard Object's Primary Link, if set. + * The $vv_primary_link view variable is also set. + * + * @since COmanage Match v1.0.0 + * @param boolean $lookup If true, get the value of the primary link, not just the attribute + * @return array Array holding the primary link attribute, and optionally its value + * @throws \RuntimeException + */ + + protected function getPrimaryLink(bool $lookup=false) { + // $this->name = Models + $modelsName = $this->name; + // $modelName = Model + $modelName = \Cake\Utility\Inflector::singularize($this->name); + + $ret = []; + + // PrimaryLinkTrait + if(method_exists($this->$modelsName, "getPrimaryLink") + && $this->$modelsName->getPrimaryLink()) { + $ret['linkattr'] = $this->$modelsName->getPrimaryLink(); + $this->set('vv_primary_link', $ret['linkattr']); + + if($lookup) { + // Try to find a value + if($this->request->getQuery($ret['linkattr'])) { + $ret['linkvalue'] = $this->request->getQuery($ret['linkattr']); + } elseif($this->request->getData($ret['linkattr'])) { + $ret['linkvalue'] = $this->request->getData($ret['linkattr']); + } elseif($this->request->getData($modelName . "." . $ret['linkattr'])) { + $ret['linkvalue'] = $this->request->getData($modelName . "." . $ret['linkattr']); + } else { + if(!$this->$modelsName->allowEmptyPrimaryLink()) { + throw new \RuntimeException(__('match.er.primary_link', [ $ret['linkattr'] ])); + } + } + } + } + + return $ret; + } + /** * Initialization callback. * @@ -93,6 +137,9 @@ public function initialize() { public function beforeFilter(\Cake\Event\Event $event) { parent::beforeFilter($event); + + // Determine the timezone + $this->setTZ(); // Determine the requested Matchgrid $this->setMatchgrid(); @@ -184,6 +231,22 @@ protected function setMatchgrid() { } } + if(!$mgid) { + // Use the primary link (if found) to calculate the matchgrid ID + + // PrimaryLinkTrait + $link = $this->getPrimaryLink(true); + + if(!empty($link['linkvalue'])) { + $m = \Cake\Utility\Inflector::pluralize( + \Cake\Utility\Inflector::camelize( + substr($link['linkattr'], 0, strlen($link['linkattr'])-3))); + + $linkModel = TableRegistry::get($m); + $mgid = $linkModel->calculateMatchgridId((int)$link['linkvalue']); + } + } + if(!$mgid && !$this->$modelsName->allowEmptyMatchgrid()) { // If we get this far without a Matchgrid ID, something went wrong. throw new \RuntimeException(__('match.er.mgid')); @@ -198,4 +261,35 @@ protected function setMatchgrid() { $this->set('vv_cur_mg', $this->cur_mg); } } + + /** + * Determine the current timezone and make it available to the + * rest of the application. + * + * @since COmanage Match v1.0.0 + */ + + protected function setTZ() { + // $this->name = Models + $modelsName = $this->name; + + // See if we've collected it from the browser in a previous page load. Otherwise + // use the system default. If the user set a preferred timezone, we'll catch that below. + + $tz = date_default_timezone_get(); + + if(!empty($_COOKIE['cm_match_tz_auto'])) { + // We have an auto-detected timezone from a previous page render from the browser. + // Note we don't call date_default_timezone_set() because we still want to record + // times internally in UTC (at the expense of having to convert back and forth). + $tz = $_COOKIE['cm_match_tz_auto']; + } + + $this->set('vv_tz', $tz); + + if($this->$modelsName->behaviors()->has('Timezone')) { + // Tell TimezoneBehavior what the current timezone is + $this->$modelsName->setTimeZone($tz); + } + } } diff --git a/app/src/Controller/AttributeMappingsController.php b/app/src/Controller/AttributeMappingsController.php new file mode 100644 index 000000000..3948dc892 --- /dev/null +++ b/app/src/Controller/AttributeMappingsController.php @@ -0,0 +1,86 @@ + [ + 'AttributeMappings.query' => 'asc', + 'AttributeMappings.value' => 'asc' + ] + ]; + + /** + * Handle an edit action for a Standard object. + * + * @since COmanage Match v1.0.0 + */ + + public function install() { + try { + $this->AttributeMappings->install((int)$this->request->getQuery('attribute_map_id'), + $this->request->getQuery('mapping')); + + $this->Flash->success(__('match.rs.AttributeMappings.install')); + } + catch(Exception $e) { + $this->Flash->error($e->getMessage()); + } + + return $this->generateRedirect(); + } + + /** + * Authorization for this Controller, called by Auth component + * - postcondition: $vv_permissions set with calculated permissions for this Controller + * + * @since COmanage Match v1.0.0 + * @param Array $user Array of user data + * @return Boolean True if authorized for the current action, false otherwise + */ + + public function isAuthorized(Array $user) { + $platformAdmin = $this->Authorization->isPlatformAdmin($user['username']); + + $mgAdmin = $this->Authorization->isMatchAdmin($user['username'], $this->mgid); + + $p = [ + 'add' => $platformAdmin || $mgAdmin, + 'delete' => $platformAdmin || $mgAdmin, + 'edit' => $platformAdmin || $mgAdmin, + 'index' => $platformAdmin || $mgAdmin, + 'install' => $platformAdmin || $mgAdmin, + 'view' => false + ]; + + $this->set('vv_permissions', $p); + return $p[$this->request->getParam('action')]; + } +} \ No newline at end of file diff --git a/app/src/Controller/AttributeMapsController.php b/app/src/Controller/AttributeMapsController.php new file mode 100644 index 000000000..aee98256c --- /dev/null +++ b/app/src/Controller/AttributeMapsController.php @@ -0,0 +1,64 @@ + [ + 'AttributeMaps.name' => 'asc' + ] + ]; + + /** + * Authorization for this Controller, called by Auth component + * - postcondition: $vv_permissions set with calculated permissions for this Controller + * + * @since COmanage Match v1.0.0 + * @param Array $user Array of user data + * @return Boolean True if authorized for the current action, false otherwise + */ + + public function isAuthorized(Array $user) { + $platformAdmin = $this->Authorization->isPlatformAdmin($user['username']); + + $mgAdmin = $this->Authorization->isMatchAdmin($user['username'], $this->mgid); + + $p = [ + 'add' => $platformAdmin || $mgAdmin, + 'delete' => $platformAdmin || $mgAdmin, + 'edit' => $platformAdmin || $mgAdmin, + 'index' => $platformAdmin || $mgAdmin, + 'view' => false + ]; + + $this->set('vv_permissions', $p); + return $p[$this->request->getParam('action')]; + } +} \ No newline at end of file diff --git a/app/src/Controller/Component/AuthorizationComponent.php b/app/src/Controller/Component/AuthorizationComponent.php index e6cf71684..113536678 100644 --- a/app/src/Controller/Component/AuthorizationComponent.php +++ b/app/src/Controller/Component/AuthorizationComponent.php @@ -185,8 +185,9 @@ public function menuPermissions($username, $matchgridId=null) { return [ // Manage configuration of the current matchgrid 'api_users' => $platformAdmin || $mgAdmin, - 'attributes' => $platformAdmin || $mgAdmin, 'attribute_groups' => $platformAdmin || $mgAdmin, + 'attribute_maps' => $platformAdmin || $mgAdmin, + 'attributes' => $platformAdmin || $mgAdmin, 'rules' => $platformAdmin || $mgAdmin, 'systems_of_record' => $platformAdmin || $mgAdmin, // Permissions specific to a matchgrid diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index cc85f3581..979f32c20 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -216,49 +216,6 @@ public function generateRedirect() { return $this->redirect($redirect); } - /** - * Obtain information about the Standard Object's Primary Link, if set. - * The $vv_primary_link view variable is also set. - * - * @since COmanage Match v1.0.0 - * @param boolean $lookup If true, get the value of the primary link, not just the attribute - * @return array Array holding the primary link attribute, and optionally its value - * @throws \RuntimeException - */ - - protected function getPrimaryLink(bool $lookup=false) { - // $this->name = Models - $modelsName = $this->name; - // $modelName = Model - $modelName = \Cake\Utility\Inflector::singularize($this->name); - - $ret = []; - - // PrimaryLinkTrait - if(method_exists($this->$modelsName, "getPrimaryLink") - && $this->$modelsName->getPrimaryLink()) { - $ret['linkattr'] = $this->$modelsName->getPrimaryLink(); - $this->set('vv_primary_link', $ret['linkattr']); - - if($lookup) { - // Try to find a value - if($this->request->getQuery($ret['linkattr'])) { - $ret['linkvalue'] = $this->request->getQuery($ret['linkattr']); - } elseif($this->request->getData($ret['linkattr'])) { - $ret['linkvalue'] = $this->request->getData($ret['linkattr']); - } elseif($this->request->getData($modelName . "." . $ret['linkattr'])) { - $ret['linkvalue'] = $this->request->getData($modelName . "." . $ret['linkattr']); - } else { - if(!$this->$modelsName->allowEmptyPrimaryLink()) { - throw new \RuntimeException(__('match.er.primary_link', [ $ret['linkattr'] ])); - } - } - } - } - - return $ret; - } - /** * Generate an index for a set of Standard Objects. * diff --git a/app/src/Lib/Enum/SearchTypeEnum.php b/app/src/Lib/Enum/SearchTypeEnum.php index 03bbfac4e..5e97df6a1 100644 --- a/app/src/Lib/Enum/SearchTypeEnum.php +++ b/app/src/Lib/Enum/SearchTypeEnum.php @@ -32,6 +32,7 @@ class SearchTypeEnum extends StandardEnum { const Distance = 'D'; const Exact = 'E'; + const Mapping = 'M'; const Skip = 'X'; const Substring = 'S'; } \ No newline at end of file diff --git a/app/src/Lib/Match/MatchService.php b/app/src/Lib/Match/MatchService.php index 1ad7a4f1b..01e259be5 100644 --- a/app/src/Lib/Match/MatchService.php +++ b/app/src/Lib/Match/MatchService.php @@ -513,6 +513,16 @@ protected function search(string $mode, case SearchTypeEnum::Exact: $andclause = $colclause . "=?"; break; + case SearchTypeEnum::Mapping: + $andclause = "(" . $colclause . " + IN (SELECT value + FROM attribute_mappings + WHERE attribute_map_id=" . $ruleattr->attribute->attribute_map_id ." + AND query=LOWER(?)) + OR " . $colclause . "=?)"; + // We need to copies of $val in the param list + $vals[] = $val; + break; case SearchTypeEnum::Substring: $andclause = "SUBSTRING(" . $colclause diff --git a/app/src/Locale/en_US/default.po b/app/src/Locale/en_US/default.po index f1744bf23..ce84a19bd 100644 --- a/app/src/Locale/en_US/default.po +++ b/app/src/Locale/en_US/default.po @@ -87,6 +87,12 @@ msgstr "{0,plural,=1{API User} other{API Users}}" msgid "match.ct.attribute_groups" msgstr "{0,plural,=1{Attribute Group} other{Attribute Groups}}" +msgid "match.ct.attribute_mappings" +msgstr "{0,plural,=1{Attribute Mapping} other{Attribute Mappings}}" + +msgid "match.ct.attribute_maps" +msgstr "{0,plural,=1{Attribute Map} other{Attribute Maps}}" + msgid "match.ct.attributes" msgstr "{0,plural,=1{Attribute} other{Attributes}}" @@ -142,6 +148,9 @@ msgstr "Distance" msgid "match.en.SearchTypeEnum.E" msgstr "Exact" +msgid "match.en.SearchTypeEnum.M" +msgstr "Mapping" + msgid "match.en.SearchTypeEnum.X" msgstr "Skip" @@ -224,6 +233,15 @@ msgstr "{0} does not have any valid permissions" msgid "match.er.search_type" msgstr "Unknown search type '{0}'" +msgid "match.er.val.alphanum" +msgstr "Provided value contains non-alphanumeric characters" + +msgid "match.er.val.length" +msgstr "Provided value exceeds maximum length of {0}" + +msgid "match.er.val.range" +msgstr "Value must be between {0} and {1}" + ### Fields ### Keys of the form match.fd.MyModels.field_name[.desc] will apply only to MyModels.field_name ### Keys of the form match.fd.field_name[.desc] will apply if no model specific key is found @@ -242,6 +260,15 @@ msgstr "API Username" msgid "match.fd.ApiUsers.username.desc" msgstr "Username must begin with matchgrid name and a dot (for Matchgrid API Users), or must not contain a dot (for Platform API Users)" +msgid "match.fd.AttributeMappings.query.desc" +msgstr "String used as a lookup key or query value" + +msgid "match.fd.AttributeMappings.value.desc" +msgstr "Value used as a matching string to query key" + +msgid "match.fd.Attributes.name.desc" +msgstr "Value must be alphanumeric, as it will be used to construct the matchgrid column name" + msgid "match.fd.case_sensitive" msgstr "Case Sensitive" @@ -272,6 +299,9 @@ msgstr "Password" msgid "match.fd.permission" msgstr "Permission" +msgid "match.fd.query" +msgstr "Query" + msgid "match.fd.referenceid" msgstr "Reference ID" @@ -335,6 +365,9 @@ msgstr "Unique, alphanumeric name for matchgrid (will be prefixed mg_ for actual msgid "match.fd.username" msgstr "Username" +msgid "match.fd.value" +msgstr "Value" + msgid "match.home.welcome" msgstr "Welcome to {0}." @@ -353,6 +386,9 @@ msgstr "Platform" msgid "match.op.add.a" msgstr "Add New {0}" +msgid "match.op.AttributeMappings.install.nicknames.en" +msgstr "Install English Nicknames" + msgid "match.op.build" msgstr "Build" @@ -429,6 +465,9 @@ msgid "match.op.skip_to_content" msgstr "Skip to main content" ### Results +msgid "match.rs.AttributeMappings.install" +msgstr "Attribute Mapping successfully installed" + msgid "match.rs.build" msgstr "Matchgrid schema successfully applied" diff --git a/app/src/Model/Entity/AttributeMap.php b/app/src/Model/Entity/AttributeMap.php new file mode 100644 index 000000000..9f00e0f36 --- /dev/null +++ b/app/src/Model/Entity/AttributeMap.php @@ -0,0 +1,41 @@ + true, + 'id' => false, + 'slug' => false, + ]; +} \ No newline at end of file diff --git a/app/src/Model/Entity/AttributeMapping.php b/app/src/Model/Entity/AttributeMapping.php new file mode 100644 index 000000000..862537094 --- /dev/null +++ b/app/src/Model/Entity/AttributeMapping.php @@ -0,0 +1,40 @@ + true, + 'id' => false, + 'slug' => false, + ]; +} diff --git a/app/src/Model/Table/AttributeMappingsTable.php b/app/src/Model/Table/AttributeMappingsTable.php new file mode 100644 index 000000000..762e3ee09 --- /dev/null +++ b/app/src/Model/Table/AttributeMappingsTable.php @@ -0,0 +1,157 @@ +addBehavior('Timestamp'); + + // Define associations + $this->belongsTo('AttributeMaps'); + + $this->setDisplayField('query'); + + $this->setPrimaryLink('attribute_map_id'); + $this->setRequiresMatchgrid(true); + } + + /** + * Install a pre-configured set of Attribute Mappings. + * + * @param int $attributeMapId Attribute Map ID to install into + * @param string $mapping Mapping to install, currently only "nicknames.en" is supported + * @throws \RuntimeException + */ + + public function install(int $attributeMapId, string $mapping) { + // For now, we assume this is the CSV file from this project: + // https://github.com/carltonnorthern/nickname-and-diminutive-names-lookup + $infile = fopen(ROOT . DS . "vendor" . DS . "nicknames" . DS . "names.csv", "r"); + + // We'll build an array of name -> nickname by cross referencing each set of + // names. There may be some duplicates, so we use query -> value -> true + // format. + + $namemap = []; // Inbound mapping (from file) + $curmap = []; // Current mapping (from database) + + while(($row = fgetcsv($infile))) { + foreach($row as $q) { + foreach($row as $v) { + if($q == $v) { + continue; + } + + $namemap[$q][$v] = true; + } + } + } + + // Pull the current mappings so we can skip any that are already in place + + $curmapobjs = $this->find('all') //, ['keyField' => 'query', 'valueField' => 'value']) + ->where(['attribute_map_id' => $attributeMapId]) + ->all(); + + // Transform the result into a lookup-able dictionary of the same format + // as $namemap, since we might have multiple values for the same key. + + foreach($curmapobjs as $o) { + $curmap[ $o->query ][ $o->value ] = true; + } + + foreach($namemap as $q => $vs) { + foreach($vs as $v => $status) { + if(!isset($curmap[$q][$v])) { + $mapping = $this->newEntity(); + + $mapping->attribute_map_id = $attributeMapId; + $mapping->query = $q; + $mapping->value = $v; + + if(!$this->save($mapping)) { + throw new \RuntimeException(__('match.er.save', ['AttributeMappings'])); + } + } + } + } + + fclose($infile); + } + + /** + * Set validation rules. + * + * @since COmanage Match v1.0.0 + * @param Validator $validator Validator + * @return $validator Validator + */ + + public function validationDefault(Validator $validator) { + $validator->add( + 'query', + 'length', + [ 'rule' => [ 'maxLength', 80 ], + 'message' => __('match.er.val.length', [80]) ] + ); + $validator->notEmpty('name'); + + $validator->add( + 'value', + 'length', + [ 'rule' => [ 'maxLength', 80 ], + 'message' => __('match.er.val.length', [80]) ] + ); + $validator->notEmpty('description'); + + $validator->add( + 'attribute_map_id', + 'content', + [ 'rule' => 'isInteger' ] + ); + $validator->notEmpty('attribute_map_id'); + + return $validator; + } +} diff --git a/app/src/Model/Table/AttributeMapsTable.php b/app/src/Model/Table/AttributeMapsTable.php new file mode 100644 index 000000000..f35d09b7b --- /dev/null +++ b/app/src/Model/Table/AttributeMapsTable.php @@ -0,0 +1,98 @@ +addBehavior('Timestamp'); + + // Define associations + $this->belongsTo('Matchgrids'); + + $this->hasMany('Attributes'); + + $this->hasMany('AttributeMappings') + ->setDependent(true); + + $this->setDisplayField('name'); + + $this->setPrimaryLink('matchgrid_id'); + $this->setRequiresMatchgrid(true); + } + + /** + * Set validation rules. + * + * @since COmanage Match v1.0.0 + * @param Validator $validator Validator + * @return $validator Validator + */ + + public function validationDefault(Validator $validator) { + $validator->add( + 'name', + 'length', + [ 'rule' => [ 'maxLength', 64 ], + 'message' => __('match.er.val.length', [64]) ] + ); + $validator->notEmpty('name'); + + $validator->add( + 'description', + 'length', + [ 'rule' => [ 'maxLength', 128 ], + 'message' => __('match.er.val.length', [128]) ] + ); + $validator->allowEmpty('description'); + + $validator->add( + 'matchgrid_id', + 'content', + [ 'rule' => 'isInteger' ] + ); + $validator->notEmpty('matchgrid_id'); + + return $validator; + } +} diff --git a/app/src/Model/Table/AttributesTable.php b/app/src/Model/Table/AttributesTable.php index 3c704e110..4774c2387 100644 --- a/app/src/Model/Table/AttributesTable.php +++ b/app/src/Model/Table/AttributesTable.php @@ -49,6 +49,7 @@ public function initialize(array $config) { // Define associations $this->belongsTo('AttributeGroups'); + $this->belongsTo('AttributeMaps'); $this->belongsTo('Matchgrids'); //$this->belongsToMany('Rules', ['through' => 'RuleAttributes']); $this->hasMany('RuleAttributes') @@ -64,6 +65,11 @@ public function initialize(array $config) { 'type' => 'select', 'model' => 'AttributeGroups', 'find' => 'filterPrimaryLink' + ], + 'attributeMaps' => [ + 'type' => 'select', + 'model' => 'AttributeMaps', + 'find' => 'filterPrimaryLink' ] ]); } @@ -79,7 +85,16 @@ public function validationDefault(Validator $validator) { $validator->add( 'name', 'length', - [ 'rule' => [ 'maxLength', 128 ] ] + [ 'rule' => [ 'maxLength', 128 ], + 'message' => __('match.er.val.length', [128]) ] + ); + // name must be alphanumeric since that's what MatchgridBuilder uses to + // construct the column name. + $validator->add( + 'name', + 'content', + [ 'rule' => [ 'alphaNumeric' ], + 'message' => __('match.er.val.alphanum') ] ); $validator->notEmpty('name'); @@ -93,14 +108,16 @@ public function validationDefault(Validator $validator) { $validator->add( 'description', 'length', - [ 'rule' => [ 'maxLength', 128 ] ] + [ 'rule' => [ 'maxLength', 128 ], + 'message' => __('match.er.val.length', [128]) ] ); $validator->allowEmpty('description'); $validator->add( 'api_name', 'length', - [ 'rule' => [ 'maxLength', 128 ] ] + [ 'rule' => [ 'maxLength', 128 ], + 'message' => __('match.er.val.length', [128]) ] ); $validator->notEmpty('api_name'); @@ -149,7 +166,8 @@ public function validationDefault(Validator $validator) { $validator->add( 'search_distance', 'content', - [ 'rule' => [ 'range', 1, 9 ] ] + [ 'rule' => [ 'range', 1, 9 ], + 'message' => __('match.er.val.range', [1, 9]) ] ); $validator->allowEmpty('search_distance'); @@ -163,17 +181,26 @@ public function validationDefault(Validator $validator) { $validator->add( 'search_substr_from', 'content', - [ 'rule' => [ 'range', 0, 128 ] ] + [ 'rule' => [ 'range', 0, 128 ], + 'message' => __('match.er.val.range', [0, 128]) ] ); $validator->allowEmpty('search_substr_from'); $validator->add( 'search_substr_for', 'content', - [ 'rule' => [ 'range', 1, 128 ] ] + [ 'rule' => [ 'range', 1, 128 ], + 'message' => __('match.er.val.range', [1, 128]) ] ); $validator->allowEmpty('search_substr_for'); + $validator->add( + 'attribute_map_id', + 'content', + [ 'rule' => 'isInteger' ] + ); + $validator->allowEmpty('attribute_map_id'); + return $validator; } } \ No newline at end of file diff --git a/app/src/Model/Table/RuleAttributesTable.php b/app/src/Model/Table/RuleAttributesTable.php index 45c5b8c9f..68919eacb 100644 --- a/app/src/Model/Table/RuleAttributesTable.php +++ b/app/src/Model/Table/RuleAttributesTable.php @@ -79,6 +79,7 @@ public function validationDefault(Validator $validator) { [ 'rule' => [ 'inList', [ SearchTypeEnum::Distance, SearchTypeEnum::Exact, + SearchTypeEnum::Mapping, SearchTypeEnum::Skip, SearchTypeEnum::Substring ] ] ] diff --git a/app/src/Template/AttributeMappings/columns.inc b/app/src/Template/AttributeMappings/columns.inc new file mode 100644 index 000000000..9c035d5df --- /dev/null +++ b/app/src/Template/AttributeMappings/columns.inc @@ -0,0 +1,49 @@ + [ + 'type' => 'link', + 'sortable' => true + ], + 'value' => [ + 'type' => 'echo', + 'sortable' => true + ] +]; + +$topLinks = [ + [ + 'label' => __('match.op.AttributeMappings.install.nicknames.en'), + 'link' => [ + 'action' => 'install', + 'mapping' => 'nicknames.en' + ], + 'class' => 'buildbutton' + ] +]; \ No newline at end of file diff --git a/app/src/Template/AttributeMappings/fields.inc b/app/src/Template/AttributeMappings/fields.inc new file mode 100644 index 000000000..f4743f025 --- /dev/null +++ b/app/src/Template/AttributeMappings/fields.inc @@ -0,0 +1,32 @@ +Field->control('query'); + print $this->Field->control('value'); +} \ No newline at end of file diff --git a/app/src/Template/AttributeMaps/columns.inc b/app/src/Template/AttributeMaps/columns.inc new file mode 100644 index 000000000..bd8260b56 --- /dev/null +++ b/app/src/Template/AttributeMaps/columns.inc @@ -0,0 +1,40 @@ + [ + 'type' => 'link' + ] +]; + +$indexActions = [ + [ + 'controller' => 'attribute_mappings', + 'action' => 'index', + 'class' => 'linkbutton' + ] +]; \ No newline at end of file diff --git a/app/src/Template/AttributeMaps/fields.inc b/app/src/Template/AttributeMaps/fields.inc new file mode 100644 index 000000000..246363f0c --- /dev/null +++ b/app/src/Template/AttributeMaps/fields.inc @@ -0,0 +1,32 @@ +Field->control('name'); + print $this->Field->control('description', [], false); +} \ No newline at end of file diff --git a/app/src/Template/Attributes/fields.inc b/app/src/Template/Attributes/fields.inc index a8d9b24af..69485c9e3 100644 --- a/app/src/Template/Attributes/fields.inc +++ b/app/src/Template/Attributes/fields.inc @@ -45,5 +45,7 @@ if($action == 'add' || $action == 'edit') { print $this->Field->control('search_substr_from', [], false); print $this->Field->control('search_substr_for', [], false); + print $this->Field->control('attribute_map_id', ['empty' => true], false); + print $this->Field->control('attribute_group_id', ['empty' => true], false); } diff --git a/app/src/Template/Element/menuMain.ctp b/app/src/Template/Element/menuMain.ctp index 8f9bba476..d357af8e1 100644 --- a/app/src/Template/Element/menuMain.ctp +++ b/app/src/Template/Element/menuMain.ctp @@ -37,6 +37,7 @@ 'api_users' => 'vpn_key', 'attributes' => 'edit', 'attribute_groups' => 'storage', + 'attribute_maps' => 'swap_horiz', 'rules' => 'assignment', 'systems_of_record' => 'gavel', ]; diff --git a/app/vendor/nicknames/JavaParser.java b/app/vendor/nicknames/JavaParser.java new file mode 100644 index 000000000..a8ee988b7 --- /dev/null +++ b/app/vendor/nicknames/JavaParser.java @@ -0,0 +1,29 @@ +public Map dimNames = new HashMap(); + + private void loadDiminutiveNames() { + BufferedReader input = null; + + try { + input = new BufferedReader(new FileReader(dimNamesFile)); + String line = null; + while ((line = input.readLine()) != null) { + //System.out.println("line = " + line); + StringTokenizer st = new StringTokenizer(line, ","); + String key = st.nextToken(); + List values = new ArrayList(); + while (st.hasMoreElements()) { + values.add(st.nextToken()); + } + dimNames.put(key, values); + } + + } catch (IOException ex) { + Logger.getLogger(ThisClass.class.getName()).log(Level.SEVERE, null, ex); + } finally { + try { + input.close(); + } catch (IOException ex) { + Logger.getLogger(ThisClass.class.getName()).log(Level.SEVERE, null, ex); + } + } + } diff --git a/app/vendor/nicknames/License.txt b/app/vendor/nicknames/License.txt new file mode 100644 index 000000000..8dada3eda --- /dev/null +++ b/app/vendor/nicknames/License.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/app/vendor/nicknames/README.md b/app/vendor/nicknames/README.md new file mode 100644 index 000000000..00248b760 --- /dev/null +++ b/app/vendor/nicknames/README.md @@ -0,0 +1,11 @@ +# nickname-and-diminutive-names-lookup +A CSV file that containing US given names (first name) and their associated nicknames or diminutive names. + +This lookup file was initially created by mining this +genealogy page. Because the lookup is based off of a dataset used for genealogy purposes there are some old names that aren't used commonly these days, but there are recent ones as well. Examples are "gregory", "greg", or "geoffrey", "geoff". There was also a significant effort to make it machine readable, i.e. separate it with commas, remove human conventions, like "rickie(y)" would need to be made into two different names "rickie", and "ricky". + +There are Java, Perl and Python parsers provided for convenience. + +This is a relatively large list with about 1600 names. Any help from people to clean this list up and add to it is greatly appreciated. Think of it as a wiki. Just request to join the project and you'll be added. + +This project was created by Old Dominion University - Web Science and Digital Libraries Research Group. More information about the creation of this lookup can be found here. diff --git a/app/vendor/nicknames/name_lookup.pl b/app/vendor/nicknames/name_lookup.pl new file mode 100755 index 000000000..8d68e747c --- /dev/null +++ b/app/vendor/nicknames/name_lookup.pl @@ -0,0 +1,91 @@ +#!/usr/bin/env perl + +## Nickname lookup +## Example code for parsing a csv file of names and nicknames +## into a hash dictionary for quick lookups +## +## Expects a csv where each line contains a list of related names +## EX: +## abbie,abby,abigail +## beth,betsy,betty,elizabeth + +use strict; + +use Getopt::Std; + +my $opts = {}; +getopts('hd', $opts); + +if (!$ARGV[0] or $opts->{h}) { + usage(); + exit; +} + +my $name_dict; + +# Open the input file and output file +open my $in_file , '<', $ARGV[0] or die "Cant open $ARGV[0]"; + +while(defined(my $line = <$in_file>)) { + + $line =~ s/^\s*|\s*$//g; # strip leading and following whitespace + $line =~ s/#.*$//; # strip comments + + if (!$line or $line =~ /^,+$/ or $line =~ /^\s*$/) { + # line is blank + next; + } + + my @names = split(',', $line); + for my $name (@names) { + if ($name !~ /^[a-z\.\-\ ']*$/i) { + # Invalid character found + warn "Invalid character at line $. : $line\n"; + } + elsif ($name =~ /^\s*$/) { + warn "Blank field at line $. : $line\n"; + } + else { + foreach (@names) { + unless ($_ eq $name) { + $name_dict->{$name}->{$_} = 1; + } + } + } + } +} + +close $in_file; + +if ($opts->{d}) { + print "The dictionary contains: \n"; + for my $name (sort keys %$name_dict) { + print "$name => " . join(', ', sort keys %{$name_dict->{$name}}) . "\n"; + } + exit; +} + +my $lookup = lc $ARGV[1]; +unless ($name_dict->{$lookup}) { + print "No nicknames found for the name $ARGV[1]\n"; + exit; +} + +print "The nicknames for $ARGV[1] are: " . join(', ', sort keys %{$name_dict->{$lookup}}) . "\n"; + +sub usage { + print <<"EOF"; + +Usage: name_lookup.pl [options] + +Example: + + ./name_lookup.pl ./names.csv Dan + +Options: + -h Help. Print this screen. + -d Dump the name dictionary. + +EOF +} + diff --git a/app/vendor/nicknames/names-counter.pl b/app/vendor/nicknames/names-counter.pl new file mode 100644 index 000000000..3f89eb080 --- /dev/null +++ b/app/vendor/nicknames/names-counter.pl @@ -0,0 +1,120 @@ +#!/usr/bin/perl +# +# File: names-counter +# Abstract: Count the number of unique names in names.csv DB. +# Usage: names-counter [csv-data-file] +# Data Fmt: name,name,name... +# Author: Bill.Costa@unh.edu +# Version: 20110311 +# +# Notes: Perl style comments and blank lines in the input +# data stream are ignored. +# +#============================================================================== +# Setup and Global Definitions ============================================== +#============================================================================== + + #-- Pragmas --------------------------- +use warnings; # Save me from my own dumb errors. +use strict; # Keep things squeaky clean. + #-- Core Modules ---------------------- +use FindBin; # Where the heck are we'z? + + +#============================================================================== +# Subroutines =============================================================== +#============================================================================== + +sub commify + +# Commify a number; "Perl Cookbook" 2.17 + +{ + my $text = reverse($_[0]); + $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; + return(scalar(reverse($text))); +} + + +#============================================================================== +# Main Line ================================================================= +#============================================================================== + +#-------------------------------+ +# Get/find our input data file. | +#-------------------------------+ + +my $dataName = $ARGV[0]; +my $junk = $ARGV[1]; + +die("? $0: too many arguments after '$dataName'\n") if (defined($junk)); + +$dataName = 'names.csv' if (not defined($dataName)); + +my $inSpec; +if (-e $dataName) + { + $inSpec = $dataName; + } +else + { + $inSpec = "$FindBin::Bin/$dataName"; + die("? $0: cannot find input data\n_ $inSpec\n") + if (not -e $inSpec); + } + +open(IN, "<$inSpec") + or die("! $0: error opening $inSpec\n_ $!\n"); + + +#-------------------------------+ +# Parse each rec, stuff into a | +# hash. | +#-------------------------------+ + +my $NAME_RE = qr/^[a-z][a-z\.\-\ ]*$/i; +my %cat; + +while (defined(my $ln = )) + { + chomp($ln); + chop($ln) if ($ln =~ m/\x0D/); # Eat any trailing ^M too. + $ln =~ s/#.*$//; # Eat comments. + next if ($ln =~ m/^\s*$/); # Eat blank lines. + + foreach my $name (split(/,/, $ln)) + { + if ($name =~ m/^\s*$/) { warn("- blank field line $. <$ln>\n") } + elsif ($name !~ m/$NAME_RE/) { warn("- invalid char line $. <$ln>\n") } + else { $cat{$name}++; } + } + } + +close(IN); + + +#-------------------------------+ +# Report name count and show | +# most references. | +#-------------------------------+ + +my $nameCnt = scalar(keys(%cat)); +die("? $0: no names cataloged\n_ $inSpec\n_ ") if ($nameCnt <= 0); +print(commify($nameCnt), " unique names cataloged in $inSpec\n\n"); + +my $topLim = 5; +my $head = "Names referenced $topLim or more times:\n"; + +foreach my $name (sort { $cat{$b} <=> $cat{$a} } keys(%cat)) + { + last if ($cat{$name} < $topLim); + print($head); + $head = ''; + printf("%8i: %s\n", $cat{$name}, $name); + } + +die("? $0: probable data err; no names found with $topLim or more refs\n_ ") + if ($head ne ''); + + +#==[ EOF: names-counter ]== diff --git a/app/vendor/nicknames/names.csv b/app/vendor/nicknames/names.csv new file mode 100644 index 000000000..e466f00b0 --- /dev/null +++ b/app/vendor/nicknames/names.csv @@ -0,0 +1,1082 @@ +aaron,erin,ronnie,ron +abbie,abby,abigail +abe,abraham,abram +abednego,bedney +abel,ebbie,ab,abe,eb +abiel,ab +abigail,nabby,abby,gail +abijah,ab,bige +abner,ab +abraham,ab,abe +abram,ab +absalom,app,ab,abbie +ada,addy +adaline,delia,lena,dell,addy,ada +adam,edie,ade +addy,adele +adela,della +adelaide,heidi,adele,dell,addy,della +adelbert,del,albert,delbert,bert +adele,dell +adeline,delia,lena,dell,addy,ada +adelphia,philly,delphia,adele,dell,addy +adolphus,dolph,ado,adolph +adrian,rian +adrienne,adrian +agatha,aggy +agnes,inez,aggy,nessa +aileen,lena,allie +al,albert,bert,alex +alan,al +alanson,al,lanson +alastair,al +alazama,ali +albert,bert,al +alberta,bert,allie,bertie +aldo,al +aldrich,riche,rich +aleva,levy,leve +alex,alexandra,alexander +alexander,alex,al,sandy +alexandra,alex,sandy,alla,sandra +alexandria,drina,alexander,alla,sandra +alexis,lexi +alfonse,al +alfred,freddy,al,fred +alfreda,freddy,alfy,freda,frieda +algernon,algy +alice,lisa,elsie,allie +alicia,lisa,elsie,allie +aline,adeline +alison,ali +allan,al +allen,al +allisandra,allie +almena,mena,allie +almina,minnie +almira,myra +alonzo,lon,al,lonzo +alphinias,alphus +alverta,virdie,vert +alyssa,lissia,al,ally +alzada,zada +amanda,mandy,manda +ambrose,brose +amelia,amy,mel,millie,emily +amos,moses +anastasia,ana,stacy +anderson,andy +andrea,drea,rea,andrew +andrew,andy,drew +andy,andrew,drew +angela,angelica,angelina,angel,angeline,jane,angie +angelina,lina +ann,nana,nan,nancy,annie,nanny +anna,anne,ann,annie +anne,annie,nana,ann,nan,nanny,nancy +annette,anna,nettie +annie,ann,anna +anselm,ansel,selma,anse,ance +anthony,tony +antoinette,tony,netta,ann +antonia,tony,netta,ann +appoline,appy,appie +aquilla,quil,quillie +ara,belle,arry +arabella,ara,bella,arry,belle +arabelle,ara,bella,arry,belle +araminta,armida,middie,ruminta,minty +archibald,archie +archilles,kill,killis +ariadne,arie +arielle,arie +aristotle,telly +arizona,onie,ona +arlene,arly,lena +armanda,mandy +armena,mena,arry +armilda,milly +arminda,mindie +arminta,minite,minnie +arnold,arnie +art,arthur +artelepsa,epsey +artemus,art +arthur,art +arthusa,thursa +arzada,zaddi +asahel,asa +asaph,asa +asenath,sene,assene,natty +aubrey,bree +audrey,dee +august,gus +augusta,tina,aggy,gatsy,gussie +augustina,tina,aggy,gatsy,gussie +augustine,gus,austin,august +augustus,gus,austin,august +aurelia,ree,rilly,orilla,aurilla,ora +avarilla,rilla +azariah,riah,aze +bab,barby +babs,barby,barbara,bab +barbara,barby,babs,bab,bobbie +barbery,barbara +barbie,barbara +barnabas,barney +barney,barnabas +bart,bartholomew +bartholomew,bartel,bat,meus,bart,mees +barticus,bart +bazaleel,basil +bea,beatrice +beatrice,bea,trisha,trixie,trix +becca,beck +beck,becky +bedelia,delia,bridgit +belinda,belle,linda +bella,belle,arabella,isabella +ben,benjamin,bennie +benedict,bennie,ben +benjamin,benjy,jamie,bennie,ben +benjy,benjamin +bernard,barney,bernie,berney +berney,bernie +bert,bertie,bob,bobby +bertha,bert,birdie,bertie +bertram,bert +bess,bessie +beth,betsy,betty,elizabeth +bethena,beth,thaney +beverly,bev +bezaleel,zeely +biddie,biddy +bill,william,billy,robert,willie,fred +billy,william,robert,fred +blanche,bea +bob,rob,robert +bobby,rob,bob +boetius,bo +brad,bradford,ford +bradford,ford,brad +brady,brody +brenda,brandy +brian,bryan,bryant +bridget,bridie,biddy,bridgie,biddie +brittany,britt +broderick,ricky,brody,brady,rick +cal,calvin +caldonia,calliedona +caleb,cal +california,callie +calista,kissy +calpurnia,cally +calvin,vin,vinny,cal +cameron,ron,cam,ronny +camille,millie,cammie +campbell,cam +candace,candy,dacey +carlotta,lottie +carlton,carl +carmellia,mellia +carmon,charm,cammie,carm +carol,lynn,carrie,carolann,cassie,caroline,carole +carolann,carol,carole +caroline,lynn,carol,carrie,cassie,carole +carolyn,lynn,carrie,cassie +carrie,cassie +carthaette,etta,etty +casey,k.c. +casper,jasper +cassandra,sandy,cassie,sandra +cassie,cassandra +caswell,cass +catherine,kathy,katy,lena,kittie,kit,trina,cathy,kay,cassie +cathleen,kathy,katy,lena,kittie,kit,trina,cathy,kay,cassie +cathy,kathy,cathleen,catherine +cecilia,cissy,celia +cedric,ced,rick,ricky +celeste,lessie,celia +celinda,linda,lynn,lindy +charity,chat +charles,charlie,chuck,carl,chick +charlie,charles,chuck +charlotte,char,sherry,lottie,lotta +chauncey,chan +cher,sher +cheryl,sheryl +chesley,chet +chester,chet +chet,chester +chick,charlotte,caroline,chuck +chloe,clo +chris,christina,christopher,christine +christa,chris +christian,chris,kit +christiana,kris,kristy,ann,tina,christy,chris,crissy +christina,kris,kristy,tina,christy,chris,crissy +christine,kris,kristy,chrissy,tina,chris,crissy +christopher,chris,kit +christy,crissy +cicely,cilla +cinderella,arilla,rella,cindy,rilla +cindy,cinderlla +claire,clair,clare,clara +clara,clarissa +clare,clara +clarence,clare,clair +clarinda,clara +clarissa,cissy,clara +claudia,claud +cleatus,cleat +clement,clem +clementine,clement,clem +cliff,clifford,cliff +clifford,ford,cliff +clifton,tony,cliff +cole,colie +columbus,clum +con,conny +conrad,conny,con +constance,connie +cordelia,cordy,delia +corey,coco,cordy,ree +corinne,cora,ora +cornelia,nelly,cornie,nelia,corny,nelle +cornelius,conny,niel,corny,con +cory,coco,cordy,ree +courtney,curt,court +crystal,chris,tal,stal,crys +curt,curtis +curtis,curt +cy,cyrus +cynthia,cintha,cindy +cyrenius,swene,cy,serene,renius,cene +cyrus,cy +daisy,margaret +dal,dahl +dalton,dahl +dan,danny,daniel +daniel,dan,danny +danielle,ellie,dani +danny,daniel +daphne,daph,daphie +darlene,lena,darry +dave,david +davey,david +david,dave,day,davey +deanne,ann,dee +deb,deborah,debra +debbie,deb,debra,deborah,debby +debby,deb +debora,deb,debbie,debby +deborah,deb,debbie,debby +debra,deb,debbie +deidre,deedee +delbert,bert,del +delia,fidelia,cordelia,delius +delilah,lil,lila,dell,della +deliverance,delly,dilly,della +dell,della +della,adela,delilah,adelaide +delores,lolly,lola,della,dee,dell +delpha,philadelphia +delphine,delphi,del,delf +demaris,dea,maris,mary +demerias,dea,maris,mary +democrates,mock +denise,dennis +dennis,denny +dennison,denny +derrick,ricky,eric,rick +deuteronomy,duty +diana,dicey,didi,di +diane,dicey,didi,di +dicey,dicie +dick,rick,richard +dickson,dick +domenic,dom +dominic,dom +don,donald +donald,dony,donnie,don,donny +donnie,donald,donny +donny,donald +dorcus,darkey +dorinda,dorothea,dora +doris,dora +dorothea,doda,dora +dorothy,dortha,dolly,dot,dotty +dot,dotty +dotha,dotty +douglas,doug +drew,andrew +drusilla,silla +duncan,dunk +earnest,ernestine,ernie +eb,ebbie +ebenezer,ebbie,eben,eb +ed,eddie,eddy +eddie,eddy +edgar,ed,eddie,eddy +edith,edie,edye +edmond,ed,eddie,eddy +edmund,ed,eddie,ted,eddy,ned +edna,edny +eduardo,ed,eddie,eddy +edward,teddy,ed,ned,ted,eddy,eddie +edwin,ed,eddie,win,eddy,ned +edwina,edwin +edyth,edie,edye +edythe,edie,edye +egbert,bert,burt +eighta,athy +eileen,helen +elaine,lainie,helen +elbert,albert +elbertson,elbert,bert +eleanor,lanna,nora,nelly,ellie,elaine,ellen,lenora +eleazer,lazar +elena,helen +elias,eli,lee,lias +elijah,lige,eli +eliphalel,life +eliphalet,left +elisa,lisa +elisha,lish,eli +eliza,elizabeth +elizabeth,libby,lisa,lib,lizzie,eliza,betsy,liza,betty,bessie,bess,beth,liz +ella,ellen +ellen,nellie,nell,helen +ellender,nellie,ellen,helen +ellie,elly +ellswood,elsey +elminie,minnie +elmira,ellie,elly,mira +elnora,nora +eloise,heloise,louise +elouise,louise +elsie,elsey +elswood,elsey +elvira,elvie +elwood,woody +elysia,lisa +elze,elsey +emanuel,manuel,manny +emeline,em,emmy,emma,milly,emily +emil,emily +emily,emmy,millie,emma,mel +emma,emmy +epaphroditius,dite,ditus,eppa,dyche,dyce +ephraim,eph +erasmus,raze,rasmus +eric,rick,ricky +ernest,ernie +ernestine,teeny,ernest,tina,erna +erwin,irwin +eseneth,senie +essy,es +estella,essy,stella +estelle,essy,stella +esther,hester,essie +eudicy,dicey +eudora,dora +eudoris,dossie,dosie +eugene,gene +eunice,nicie +euphemia,effie,effy +eurydice,dicey +eustacia,stacia,stacy +eva,eve +evaline,eva,lena,eve +evangeline,ev,evan,vangie +evelyn,evelina,ev,eve +experience,exie +ezekiel,zeke,ez +ezideen,ez +ezra,ez +faith,fay +felicia,fel,felix,feli +felicity,flick,tick +feltie,felty +ferdinand,freddie,freddy,ferdie,fred +ferdinando,nando,ferdie,fred +fidelia,delia +flo,florence +flora,florence +florence,flossy,flora,flo +floyd,lloyd +fran,frannie +frances,sis,cissy,frankie,franniey,fran,francie,frannie,fanny +francie,francine +francine,franniey,fran,frannie,francie +francis,fran,frankie,frank +frank,franklin +frankie,frank,francis +franklin,fran,frank +franklind,frank +fred,freddy,frederick +freda,frieda +frederica,frederick +frederick,freddie,freddy,fritz,fred +fredericka,freddy,ricka,freda,frieda +frieda,freddie,freddy,fred +gabby,gabriella,gabe,gabrielle +gabe,gabriel +gabriel,gabe,gabby +gabriella,ella,gabby +gabrielle,ella,gabby +genevieve,jean,eve,jenny +geoff,geoffrey,jeffrey,jeff +geoffrey,geoff,jeff +george,jorge,georgiana +georgia,george,georgiana +gerald,gerry,jerry +geraldine,gerry,gerrie,jerry,dina +gerhardt,gay +gerrie,geraldine +gerry,gerald,geraldine,jerry +gert,gertie +gertie,gertrude +gertrude,gertie,gert,trudy +gil,gilbert +gilbert,bert,gil,wilber +gloria,glory +governor,govie +greenberry,green,berry +gregory,greg +gretchen,margaret +griselda,grissel +gum,monty +gus,gussie +gustavus,gus +gwen,gwendolyn,wendy +gwendolyn,gwen,wendy +hamilton,ham +hannah,nan,nanny,anna +harold,hal,harry +harriet,hattie +harry,harold,henry +haseltine,hassie +heather,hetty +helen,lena,ella,ellen,ellie +helena,eileen,lena,nell,nellie,eleanor,elaine,ellen,aileen +helene,lena,ella,ellen,ellie +heloise,lois,eloise,elouise +henrietta,hank,etta,etty,retta,nettie +henry,hank,hal,harry +hephsibah,hipsie +hepsibah,hipsie +herb,herbert +herbert,bert,herb +herman,harman,dutch +hermione,hermie +hester,hessy,esther,hetty +hezekiah,hy,hez,kiah +hiram,hy +honora,honey,nora,norry,norah +hopkins,hopp,hop +horace,horry +hortense,harty,tensey +hosea,hosey,hosie +howard,hal,howie +hubert,bert,hugh,hub +ian,john +ignatius,natius,iggy,nate,nace +ignatzio,naz,iggy,nace +immanuel,manuel,emmanuel +india,indie,indy +inez,agnes +iona,onnie +irene,rena +irvin,irving +irving,irv +irwin,erwin +isaac,ike,zeke +isabel,tibbie,bell,nib,belle,bella,nibby,ib,issy +isabella,tibbie,nib,belle,bella,nibby,ib,issy +isabelle,tibbie,nib,belle,bella,nibby,ib,issy +isadora,issy,dora +isaiah,zadie,zay +isidore,izzy +iva,ivy +ivan,john +jackson,jack +jacob,jaap,jake,jay +jacobus,jacob +jacqueline,jackie,jack +jahoda,hody,hodie,hoda +james,jimmy,jim,jamie,jimmie,jem +jamie,james +jane,janie,jessie,jean,jennie +janet,jan,jessie +janice,jan +jannett,nettie +jasper,jap,casper +jayme,jay +jean,jane,jeannie +jeanette,jessie,jean,janet,nettie +jeanne,jane,jeannie +jeb,jebadiah +jedediah,dyer,jed,diah +jedidiah,jed +jeff,geoffrey,jeffrey +jefferey,jeff +jefferson,sonny,jeff +jeffrey,geoff,jeff +jehiel,hiel +jehu,hugh,gee +jemima,mima +jennet,jessie,jenny +jennifer,jennie +jenny,jennifer +jeremiah,jereme,jerry +jerita,rita +jerry,jereme,geraldine +jessica,jessie +jessie,jane,jess,janet +jim,jimmie +jincy,jane +jinsy,jane +joan,jo,nonie +joann,jo +joanna,hannah,jody,jo,joan +joanne,jo +jody,jo +joe,joseph,joey +joey,joseph +johanna,jo +johannah,hannah,jody,joan,nonie +johannes,jonathan,john,johnny +john,jack,johnny,jock +jon,john,nathan +jonathan,john,nathan +joseph,jody,jos,joe,joey +josephine,fina,jody,jo,josey,joey +josetta,jettie +josey,josophine +josh,joshua +joshua,jos,josh +josiah,jos +joyce,joy +juanita,nita,nettie +judah,juder,jude +judith,judie,juda,judy,judi,jude +judson,sonny,jud +judy,judith +julia,julie,jill +julian,jule +julias,jule +julie,julia,jule +june,junius +junior,junie,june,jr +justin,justus,justina +karonhappuck,karon,karen,carrie,happy +kasey,k.c. +katarina,catherine,tina +kate,kay +katelin,kay,kate,kaye +katelyn,kay,kate,kaye +katherine,kathy,katy,lena,kittie,kaye,kit,trina,cathy,kay,kate,cassie +kathleen,kathy,katy,lena,kittie,kit,trina,cathy,kay,cassie +kathryn,kathy +katy,kathy +kayla,kay +ken,kenneth +kendall,ken,kenny +kendra,kenj,kenji,kay,kenny +kendrick,ken,kenny +kenneth,ken,kenny,kendrick +kenny,ken,kenneth +kent,ken,kenny,kendrick +keziah,kizza,kizzie +kim,kimberly,kimberley +kimberley,kim +kimberly,kim +kingsley,king +kingston,king +kit,kittie +kris,chris +kristel,kris +kristen,chris +kristin,chris +kristine,kris,kristy,tina,christy,chris,crissy +kristopher,chris,kris +kristy,chris +lafayette,laffie,fate +lamont,monty +laodicia,dicy,cenia +larry,laurence,lawrence +lauren,ren,laurie +laurence,lorry,larry,lon,lonny,lorne +laurinda,laura,lawrence +lauryn,laurie +laveda,veda +laverne,vernon,verna +lavina,vina,viney,ina +lavinia,vina,viney,ina +lavonia,vina,vonnie,wyncha,viney +lavonne,von +lawrence,lorry,larry,lon,lonny,lorne +leanne,lea,annie +lecurgus,curg +lemuel,lem +lena,ellen +lenora,nora,lee +leo,leon +leonard,lineau,leo,leon,len,lenny +leonidas,lee,leon +leonora,nora,nell,nellie +leonore,nora,honor,elenor +leroy,roy,lee,l.r. +les,lester +leslie,les +lester,les +letitia,tish,titia,lettice,lettie +levi,lee +levicy,vicy +levone,von +lib,libby +lidia,lyddy +lil,lilly,lily +lillah,lil,lilly,lily,lolly +lillian,lil,lilly,lolly +lilly,lily +lincoln,link +linda,lindy,lynn +lindy,lynn +lionel,leon +lisa,lizzie,alice,liz,melissa +littleberry,little,berry,l.b. +liz,elizabeth +lizzie,elizabeth,liz +lois,lou,louise +lon,lonzo +lorenzo,loren +loretta,etta,lorrie,retta +lorraine,lorrie +lotta,lottie +lou,louis,lu +louis,lewis,louise,louie,lou +louisa,eliza,lou,lois +louise,eliza,lou,lois +louvinia,vina,vonnie,wyncha,viney +lucas,luke +lucia,lucy,lucius +lucias,luke +lucille,cille,lu,lucy,lou +lucina,sinah +lucinda,lu,lucy,cindy,lou +lucretia,creasey +lucy,lucinda +luella,lula,ella,lu +luke,lucas +lunetta,nettie +lurana,lura +luther,luke +lydia,lyddy +lyndon,lindy,lynn +mabel,mehitabel,amabel +mac,mc +mack,mac,mc +mackenzie,kenzy,mac,mack +maddy,madelyn,madeline,madge +madeline,maggie,lena,magda,maddy,madge +madie,madeline,madelyn +madison,mattie,maddy +magdalena,maggie,lena +magdelina,lena,magda,madge +mahala,hallie +malachi,mally +malcolm,mac,mal,malc +malinda,lindy +manda,mandy +mandy,amanda +manerva,minerva,nervie,eve,nerva +manny,manuel +manoah,noah +manola,nonnie +manuel,emanuel,manny +marcus,mark +margaret,maggie,meg,peg,midge,margy,margie,madge,peggy,maggy,marge,daisy,margery,gretta,rita +margaretta,maggie,meg,peg,midge,margie,madge,peggy,marge,daisy,margery,gretta,rita +margarita,maggie,meg,metta,midge,greta,megan,maisie,madge,marge,daisy,peggie,rita,margo +marge,margery,margaret,margaretta +margie,marjorie,margie +marguerite,peggy +margy,marjorie +mariah,mary,maria +marian,marianna,marion +marie,mae +marietta,mariah,mercy,polly,may,molly,mitzi,minnie,mollie,mae,maureen,marion,marie,mamie,mary,maria +marilyn,mary +marion,mary +marissa,rissa +marjorie,margy,margie +marsha,marcie,mary +martha,marty,mattie,mat,patsy,patty +martin,marty +martina,tina +martine,tine +marv,marvin +marvin,marv +mary,mamie,molly,mae,polly,mitzi +mat,mattie +mathilda,tillie,patty +matilda,tilly,maud,matty +matt,mathew,matthew +matthew,thys,matt,thias,mattie,matty +matthias,thys,matt,thias +maud,middy +maureen,mary +maurice,morey +mavery,mave +mavine,mave +maxine,max +may,mae +mckenna,ken,kenna,meaka +medora,dora +megan,meg +mehitabel,hetty,mitty,mabel,hitty +melanie,mellie +melchizedek,zadock,dick +melinda,linda,mel,lynn,mindy,lindy +melissa,lisa,mel,missy,milly,lissa +mellony,mellia +melody,lodi +melvin,mel +melvina,vina +mercedes,merci,sadie,mercy +merv,mervin +mervyn,merv +micajah,cage +michael,micky,mike,micah,mick +michelle,mickey +mick,micky +mike,micky,mick,michael +mildred,milly +millicent,missy,milly +minerva,minnie +minnie,wilhelmina +miranda,randy,mandy,mira +miriam,mimi,mitzi,mitzie +missy,melissa +mitch,mitchell +mitchell,mitch +mitzi,mary,mittie,mitty +mitzie,mittie,mitty +monet,nettie +monica,monna,monnie +monteleon,monte +montesque,monty +montgomery,monty,gum +monty,lamont +morris,morey +mortimer,mort +moses,amos,mose,moss +muriel,mur +myrtle,myrt,myrti,mert +nadine,nada,deedee +nancy,ann,nan,nanny +naomi,omi +napoleon,nap,nappy,leon +natalie,natty,nettie +natasha,tasha,nat +nathan,nate,nat +nathaniel,than,nathan,nate,nat,natty +nelle,nelly +nelson,nels +newt,newton +nicholas,nick,claes,claas +nick,nik,nicholas +nickie,nicholas +nicodemus,nick +nicole,nole,nikki,cole +nik,nick +nora,nonie +norbert,bert,norby +nowell,noel +obadiah,dyer,obed,obie,diah +obedience,obed,beda,beedy,biddie +obie,obediah +octavia,tave,tavia +odell,odo +olive,nollie,livia,ollie +oliver,ollie +olivia,nollie,livia,ollie +ollie,oliver +onicyphorous,cyphorus,osaforus,syphorous,one,cy,osaforum +orilla,rilly,ora +orlando,roland +orphelia,phelia +ossy,ozzy +oswald,ozzy,waldo,ossy +otis,ode,ote +ozzy,oswald +pamela,pam +pandora,dora +parmelia,amelia,milly,melia +parthenia,teeny,parsuny,pasoonie,phenie +pat,patrick,pat,patricia +patience,pat,patty +patricia,tricia,pat,patsy,patty +patrick,pate,peter,pat,patsy,paddy +patsy,patty +patty,patricia +paul,polly,paula,pauline +paula,polly,lina +paulina,polly,lina +pauline,polly +peg,peggy +pelegrine,perry +penelope,penny +percival,percy +peregrine,perry +permelia,melly,milly,mellie +pernetta,nettie +persephone,seph,sephy +pete,peter +peter,pete,pate +petronella,nellie +pheney,josephine +pheriba,pherbia,ferbie +phil,phillip,philip +philadelphia,delphia +philander,fie +philetus,leet,phil +philinda,linda,lynn,lindy +philip,phil +philipina,phoebe,penie +phillip,phil +philly,delphia +philomena,menaalmena +phoebe,fifi +pinckney,pink +pleasant,ples +pocahontas,pokey +posthuma,humey +prescott,scotty,scott,pres +priscilla,prissy,cissy,cilla +providence,provy +prudence,prue,prudy +prudy,prudence +rachel,shelly +rafaela,rafa +ramona,mona +randolph,dolph,randy +raphael,ralph +ray,raymond +raymond,ray +reba,beck,becca +rebecca,beck,becca,reba,becky +reg,reggie +reggie,reginald +regina,reggie,gina +reginald,reggie,naldo,reg,renny +relief,leafa +reuben,rube +reynold,reginald +rhoda,rodie +rhodella,della +rhyna,rhynie +ricardo,rick,ricky +rich,dick,rick,riche,richard +richard,dick,dickon,dickie,dicky,rick,rich,ricky +richie,richard +rick,ricky +ricky,dick,rich +robert,hob,hobkin,dob,rob,bobby,dobbin,bob +roberta,robbie,bert,bobbie,birdie,bertie +roderick,rod,erick,rickie +rodger,roge,bobby,hodge,rod,robby,rupert,robin +roger,roge,bobby,hodge,rod,robby,rupert,robin +roland,rollo,lanny,orlando,rolly +ron,ronald,ronnie,ronny +ronald,naldo,ron,ronny +ronnie,ronald +ronny,ronald +rosa,rose +rosabel,belle,roz,rosa,rose +rosabella,belle,roz,rosa,rose +rosalinda,linda,roz,rosa,rose +rosalyn,linda,roz,rosa,rose +roscoe,ross +rose,rosie +roseann,rose,ann,rosie,roz +roseanna,rose,ann,rosie,roz +roseanne,ann +rosina,sina +roxane,rox,roxie +roxanna,roxie,rose,ann +roxanne,roxie,rose,ann +roz,rosalyn +rube,reuben +rudolph,dolph,rudy,olph,rolf +rudolphus,dolph,rudy,olph,rolf +rudy,rudolph +russ,russell +russell,russ,rusty +rusty,russell +ryan,ry +sabrina,brina +salome,loomie +salvador,sal +sam,sammy,samuel +samantha,sammy,sam,mantha +sammy,samuel +sampson,sam +samson,sam +samuel,sammy,sam +samyra,myra +sandra,sandy,cassandra +sandy,sandra +sanford,sandy +sarah,sally,sadie +sarilla,silla +savannah,vannie,anna +scott,scotty,sceeter,squat,scottie +sebastian,sebby,seb +selma,anselm +serena,rena +serilla,rilla +seymour,see,morey +shaina,sha,shay +sharon,sha,shay +sheila,cecilia +sheldon,shelly +shelton,tony,shel,shelly +sheridan,dan,danny,sher +sheryl,sher +shirley,sherry,lee,shirl +sibbilla,sybill,sibbie,sibbell +sidney,syd,sid +sigfired,sid +sigfrid,sid +sigismund,sig +silas,si +silence,liley +silvester,vester,si,sly,vest,syl +simeon,si,sion +simon,si,sion +sly,sylvester +smith,smitty +socrates,crate +solomon,sal,salmon,sol,solly,saul,zolly +sondra,dre,sonnie +sophia,sophie +sophronia,frona,sophia,fronia +stephan,steve +stephanie,stephen,stephie,annie,steph +stephen,steve,steph +steve,stephen,steven +steven,steve,steph +stuart,stu +sue,susie,susan +sullivan,sully,van +sully,sullivan +susan,hannah,susie,sue,sukey,suzie +susannah,hannah,susie,sue,sukey +susie,suzie +suzanne,suki,sue,susie +sybill,sibbie +sydney,sid +sylvanus,sly,syl +sylvester,sy,sly,vet,syl,vester,si,vessie +tabby,tabitha +tabitha,tabby +tamarra,tammy +tanafra,tanny +tasha,tash,tashie +ted,teddy +temperance,tempy +terence,terry +teresa,terry +terry,terence +tess,teresa,theresa +tessa,teresa,theresa +thad,thaddeus +thaddeus,thad +theo,theodore +theodora,dora +theodore,theo,ted,teddy +theodosia,theo,dosia,theodosius +theophilus,ophi +theotha,otha +theresa,tessie,thirza,tessa,terry,tracy,tess,thursa +thom,thomas,tommy,tom +thomas,thom,tommy,tom +thomasa,tamzine +tiffany,tiff,tiffy +tilford,tillie +tim,timothy,timmy +timmy,timothy +timothy,tim,timmy +tina,christina +tobias,bias,toby +tom,thomas,tommy +tommy,thomas +tony,anthony +tranquilla,trannie,quilla +trisha,patricia +trix,trixie +trudy,gertrude +tryphena,phena +unice,eunice,nicie +uriah,riah +ursula,sulie,sula +valentina,felty,vallie,val +valentine,felty +valeri,val +valerie,val +vanburen,buren +vandalia,vannie +vanessa,essa,vanna,nessa +vernisee,nicey +veronica,vonnie,ron,ronna,ronie,frony,franky,ronnie +vic,vicki,victor,vicky +vicki,vicky,victoria +vickie,victoria +vicky,victoria +victor,vic +victoria,torie,vic,vicki,tory,vicky +vin,vinny +vince,vinnie +vincent,vic,vince,vinnie,vin,vinny +vincenzo,vic,vinnie,vin,vinny +vinson,vinny +viola,ola,vi +violetta,lettie +virginia,jane,jennie,ginny,virgy,ginger +vivian,vi,viv +waldo,ozzy,ossy +wallace,wally +wally,walt +walter,wally,walt +washington,wash +webster,webb +wendy,wen +wilber,will,bert +wilbur,willy,willie +wilda,willie +wilfred,will,willie,fred +wilhelmina,mina,wilma,willie,minnie +will,bill,willie,wilbur,fred +william,willy,bell,bela,bill,will,billy,willie +willie,william,fred +willis,willy,bill +wilma,william,billiewilhelm +wilson,will,willy,willie +winfield,field,winny,win +winifred,freddie,winnie,winnet +winnie,winnifred +winnifred,freddie,freddy,winny,winnie,fred +winny,winnifred +winton,wint +woodrow,woody,wood,drew +yeona,onie,ona +yulan,lan,yul +yvonne,vonna +zach,zachariah +zachariah,zachy,zach,zeke +zebedee,zeb +zedediah,dyer,zed,diah +zephaniah,zeph diff --git a/app/vendor/nicknames/python-parser.py b/app/vendor/nicknames/python-parser.py new file mode 100644 index 000000000..1a06384b8 --- /dev/null +++ b/app/vendor/nicknames/python-parser.py @@ -0,0 +1,31 @@ +import collections +import csv +import operator +import functools + +class NameDenormalizer(object): + def __init__(self, filename=None): + filename = filename or 'names.csv' + lookup = collections.defaultdict(list) + with open(filename) as f: + reader = csv.reader(f) + for line in reader: + matches = set(line) + for match in matches: + lookup[match].append(matches) + self.lookup = lookup + + def __getitem__(self, name): + name = name.lower() + if name not in self.lookup: + raise KeyError(name) + names = functools.reduce(operator.or_, self.lookup[name]) + if name in names: + names.remove(name) + return names + + def get(self, name, default=None): + try: + return self[name] + except KeyError: + return default