Reworked rel_es.py as evolution of some uncompleted code for 3.2 that never made it to svn
svn: r20339
This commit is contained in:
parent
29a4046844
commit
eee0f0283a
@ -4,6 +4,7 @@
|
||||
#
|
||||
# Copyright (C) 2003-2005 Donald N. Allingham
|
||||
# Copyright (C) 2008 Brian G. Matherly
|
||||
# Copyright (C) 2005-2012 Julio Sanchez
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -19,10 +20,9 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# Written by Julio Sanchez <julio.sanchez@gmail.com>
|
||||
|
||||
# $Id$
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
"""
|
||||
Spanish-specific classes for relationships.
|
||||
"""
|
||||
@ -33,6 +33,9 @@ Spanish-specific classes for relationships.
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
import gen.lib
|
||||
MALE = gen.lib.Person.MALE
|
||||
FEMALE = gen.lib.Person.FEMALE
|
||||
UNKNOWN = gen.lib.Person.UNKNOWN
|
||||
import Relationship
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -42,30 +45,30 @@ import Relationship
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
_level_name_male = [ "", "primero", "segundo", "tercero", "cuarto", "quinto",
|
||||
"sexto", "séptimo", "octavo", "noveno", "décimo", "undécimo",
|
||||
"duodécimo", "decimotercero", "decimocuarto", "decimoquinto",
|
||||
"decimosexto", "decimoséptimo", "decimoctavo", "decimonono",
|
||||
"vigésimo", ]
|
||||
"sexto", "séptimo", "octavo", "noveno", "décimo", "undécimo",
|
||||
"duodécimo", "decimotercero", "decimocuarto", "decimoquinto",
|
||||
"decimosexto", "decimoséptimo", "decimoctavo", "decimonono",
|
||||
"vigésimo" ]
|
||||
|
||||
# Short forms (in apocope) used before names
|
||||
_level_name_male_a = [ "", "primer", "segundo", "tercer", "cuarto", "quinto",
|
||||
"sexto", "séptimo", "octavo", "noveno", "décimo", "undécimo",
|
||||
"duodécimo", "decimotercer", "decimocuarto", "decimoquinto",
|
||||
"decimosexto", "decimoséptimo", "decimoctavo", "decimonono",
|
||||
"vigésimo"]
|
||||
"sexto", "séptimo", "octavo", "noveno", "décimo", "undécimo",
|
||||
"duodécimo", "decimotercer", "decimocuarto", "decimoquinto",
|
||||
"decimosexto", "decimoséptimo", "decimoctavo", "decimonono",
|
||||
"vigésimo" ]
|
||||
|
||||
_level_name_female = [ "", "primera", "segunda", "tercera", "cuarta", "quinta",
|
||||
"sexta", "séptima", "octava", "novena", "décima", "undécima",
|
||||
"duodécima", "decimotercera", "decimocuarta", "decimoquinta",
|
||||
"decimosexta", "decimoséptima", "decimoctava", "decimonona",
|
||||
"vigésima"]
|
||||
"sexta", "séptima", "octava", "novena", "décima", "undécima",
|
||||
"duodécima", "decimotercera", "decimocuarta", "decimoquinta",
|
||||
"decimosexta", "decimoséptima", "decimoctava", "decimonona",
|
||||
"vigésima" ]
|
||||
|
||||
_level_name_plural = [ "", "primeros", "segundos", "terceros", "cuartos",
|
||||
"quintos", "sextos", "séptimos", "octavos", "novenos",
|
||||
"décimos", "undécimos", "duodécimos", "decimoterceros",
|
||||
"decimocuartos", "decimoquintos", "decimosextos",
|
||||
"decimoséptimos", "decimoctavos", "decimononos",
|
||||
"vigésimos", ]
|
||||
"quintos", "sextos", "séptimos", "octavos", "novenos",
|
||||
"décimos", "undécimos", "duodécimos", "decimoterceros",
|
||||
"decimocuartos", "decimoquintos", "decimosextos",
|
||||
"decimoséptimos", "decimoctavos", "decimononos",
|
||||
"vigésimos" ]
|
||||
|
||||
# This plugin tries to be flexible and expect little from the following
|
||||
# tables. Ancestors are named from the list for the first generations.
|
||||
@ -73,14 +76,41 @@ _level_name_plural = [ "", "primeros", "segundos", "terceros", "cuartos",
|
||||
# i.e. bisabuelo is 'segundo abuelo' and so on, that has been the
|
||||
# traditional way in Spanish. When we run out of ordinals we resort to
|
||||
# N-ésimo notation, that is sort of understandable if in context.
|
||||
_parents_level = [ "", "padres", "abuelos", "bisabuelos", "tatarabuelos",
|
||||
"trastatarabuelos"]
|
||||
# 'trastatarabuelo' is not in DRAE, but is well known
|
||||
_parents_level = [ "", "padres",
|
||||
"abuelos",
|
||||
"bisabuelos",
|
||||
"tatarabuelos",
|
||||
"trastatarabuelos" ]
|
||||
|
||||
_father_level = [ "", "padre", "abuelo", "bisabuelo", "tatarabuelo",
|
||||
"trastatarabuelo"]
|
||||
_father_level = [ "", "padre%(inlaw)s",
|
||||
"abuelo%(inlaw)s",
|
||||
"bisabuelo%(inlaw)s",
|
||||
"tatarabuelo%(inlaw)s",
|
||||
"trastatarabuelo%(inlaw)s"]
|
||||
|
||||
_mother_level = [ "", "madre", "abuela", "bisabuela", "tatarabuela",
|
||||
"trastatarabuela"]
|
||||
_mother_level = [ "", "madre%(inlaw)s",
|
||||
"abuela%(inlaw)s",
|
||||
"bisabuela%(inlaw)s",
|
||||
"tatarabuela%(inlaw)s",
|
||||
"trastatarabuela%(inlaw)s"]
|
||||
|
||||
# step-relationships can't be handled as in English
|
||||
# Notice that the traditional lack of divorce in Catholic, Spanish-speaking, countries has resulted
|
||||
# in a scarcity of terms to describe these relationships since only death of a spouse would let the
|
||||
# other marry again. Divorce is common now, so these relationships abound, but history has left us
|
||||
# without support in the language. So, in this case, we will be more liberal than in other cases and
|
||||
# or coin a few new words or accept others that seem to have some use, but always patterned
|
||||
# after the style of the well-documented cases, so that users can intuitively guess their meaning.
|
||||
# Notice that "that relationship does not exist in Spanish" is not a valid objection. Once the Gramps
|
||||
# core has computed a relationship, it *has* to be named *somehow*. The only alternative is to change
|
||||
# the Gramps core so that it does not find relationships that cannot be named in Spanish.
|
||||
|
||||
_step_father_level = [ "", "padrastro%(inlaw)s",
|
||||
"abuelastro%(inlaw)s" ]
|
||||
|
||||
_step_mother_level = [ "", "madrastra%(inlaw)s",
|
||||
"abuelastra%(inlaw)s" ]
|
||||
|
||||
# Higher-order terms (after trastatarabuelo) on this list are not standard,
|
||||
# but then there is no standard naming scheme at all for this in Spanish.
|
||||
@ -97,21 +127,93 @@ _mother_level = [ "", "madre", "abuela", "bisabuela", "tatarabuela",
|
||||
# "trastatarabuela", "pentabuela", "hexabuela",
|
||||
# "heptabuela", "octabuela", "eneabuela", "decabuela"]
|
||||
|
||||
_son_level = [ "", "hijo", "nieto", "bisnieto",
|
||||
"tataranieto", "trastataranieto", ]
|
||||
# DRAE defines cuadrinieto as well, with the same meaning as chozno
|
||||
# trastataranieto is in use too, but is not in DRAE
|
||||
# DRAE also registers bizchozno and bischozno, but prefers bichozno
|
||||
_son_level = [ "", "hijo%(inlaw)s",
|
||||
"nieto%(inlaw)s",
|
||||
"bisnieto%(inlaw)s",
|
||||
"tataranieto%(inlaw)s",
|
||||
"chozno%(inlaw)s",
|
||||
"bichozno%(inlaw)s" ]
|
||||
|
||||
_daughter_level = [ "", "hija", "nieta", "bisnieta",
|
||||
"tataranieta", "trastataranieta", ]
|
||||
# Though "abuelastro" is in DRAE, "nietastro" isn't
|
||||
_step_son_level = [ "", "hijastro%(inlaw)s",
|
||||
"nietastro%(inlaw)s" ]
|
||||
|
||||
_sister_level = [ "", "hermana", "tía", "tía abuela",
|
||||
"tía bisabuela", ]
|
||||
_daughter_level = [ "", "hija%(inlaw)s",
|
||||
"nieta%(inlaw)s",
|
||||
"bisnieta%(inlaw)s",
|
||||
"tataranieta%(inlaw)s",
|
||||
"chozna%(inlaw)s",
|
||||
"bichozna%(inlaw)s" ]
|
||||
|
||||
_brother_level = [ "", "hermano", "tío", "tío abuelo",
|
||||
"tío bisabuelo", ]
|
||||
_step_daughter_level = [ "", "hijastra%(inlaw)s",
|
||||
"nietastra%(inlaw)s" ]
|
||||
|
||||
_nephew_level = [ "", "sobrino", "sobrino nieto", "sobrino bisnieto", ]
|
||||
_sister_level = [ "", "hermana%(inlaw)s",
|
||||
"tía%(inlaw)s",
|
||||
"tía abuela%(inlaw)s",
|
||||
"tía bisabuela%(inlaw)s",
|
||||
"tía tatarabuela%(inlaw)s" ]
|
||||
|
||||
# Tiastro/tiastra aren't in DRAE
|
||||
_step_sister_level = [ "", "hermanastra%(inlaw)s",
|
||||
"tiastra%(inlaw)s",
|
||||
"tía abuelastra%(inlaw)s" ]
|
||||
|
||||
_brother_level = [ "", "hermano%(inlaw)s",
|
||||
"tío%(inlaw)s",
|
||||
"tío abuelo%(inlaw)s",
|
||||
"tío bisabuelo%(inlaw)s",
|
||||
"tío tatarabuelo%(inlaw)s" ]
|
||||
|
||||
_step_brother_level = [ "", "hermanastro%(inlaw)s",
|
||||
"tiastro%(inlaw)s",
|
||||
"tío abuelastro%(inlaw)s" ]
|
||||
|
||||
_nephew_level = [ "", "sobrino%(inlaw)s",
|
||||
"sobrino nieto%(inlaw)s",
|
||||
"sobrino bisnieto%(inlaw)s",
|
||||
"sobrino tataranieto%(inlaw)s",
|
||||
"sobrino chozno%(inlaw)s",
|
||||
"sobrino bichozno%(inlaw)s" ]
|
||||
|
||||
# Nether are sobrinastro/sobrinastra
|
||||
_step_nephew_level = [ "", "sobrinastro%(inlaw)s",
|
||||
"sobrino nietastro%(inlaw)s" ]
|
||||
|
||||
_niece_level = [ "", "sobrina%(inlaw)s",
|
||||
"sobrina nieta%(inlaw)s",
|
||||
"sobrina bisnieta%(inlaw)s",
|
||||
"sobrina tataranieta%(inlaw)s",
|
||||
"sobrina chozna%(inlaw)s",
|
||||
"sobrina bichozna%(inlaw)s" ]
|
||||
|
||||
_step_niece_level = [ "", "sobrinastra%(inlaw)s",
|
||||
"sobrina nietastra%(inlaw)s" ]
|
||||
|
||||
_children_level = [ "", "hijos",
|
||||
"nietos",
|
||||
"bisnietos",
|
||||
"tataranietos",
|
||||
"choznos",
|
||||
"bichoznos" ]
|
||||
|
||||
_siblings_level = [ "",
|
||||
"hermanos/as", "tíos/tías",
|
||||
"tíos abuelos/tías abuelas", "tíos bisabuelos/tías bisabuelas",
|
||||
"tíos tatarabuelos/tías tatarabuelas", "tíos trastatarabuelos/tías trastatarabuelas" ]
|
||||
|
||||
_nephews_nieces_level = [ "",
|
||||
"hermanos/as",
|
||||
"sobrinos/as",
|
||||
"sobrinos nietos/sobrinas nietas",
|
||||
"sobrinos bisnietos/sobrinas bisnietas",
|
||||
"sobrinos tataranietos/sobrinas tataranietas",
|
||||
"sobrinos choznos/sobrinas choznas",
|
||||
"sobrinos bichoznos/sobrinas bichoznas" ]
|
||||
|
||||
_niece_level = [ "", "sobrina", "sobrina nieta", "sobrina bisnieta", ]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -126,197 +228,580 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_male_cousin(self, level):
|
||||
if level < len(_level_name_male):
|
||||
return "primo %s" % (_level_name_male[level])
|
||||
def _get_step_father(self, level, inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if level < len(_step_father_level):
|
||||
return _step_father_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_male_a):
|
||||
return "%s abuelastro%s" % (_level_name_male_a[level-1],inlaw)
|
||||
else:
|
||||
return "primo %d-ésimo" % level
|
||||
return "%d-ésimo abuelastro%s" % (level-1,inlaw)
|
||||
|
||||
def get_female_cousin(self, level):
|
||||
if level < len(_level_name_female):
|
||||
return "prima %s" % (_level_name_female[level])
|
||||
else:
|
||||
return "prima %d-ésima" % level
|
||||
|
||||
def get_distant_uncle(self, level):
|
||||
if level < len(_level_name_male):
|
||||
return "tío %s" % (_level_name_male[level])
|
||||
else:
|
||||
return "tío %d-ésimo" % level
|
||||
|
||||
def get_distant_aunt(self, level):
|
||||
if level < len(_level_name_female):
|
||||
return "tía %s" % (_level_name_female[level])
|
||||
else:
|
||||
return "tía %d-ésima" % level
|
||||
|
||||
def get_distant_nephew(self, level):
|
||||
if level < len(_level_name_male):
|
||||
return "sobrino %s" % (_level_name_male[level])
|
||||
else:
|
||||
return "sobrino %d-ésimo" % level
|
||||
|
||||
def get_distant_niece(self, level):
|
||||
if level < len(_level_name_female):
|
||||
return "sobrina %s" % (_level_name_female[level])
|
||||
else:
|
||||
return "sobrina %d-ésima" % level
|
||||
|
||||
def get_male_relative(self, level1, level2):
|
||||
if level1 < len(_level_name_male_a):
|
||||
level1_str = _level_name_male_a[level1]
|
||||
else:
|
||||
level1_str = "%d-ésimo" % level1
|
||||
if level2 < len(_level_name_male_a):
|
||||
level2_str = _level_name_male_a[level2]
|
||||
else:
|
||||
level2_str = "%d-ésimo" % level2
|
||||
level = level1 + level2
|
||||
if level < len(_level_name_male_a):
|
||||
level_str = _level_name_male_a[level]
|
||||
else:
|
||||
level_str = "%d-ésimo" % level
|
||||
return "pariente en %s grado (%s con %s)" % (level_str, level1_str, level2_str)
|
||||
|
||||
def get_female_relative(self, level1, level2):
|
||||
return self.get_male_relative(level1, level2)
|
||||
|
||||
def get_parents(self, level):
|
||||
if level < len(_parents_level):
|
||||
return _parents_level[level]
|
||||
elif (level-1) < len(_level_name_plural):
|
||||
return "%s abuelos" % (_level_name_plural[level-1])
|
||||
else:
|
||||
return "%d-ésimos abuelos" % (level-1)
|
||||
|
||||
def get_father(self, level):
|
||||
def _get_father(self, level, step='', inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if step:
|
||||
return self._get_step_father(level, inlaw)
|
||||
if inlaw and level == 1:
|
||||
return "suegro"
|
||||
if level < len(_father_level):
|
||||
return _father_level[level]
|
||||
return _father_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_male_a):
|
||||
return "%s abuelo" % (_level_name_male_a[level-1])
|
||||
return "%s abuelo%s" % (_level_name_male_a[level-1],inlaw)
|
||||
else:
|
||||
return "%d-ésimo abuelo" % (level-1)
|
||||
return "%d-ésimo abuelo%s" % (level-1,inlaw)
|
||||
|
||||
def get_son(self, level):
|
||||
def _get_step_son(self, level, inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if level < len(_step_son_level):
|
||||
return _step_son_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_male_a):
|
||||
return "%s nietastro%s" % (_level_name_male_a[level-1],inlaw)
|
||||
else:
|
||||
return "%d-ésimo nietastro%s" % (level-1,inlaw)
|
||||
|
||||
def _get_son(self, level, step='', inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if step:
|
||||
return self._get_step_son(level, inlaw)
|
||||
if inlaw and level == 1:
|
||||
return "yerno"
|
||||
if level < len(_son_level):
|
||||
return _son_level[level]
|
||||
return _son_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_male_a):
|
||||
return "%s nieto" % (_level_name_male_a[level-1])
|
||||
return "%s nieto%s" % (_level_name_male_a[level-1], inlaw)
|
||||
else:
|
||||
return "%d-ésimo nieto" % (level-1)
|
||||
return "%d-ésimo nieto%s" % (level-1, inlaw)
|
||||
|
||||
def get_mother(self, level):
|
||||
def _get_step_mother(self, level, inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if level < len(_step_mother_level):
|
||||
return _step_mother_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_female):
|
||||
return "%s abuelastra%s" % (_level_name_female[level-1],inlaw)
|
||||
else:
|
||||
return "%d-ésima abuelastra%s" % (level-1,inlaw)
|
||||
|
||||
def _get_mother(self, level, step='', inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if step:
|
||||
return self._get_step_mother(level, inlaw)
|
||||
if inlaw and level == 1:
|
||||
return "suegra"
|
||||
if level < len(_mother_level):
|
||||
return _mother_level[level]
|
||||
return _mother_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_female):
|
||||
return "%s abuela" % (_level_name_female[level-1])
|
||||
return "%s abuela%s" % (_level_name_female[level-1],inlaw)
|
||||
else:
|
||||
return "%d-ésima abuela" % (level-1)
|
||||
return "%d-ésima abuela%s" % (level-1,inlaw)
|
||||
|
||||
def get_daughter(self, level):
|
||||
def _get_step_daughter(self, level, inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if level < len(_step_daughter_level):
|
||||
return _step_daughter_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_female):
|
||||
return "%s nietastra%s" % (_level_name_female[level-1],inlaw)
|
||||
else:
|
||||
return "%d-ésima nietastra%s" % (level-1,inlaw)
|
||||
|
||||
def _get_daughter(self, level, step='', inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if step:
|
||||
return self._get_step_daughter(level, inlaw)
|
||||
if inlaw and level == 1:
|
||||
return "nuera"
|
||||
if level < len(_daughter_level):
|
||||
return _daughter_level[level]
|
||||
return _daughter_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_female):
|
||||
return "%s nieta" % (_level_name_female[level-1])
|
||||
return "%s nieta%s" % (_level_name_female[level-1], inlaw)
|
||||
else:
|
||||
return "%d-ésima nieta" % (level-1)
|
||||
return "%d-ésima nieta%s" % (level-1, inlaw)
|
||||
|
||||
def get_aunt(self, level):
|
||||
if level < len(_sister_level):
|
||||
return _sister_level[level]
|
||||
def _get_parent_unknown(self, level, step='', inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
return "%s o %s" % (self._get_father(level,step,inlaw), self._get_mother(level,step,inlaw))
|
||||
|
||||
def _get_child_unknown(self, level, step='', inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
return "%s o %s" % (self._get_son(level,step,inlaw), self._get_daughter(level,step,inlaw))
|
||||
|
||||
def _get_step_aunt(self, level, inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if level < len(_step_sister_level):
|
||||
return _step_sister_level[level] % {'inlaw': inlaw}
|
||||
elif (level-2) < len(_level_name_female):
|
||||
return "%s tía abuela" % (_level_name_female[level-2])
|
||||
return "%s tía abuelastra%s" % (_level_name_female[level-2],inlaw)
|
||||
else:
|
||||
return "%d-ésima tía abuela" % (level-2)
|
||||
return "%d-ésima tia abuelastra%s" % (level-2,inlaw)
|
||||
|
||||
def get_uncle(self, level):
|
||||
if level < len(_brother_level):
|
||||
return _brother_level[level]
|
||||
def _get_aunt(self, level, step='', inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if step:
|
||||
return self._get_step_aunt(level, inlaw)
|
||||
if inlaw and level == 1:
|
||||
return "cuñada"
|
||||
if level < len(_sister_level):
|
||||
return _sister_level[level] % {'inlaw': inlaw}
|
||||
elif (level-2) < len(_level_name_female):
|
||||
return "%s tía abuela%s" % (_level_name_female[level-2], inlaw)
|
||||
else:
|
||||
return "%d-ésima tía abuela%s" % (level-2, inlaw)
|
||||
|
||||
def _get_distant_aunt(self, level, step, inlae):
|
||||
if step:
|
||||
base = 'tiastra'
|
||||
else:
|
||||
base = 'tía'
|
||||
if level < len(_level_name_female):
|
||||
return "%s %s" % (base,_level_name_female[level])
|
||||
else:
|
||||
return "%s %d-ésima" % (base,level)
|
||||
|
||||
def _get_step_uncle(self, level, inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if level < len(_step_brother_level):
|
||||
return _step_brother_level[level] % {'inlaw': inlaw}
|
||||
elif (level-2) < len(_level_name_male_a):
|
||||
return "%s tío abuelo" % (_level_name_male_a[level-2])
|
||||
return "%s tío abuelastro%s" % (_level_name_male_a[level-2],inlaw)
|
||||
else:
|
||||
return "%d-ésimo tío abuelo" % (level-2)
|
||||
return "%d-ésimo tío abuelastro%s" % (level-2,inlaw)
|
||||
|
||||
def get_nephew(self, level):
|
||||
if level < len(_nephew_level):
|
||||
return _nephew_level[level]
|
||||
def _get_uncle(self, level, step='', inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if step:
|
||||
return self._get_step_uncle(level, inlaw)
|
||||
if inlaw and level == 1:
|
||||
return "cuñado"
|
||||
if level < len(_brother_level):
|
||||
return _brother_level[level] % {'inlaw': inlaw}
|
||||
elif (level-2) < len(_level_name_male_a):
|
||||
return "%s tío abuelo%s" % (_level_name_male_a[level-2], inlaw)
|
||||
else:
|
||||
return "%d-ésimo tío abuelo%s" % (level-2, inlaw)
|
||||
|
||||
def _get_distant_uncle(self, level, step='', inlaw=''):
|
||||
if step:
|
||||
base = 'tiastro'
|
||||
else:
|
||||
base = 'tío'
|
||||
if level < len(_level_name_male):
|
||||
return "%s %s" % (base,_level_name_male[level])
|
||||
else:
|
||||
return "%s %d-ésimo" % (base,level)
|
||||
|
||||
def _get_step_nephew(self, level, inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if level < len(_step_nephew_level):
|
||||
return _step_nephew_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_male_a):
|
||||
return "%s sobrino nieto" % (_level_name_male_a[level-1])
|
||||
return "%s tío sobrinastro%s" % (_level_name_male_a[level-1],inlaw)
|
||||
else:
|
||||
return "%d-ésimo sobrino nieto" % (level-1)
|
||||
return "%d-ésimo tío sobrinastro%s" % (level-1,inlaw)
|
||||
|
||||
def get_niece(self, level):
|
||||
if level < len(_niece_level):
|
||||
return _niece_level[level]
|
||||
def _get_nephew(self, level, step='', inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if step:
|
||||
return self._get_step_nephew(level, inlaw)
|
||||
if level < len(_nephew_level):
|
||||
return _nephew_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_male_a):
|
||||
return "%s sobrino nieto%s" % (_level_name_male_a[level-1], inlaw)
|
||||
else:
|
||||
return "%d-ésimo sobrino nieto%s" % (level-1, inlaw)
|
||||
|
||||
def _get_distant_nephew(self, level, step, inlaw):
|
||||
if step:
|
||||
base = 'sobrinastro'
|
||||
else:
|
||||
base = 'sobrino'
|
||||
if level < len(_level_name_male):
|
||||
return "%s %s" % (base,_level_name_male[level])
|
||||
else:
|
||||
return "%s %d-ésimo" % (base,level)
|
||||
|
||||
def _get_step_niece(self, level, inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
if level < len(_step_niece_level):
|
||||
return _step_niece_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_female):
|
||||
return "%s sobrina nieta" % (_level_name_female[level-1])
|
||||
return "%s tía sobrinastra%s" % (_level_name_female[level-1],inlaw)
|
||||
else:
|
||||
return "%d-ésima sobrina nieta" % (level-1)
|
||||
return "%d-ésima tía sobrinastra%s" % (level-1,inlaw)
|
||||
|
||||
def get_relationship(self, secondRel, firstRel, orig_person_gender, other_person_gender):
|
||||
def _get_niece(self, level, step='', inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
if step:
|
||||
return self._get_step_niece(level, inlaw)
|
||||
if level < len(_niece_level):
|
||||
return _niece_level[level] % {'inlaw': inlaw}
|
||||
elif (level-1) < len(_level_name_female):
|
||||
return "%s sobrina nieta%s" % (_level_name_female[level-1], inlaw)
|
||||
else:
|
||||
return "%d-ésima sobrina nieta%s" % (level-1, inlaw)
|
||||
|
||||
def _get_distant_niece(self, level, step, inlaw):
|
||||
if step:
|
||||
base = 'sobrinastra'
|
||||
else:
|
||||
base = 'sobrina'
|
||||
if level < len(_level_name_female):
|
||||
return "%s %s" % (base,_level_name_female[level])
|
||||
else:
|
||||
return "%s %d-ésima" % (base,level)
|
||||
|
||||
def _get_male_cousin(self, level, removed, lower=False, step='', inlaw='', gender_c=UNKNOWN):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
# primastro is an invention and is not backed by DRAE
|
||||
if step:
|
||||
prim="primastro"
|
||||
else:
|
||||
prim="primo"
|
||||
if removed == 0:
|
||||
if level == 1:
|
||||
return "%s hermano%s" % (prim, inlaw)
|
||||
elif level < len(_level_name_male):
|
||||
return "%s %s%s" % (prim,_level_name_male[level], inlaw)
|
||||
else:
|
||||
return "%s %d-ésimo%s" % (prim, level, inlaw)
|
||||
elif removed > 0 and lower:
|
||||
if gender_c == MALE:
|
||||
return "%s de un %s" % (self._get_son(removed,step,inlaw),
|
||||
self._get_male_cousin(level, 0, lower, step, inlaw, gender_c))
|
||||
elif gender_c == FEMALE:
|
||||
return "%s de una %s" % (self._get_son(removed,step,inlaw),
|
||||
self._get_female_cousin(level, 0, lower, step, inlaw, gender_c))
|
||||
else:
|
||||
return "%s de un %s" % (self._get_son(removed,step,inlaw),
|
||||
self._get_male_cousin(level, 0, lower, step, inlaw, gender_c))
|
||||
elif removed > 0 and not lower:
|
||||
if gender_c == MALE:
|
||||
return "%s de un %s" % (self._get_male_cousin(level, 0, lower, step, inlaw, gender_c),
|
||||
self._get_father(removed,step,inlaw))
|
||||
elif gender_c == FEMALE:
|
||||
return "%s de una %s" % (self._get_male_cousin(level, 0, lower, step, inlaw, gender_c),
|
||||
self._get_mother(removed,step,inlaw))
|
||||
else:
|
||||
return "%s de un %s" % (self._get_male_cousin(level, 0, lower, step, inlaw, gender_c),
|
||||
self._get_father(removed,step,inlaw))
|
||||
|
||||
else:
|
||||
return "%s %scousin%s (%d-%d)" % (_level_name[level],
|
||||
step, inlaw,
|
||||
removed, lower)
|
||||
|
||||
def _get_female_cousin(self, level, removed, lower=False, step='', inlaw='', gender_c=UNKNOWN):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
# primastra is an invention and is not real Spanish
|
||||
if step:
|
||||
prim="primastra"
|
||||
else:
|
||||
prim="prima"
|
||||
if removed == 0:
|
||||
if level == 1:
|
||||
return "%s hermana%s" % (prim, inlaw)
|
||||
elif level < len(_level_name_male):
|
||||
return "%s %s%s" % (prim,_level_name_female[level], inlaw)
|
||||
else:
|
||||
return "%s %d-ésima%s" % (prim, level, inlaw)
|
||||
elif removed > 0 and lower:
|
||||
if gender_c == MALE:
|
||||
return "%s de un %s" % (self._get_daughter(removed,step,inlaw),
|
||||
self._get_male_cousin(level, 0, lower, step, inlaw, gender_c))
|
||||
elif gender_c == FEMALE:
|
||||
return "%s de una %s" % (self._get_daughter(removed,step,inlaw),
|
||||
self._get_female_cousin(level, 0, lower, step, inlaw, gender_c))
|
||||
else:
|
||||
return "%s de un %s" % (self._get_daughter(removed,step,inlaw),
|
||||
self._get_male_cousin(level, 0, lower, step, inlaw, gender_c))
|
||||
elif removed > 0 and not lower:
|
||||
if gender_c == MALE:
|
||||
return "%s de un %s" % (self._get_female_cousin(level, 0, lower, step, inlaw, gender_c),
|
||||
self._get_father(removed,step,inlaw))
|
||||
elif gender_c == FEMALE:
|
||||
return "%s de una %s" % (self._get_female_cousin(level, 0, lower, step, inlaw, gender_c),
|
||||
self._get_mother(removed,step,inlaw))
|
||||
else:
|
||||
return "%s de un %s" % (self._get_female_cousin(level, 0, lower, step, inlaw, gender_c),
|
||||
self._get_father(removed,step,inlaw))
|
||||
|
||||
else:
|
||||
return "%s %sprima%s (%d-%d)" % (_level_name[level],
|
||||
step, inlaw,
|
||||
removed, lower)
|
||||
|
||||
def _get_sibling(self, level, step='', inlaw=''):
|
||||
"""Internal spanish method to create relation string
|
||||
"""
|
||||
# TBC: inlaw is inflicted, it is probably better to do away with this method
|
||||
# and do both calls from the caller (would need inlaw_MALE and inlaw_FEMALE,
|
||||
# but is feasible
|
||||
return "%s o %s" % (self._get_uncle(level,step,inlaw),self._get_aunt(level,step,inlaw))
|
||||
|
||||
def get_plural_relationship_string(self, Ga, Gb,
|
||||
reltocommon_a='', reltocommon_b='',
|
||||
only_birth=True,
|
||||
in_law_a=False, in_law_b=False):
|
||||
"""Spanish version of method to create relation string - check Relationship.py
|
||||
"""
|
||||
|
||||
common = ""
|
||||
if firstRel == 0:
|
||||
if secondRel == 0:
|
||||
return ('', common)
|
||||
elif other_person_gender == gen.lib.Person.MALE:
|
||||
return (self.get_father(secondRel), common)
|
||||
rel_str = "parientes lejanos"
|
||||
if Ga == 0:
|
||||
# These are descendants
|
||||
if Gb < len(_children_level):
|
||||
rel_str = _children_level[Gb]
|
||||
elif (Gb-1) < len(_level_name_plural):
|
||||
rel_str = "%s nietos" % (_level_name_plural[Gb-1])
|
||||
else:
|
||||
return (self.get_mother(secondRel), common)
|
||||
elif secondRel == 0:
|
||||
if other_person_gender == gen.lib.Person.MALE:
|
||||
return (self.get_son(firstRel), common)
|
||||
rel_str = "%d-ésimos nietos" % (Gb-1)
|
||||
elif Gb == 0:
|
||||
# These are parents/grand parents
|
||||
if Ga < len(_parents_level):
|
||||
rel_str = _parents_level[Ga]
|
||||
elif (Ga-1) < len(_level_name_plural):
|
||||
rel_str = "%s abuelos" % (_level_name_plural[Ga-1])
|
||||
else:
|
||||
return (self.get_daughter(firstRel), common)
|
||||
elif firstRel == 1:
|
||||
if other_person_gender == gen.lib.Person.MALE:
|
||||
return (self.get_uncle(secondRel), common)
|
||||
rel_str = "%d-ésimos abuelos" % (Ga-1)
|
||||
elif Gb == 1:
|
||||
# These are siblings/aunts/uncles
|
||||
if Ga < len(_siblings_level):
|
||||
rel_str = _siblings_level[Ga]
|
||||
elif (Ga-1) < len(_level_name_plural):
|
||||
rel_str = "%s tíos abuelos" % (_level_name_plural[Ga-1])
|
||||
else:
|
||||
return (self.get_aunt(secondRel), common)
|
||||
elif secondRel == 1:
|
||||
if other_person_gender == gen.lib.Person.MALE:
|
||||
return (self.get_nephew(firstRel-1), common)
|
||||
rel_str = "%s-ésimos tíos abuelos" % (Ga-1)
|
||||
elif Ga == 1:
|
||||
# These are nieces/nephews
|
||||
if Gb < len(_nephews_nieces_level):
|
||||
rel_str = _nephews_nieces_level[Gb]
|
||||
elif (Gb-1) < len(_level_name_plural):
|
||||
rel_str = "%s sobrinos nietos" % (_level_name_plural[Gb-1])
|
||||
else:
|
||||
return (self.get_niece(firstRel-1), common)
|
||||
elif firstRel == secondRel == 2:
|
||||
if other_person_gender == gen.lib.Person.MALE:
|
||||
return ('primo hermano', common)
|
||||
rel_str = "%s-ésimos sobrinos nietos" % (Gb-1)
|
||||
elif Ga > 1 and Ga == Gb:
|
||||
# These are cousins in the same generation
|
||||
if Ga == 2:
|
||||
rel_str = "primos hermanos"
|
||||
elif level < len(_level_name_plural):
|
||||
rel_str = "primos %s" % (_level_name_plural[Ga-1])
|
||||
else:
|
||||
return ('prima hermana', common)
|
||||
elif firstRel == secondRel:
|
||||
if other_person_gender == gen.lib.Person.MALE:
|
||||
return (self.get_male_cousin(firstRel-1), common)
|
||||
rel_str = "primos %d-ésimos" % (Ga-1)
|
||||
elif Ga == Gb+1:
|
||||
# These are distant uncles/aunts
|
||||
if Gb < len(_level_name_plural):
|
||||
rel_str = "tíos %s" % (_level_name_plural[Gb])
|
||||
else:
|
||||
return (self.get_female_cousin(firstRel-1), common)
|
||||
elif firstRel == secondRel+1:
|
||||
if other_person_gender == gen.lib.Person.MALE:
|
||||
return (self.get_distant_nephew(secondRel), common)
|
||||
rel_str = "tíos %d-ésimos" % (Gb)
|
||||
elif Ga+1 == Gb:
|
||||
# These are distant nephews/nieces
|
||||
if Gb-1 < len(_level_name_plural):
|
||||
rel_str = "sobrinos %s" % (_level_name_plural[Gb-1])
|
||||
else:
|
||||
return (self.get_distant_niece(secondRel), common)
|
||||
elif firstRel+1 == secondRel:
|
||||
if other_person_gender == gen.lib.Person.MALE:
|
||||
return (self.get_distant_uncle(firstRel), common)
|
||||
else:
|
||||
return (self.get_distant_aunt(firstRel), common)
|
||||
else:
|
||||
if other_person_gender == gen.lib.Person.MALE:
|
||||
return (self.get_male_relative(firstRel, secondRel), common)
|
||||
else:
|
||||
return (self.get_female_relative(firstRel, secondRel), common)
|
||||
|
||||
rel_str = "sobrinos %d-ésimos" % (Gb-1)
|
||||
elif Ga > 1 and Ga > Gb:
|
||||
# These are cousins in different generations with the second person
|
||||
# being in a higher generation from the common ancestor than the
|
||||
# first person.
|
||||
rel_str = "%s de los %s" % (
|
||||
self.get_plural_relationship_string(0, Gb),
|
||||
self.get_plural_relationship_string(Ga, 0) )
|
||||
elif Gb > 1 and Gb > Ga:
|
||||
# These are cousins in different generations with the second person
|
||||
# being in a lower generation from the common ancestor than the
|
||||
# first person.
|
||||
rel_str = "%s de los %s" % (
|
||||
self.get_plural_relationship_string(0, Gb),
|
||||
self.get_plural_relationship_string(Ga, 0) )
|
||||
|
||||
if in_law_b == True:
|
||||
rel_str = "cónyuges de los %s" % rel_str
|
||||
|
||||
return rel_str
|
||||
|
||||
def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b,
|
||||
reltocommon_a, reltocommon_b,
|
||||
only_birth=True,
|
||||
in_law_a=False, in_law_b=False):
|
||||
return self.get_relationship(Ga, Gb, gender_a, gender_b)[0];
|
||||
"""Spanish version of method to create relation string - check Relationship.py
|
||||
"""
|
||||
|
||||
if only_birth:
|
||||
step = ''
|
||||
else:
|
||||
step = self.STEP
|
||||
|
||||
if in_law_a or in_law_b :
|
||||
if gender_b == FEMALE:
|
||||
inlaw = ' política'
|
||||
else:
|
||||
inlaw = ' político'
|
||||
else:
|
||||
inlaw = ''
|
||||
|
||||
rel_str = "%spariente%s lejano" % (step, inlaw)
|
||||
|
||||
if Ga == 0:
|
||||
# b is descendant of a
|
||||
if Gb == 0 :
|
||||
rel_str = 'la misma persona'
|
||||
elif gender_b == MALE:
|
||||
rel_str = self._get_son(Gb, step, inlaw)
|
||||
elif gender_b == FEMALE:
|
||||
rel_str = self._get_daughter(Gb, step, inlaw)
|
||||
else:
|
||||
rel_str = self._get_child_unknown(Gb, step, inlaw)
|
||||
elif Gb == 0:
|
||||
# b is parents/grand parent of a
|
||||
if gender_b == MALE:
|
||||
rel_str = self._get_father(Ga, step, inlaw)
|
||||
elif gender_b == FEMALE:
|
||||
rel_str = self._get_mother(Ga, step, inlaw)
|
||||
else:
|
||||
rel_str = self._get_parent_unknown(Ga, step, inlaw)
|
||||
elif Gb == 1:
|
||||
# b is sibling/aunt/uncle of a
|
||||
if gender_b == MALE:
|
||||
rel_str = self._get_uncle(Ga, step, inlaw)
|
||||
elif gender_b == FEMALE:
|
||||
rel_str = self._get_aunt(Ga, step, inlaw)
|
||||
else:
|
||||
rel_str = self._get_sibling(Ga, step, inlaw)
|
||||
elif Ga == 1:
|
||||
# b is niece/nephew of a
|
||||
if gender_b == MALE:
|
||||
rel_str = self._get_nephew(Gb-1, step, inlaw)
|
||||
elif gender_b == FEMALE:
|
||||
rel_str = self._get_niece(Gb-1, step, inlaw)
|
||||
else:
|
||||
rel_str = "%s o %s" % (self._get_nephew(Gb-1, step, inlaw),
|
||||
self._get_niece(Gb-1, step, inlaw))
|
||||
elif Ga == Gb:
|
||||
# a and b cousins in the same generation
|
||||
if gender_b == MALE:
|
||||
rel_str = self._get_male_cousin(Ga-1, 0, lower=False, step=step,
|
||||
inlaw=inlaw)
|
||||
elif gender_b == FEMALE:
|
||||
rel_str = self._get_female_cousin(Ga-1, 0, lower=False, step=step,
|
||||
inlaw=inlaw)
|
||||
else:
|
||||
rel_str = "%s o %s" % (self._get_male_cousin(Ga-1, 0, step=step, inlaw=inlaw),
|
||||
self._get_female_cousin(Ga-1, 0, step=step, inlaw=inlaw))
|
||||
elif Ga == Gb+1:
|
||||
if gender_b == gen.lib.Person.MALE:
|
||||
rel_str = self._get_distant_uncle(Gb, step, inlaw)
|
||||
elif gender_b == gen.lib.Person.FEMALE:
|
||||
rel_str = self._get_distant_aunt(Gb, step, inlaw)
|
||||
else:
|
||||
rel_str = "%s o %s" % (self._get_distant_uncle(Gb, 0, step=step, inlaw=inlaw),
|
||||
self._get_distant_aunt(Gb, 0, step=step, inlaw=inlaw))
|
||||
elif Ga+1 == Gb:
|
||||
if gender_b == gen.lib.Person.MALE:
|
||||
rel_str = self._get_distant_nephew(Gb-1, step, inlaw)
|
||||
elif gender_b == gen.lib.Person.FEMALE:
|
||||
rel_str = self._get_distant_niece(Gb-1, step, inlaw)
|
||||
else:
|
||||
rel_str = "%s o %s" % (self._get_distant_nephew(Gb-1, 0, step=step, inlaw=inlaw),
|
||||
self._get_distant_niece(Gb-1, 0, step=step, inlaw=inlaw))
|
||||
elif Ga > Gb:
|
||||
# These are cousins in different generations with the second person
|
||||
# being in a higher generation from the common ancestor than the
|
||||
# first person.
|
||||
# We need to know the gender of the ancestor of the first person who is on
|
||||
# the same generation as the other person
|
||||
if reltocommon_a[Ga-Gb-1] == 'f':
|
||||
gender_c = MALE
|
||||
elif reltocommon_a[Ga-Gb-1] == 'm':
|
||||
gender_c = FEMALE
|
||||
else:
|
||||
gender_c = UNKNOWN
|
||||
if gender_b == MALE:
|
||||
rel_str = self._get_male_cousin(Gb-1, Ga-Gb, lower=False,
|
||||
step=step, inlaw=inlaw, gender_c=gender_c)
|
||||
elif gender_b == FEMALE:
|
||||
rel_str = self._get_female_cousin(Gb-1, Ga-Gb, lower=False,
|
||||
step=step, inlaw=inlaw, gender_c=gender_c)
|
||||
else:
|
||||
rel_str = "%s o %s" % (self._get_male_cousin(Gb-1, Ga-Gb, lower=False,
|
||||
step=step, inlaw=inlaw),
|
||||
self._get_female_cousin(Gb-1, Ga-Gb, lower=False,
|
||||
step=step, inlaw=inlaw))
|
||||
|
||||
elif Gb > Ga:
|
||||
# These are cousins in different generations with the second person
|
||||
# being in a lower generation from the common ancestor than the
|
||||
# first person.
|
||||
# We need to know the gender of the person who is an ancestor of the second person and
|
||||
# is on the same generation that the first person
|
||||
if reltocommon_b[Gb-Ga-1] == 'f':
|
||||
gender_c = MALE
|
||||
elif reltocommon_b[Gb-Ga-1] == 'm':
|
||||
gender_c = FEMALE
|
||||
else:
|
||||
gender_c = UNKNOWN
|
||||
if gender_b == MALE:
|
||||
rel_str = self._get_male_cousin(Ga-1, Gb-Ga, lower=True,
|
||||
step=step, inlaw=inlaw, gender_c=gender_c)
|
||||
elif gender_b == FEMALE:
|
||||
rel_str = self._get_female_cousin(Ga-1, Gb-Ga, lower=True,
|
||||
step=step, inlaw=inlaw, gender_c=gender_c)
|
||||
else:
|
||||
rel_str = "%s o %s" % (self._get_male_cousin(Ga-1, Gb-Ga, lower=True,
|
||||
step=step, inlaw=inlaw),
|
||||
self._get_female_cousin(Ga-1, Gb-Ga, lower=True,
|
||||
step=step, inlaw=inlaw))
|
||||
|
||||
return rel_str
|
||||
|
||||
def get_sibling_relationship_string(self, sib_type, gender_a, gender_b,
|
||||
in_law_a=False, in_law_b=False):
|
||||
return self.get_relationship(1, 1, gender_a, gender_b)[0];
|
||||
"""
|
||||
"""
|
||||
|
||||
rel_str = ''
|
||||
if gender_b != FEMALE:
|
||||
if sib_type == self.NORM_SIB or sib_type == self.UNKNOWN_SIB:
|
||||
rel_str = 'hermano'
|
||||
elif sib_type == self.HALF_SIB_MOTHER \
|
||||
or sib_type == self.HALF_SIB_FATHER:
|
||||
rel_str = 'medio hermano'
|
||||
elif sib_type == self.STEP_SIB:
|
||||
rel_str = 'hermanastro'
|
||||
if in_law_a or in_law_b :
|
||||
rel_str += ' político'
|
||||
|
||||
if gender_b == UNKNOWN:
|
||||
rel_str += ' o '
|
||||
|
||||
if gender_b != MALE:
|
||||
if sib_type == self.NORM_SIB or sib_type == self.UNKNOWN_SIB:
|
||||
rel_str += 'hermana'
|
||||
elif sib_type == self.HALF_SIB_MOTHER \
|
||||
or sib_type == self.HALF_SIB_FATHER:
|
||||
rel_str += 'medio hermana'
|
||||
elif sib_type == self.STEP_SIB:
|
||||
rel_str += 'hermanastra'
|
||||
if in_law_a or in_law_b :
|
||||
rel_str += ' política'
|
||||
|
||||
return rel_str
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user