Trees | Indices | Help |
|
---|
|
1 # 2 # Gramps - a GTK+/GNOME based genealogy program 3 # 4 # Copyright (C) 2000-2005 Donald N. Allingham 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; either version 2 of the License, or 9 # (at your option) any later version. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with this program; if not, write to the Free Software 18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 # 20 21 # $Id: genderstats.py 10103 2008-02-24 13:55:55Z acraphae $ 22 23 """ 24 Gender statistics kept in GRAMPS database. 25 """ 26 27 #------------------------------------------------------------------------- 28 # 29 # GRAMPS modules 30 # 31 #------------------------------------------------------------------------- 32 from gen.lib.person import Person 33 34 #------------------------------------------------------------------------- 35 # 36 # 37 # 38 #-------------------------------------------------------------------------40 """ 41 Class for keeping track of statistics related to Given Name vs. Gender. 42 43 This allows the tracking of the liklihood of a person's given name 44 indicating the gender of the person. 45 """ 51 54 5811560 return name.split (' ')[0].replace ('?', '')61 6668 if not person: 69 return 70 # Let the Person do their own counting later 71 72 name = self._get_key (person) 73 if not name: 74 return 75 76 gender = person.get_gender() 77 (male, female, unknown) = self.name_stats (name) 78 if not undo: 79 increment = 1 80 else: 81 increment = -1 82 83 if gender == Person.MALE: 84 male += increment 85 elif gender == Person.FEMALE: 86 female += increment 87 elif gender == Person.UNKNOWN: 88 unknown += increment 89 90 self.stats[name] = (male, female, unknown) 91 return92 9597 name = self._get_key_from_name (name) 98 if not name or not self.stats.has_key (name): 99 return Person.UNKNOWN 100 101 (male, female, unknown) = self.stats[name] 102 if unknown == 0: 103 if male and not female: 104 return Person.MALE 105 if female and not male: 106 return Person.FEMALE 107 108 if male > (2 * female): 109 return Person.MALE 110 111 if female > (2 * male): 112 return Person.FEMALE 113 114 return Person.UNKNOWN
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Mar 9 21:53:36 2008 | http://epydoc.sourceforge.net |