* Mater-Pater

Writing and using plugins for Version 5 and above.
Post Reply
User avatar
Ron Melby
Superstar
Posts: 440
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Mater-Pater

Post by Ron Melby » 11 Oct 2019 16:16

is there a fh function or any efficient user function you can point me to, that:

given a root and a relation can tell me if it is a mother's side relation or a father's side relation?

I understand that a relation can be both, but fh doesn't seem to be put out by double cousins so much either.
FH V.6.2.7 Win 7 64 bit

User avatar
tatewise
Megastar
Posts: 16613
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Mater-Pater

Post by tatewise » 11 Oct 2019 17:31

I don't think there is anything ready-made, so you will have to perform a tree traverse.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Jane
Site Admin
Posts: 7745
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Mater-Pater

Post by Jane » 12 Oct 2019 17:11

A fairly easy way to do this is to call the RelationCode function and do it on both parents to see which one is a direct line eg spouse_start flag is not set.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
Ron Melby
Superstar
Posts: 440
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Mater-Pater

Post by Ron Melby » 12 Oct 2019 17:27

local function matROOTS()
ptrFAMC = fhGetItemPtr(ptrROOT, '~.FAMC')
ptrFATHER:MoveTo(fhGetValueAsLink(ptrFAMC), '~.HUSB>')
ptrMOTHER:MoveTo(fhGetValueAsLink(ptrFAMC), '~.WIFE>')

tblROOTS[1] = ptrROOT
tblROOTS[2] = ptrFATHER
tblROOTS[3] = ptrMOTHER
end

its what I have done (or started, after some thought)
but.. there are issues.
FH V.6.2.7 Win 7 64 bit

User avatar
Jane
Site Admin
Posts: 7745
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Mater-Pater

Post by Jane » 13 Oct 2019 06:58

Ron that code does not call the RelationCode Function. Once you have added the code for that and put in the check for the spouse start and you have explained exactly what you are not getting I will look at this again. I am not going to write the code for you.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
Ron Melby
Superstar
Posts: 440
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Mater-Pater

Post by Ron Melby » 13 Oct 2019 13:03

yeah, I know that. as I said there are issues. I need to go thru my lineage table. that is my transformed relations, and change it. because I need to have a marker to determine consanguinty as well. wife's husband's niece, for example.

the mother fathers side, as I have discovered is not going to be much code, although heavy processing as it relates to any of the plugins I need it for, 3 relationship checks per individual, occasionally 2, sometimes none, over anywhere from 1600+ to 5600+ individuals depending on the plugin.
FH V.6.2.7 Win 7 64 bit

User avatar
Ron Melby
Superstar
Posts: 440
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Mater-Pater

Post by Ron Melby » 13 Oct 2019 23:59

if ptrFATHER:IsNotNull() then
isf = fhCallBuiltInFunction('IsRelativeOf', ptrFATHER, iptr)
end
if ptrMOTHER:IsNotNull()then
ism = fhCallBuiltInFunction('IsRelativeOf', ptrMOTHER, iptr)
end



now where iptr is the same as the base pointer (father or mother) it is false. so ROOT, FATHER, MOTHER, hope that is all that is incorrect that I will need to fix.
FH V.6.2.7 Win 7 64 bit

User avatar
Jane
Site Admin
Posts: 7745
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Mater-Pater

Post by Jane » 14 Oct 2019 07:17

As I said use RelationCode and check for Spouse Start as well, you can't use IsRelativeOf as it will return true for "In laws"
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
Ron Melby
Superstar
Posts: 440
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Mater-Pater

Post by Ron Melby » 14 Oct 2019 11:25

fhCallBuiltInFunction('RelationCode', ptrFATHER, iptr, GENERATION, GENS_UP, GENS_DOWN, HALF, SPOUSE_START, SPOUSE_END, 1)

GENERATION, GENS_UP, GENS_DOWN, HALF, SPOUSE_START, SPOUSE_END

no way to do that in one fell swoop is there? get all the codes at once?
FH V.6.2.7 Win 7 64 bit

User avatar
Jane
Site Admin
Posts: 7745
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Mater-Pater

Post by Jane » 14 Oct 2019 16:05

What I do is use

Code: Select all

-- V6 Template
    local template = "Gens\. Up\=(%d+), Gens\. Down\=(%d+), Half\=(%d+), Spouse Start\=(%d+), Spouse End\=(%d+)"

    local code = fhCallBuiltInFunction('Relationship',pMain,pi,'CODE',i)
    local gensUp,gensDown,half,spouseStart,spouseEnd = string.match(code,template)   

    
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
Ron Melby
Superstar
Posts: 440
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Mater-Pater

Post by Ron Melby » 10 Nov 2019 00:37

Here is the code (simplified), I take every INDI in my file, use it as root, go find the mother and father and call rtvRLT against every other record in the file. (this takes about 36 hours to run with about 5400 records. This is after several variations, and corrections and am still perplexed, I have included a few rows of results. Not sure hn ow I can determine mothers or fathers side in every case, because I am getting relations to mother and father it is unclear to me how someone related to root is no relation to father or mother, for instance... I must have several errors in this code, and the code that actually figures gens and mother or father will be needed in 'production' and correct, no way would I actually run thru the file root for indi against everyone in production. I am distraught at the time it takes to run 1 cycle thru the code, but cannot find a better shortcut. so open to efficiency, and correction:

Code: Select all

function rtvRLT(iptr, ix)
    ix = ix or 1
    local template = "Gens. Up=(%d+), Gens. Down=(%d+), Half=(%d+), Spouse Start=(%d+), Spouse End=(%d+)"

    local isf = false
    local fRLT, fcode, fGU, fGD, fHf, fSS, fSE
    local ism = false
    local mRLT, mcode, mGU, mGD, mHf, mSS, mSE
    local aRLT = ''
    local rRLT, rcode, rGU, rGD, rHf, rSS, rSE

    if ptrFATHER:IsNotNull() then
      local gensUp, gensDown, half, spouseStart, spouseEnd = ''
      fcode = fhCallBuiltInFunction('Relationship', ptrFATHER, iptr, 'CODE', ix)
      gensUp, gensDown, half, spouseStart, spouseEnd = string.match(fcode, template)   
      if fcode > '' then
        isf = true
        aRLT = '02'
        fGU = gensUp 
        fGD = gensDown 
        fHf = half 
        fSS = spouseStart 
        fSE = spouseEnd 
        fRLT = string.format('%02d.%02d.%02d.%02d.%02d.%02d', 
          aRLT, fGU, fGD, fHf, fSS, fSE)
      else
        fRLT = '88.88.88.88.88.88'
      end
    else
      fRLT = '99.99.99.99.99.99'
    end
    if ptrMOTHER:IsNotNull()then
      local gensUp, gensDown, half, spouseStart, spouseEnd = ''
      mcode = fhCallBuiltInFunction('Relationship', ptrMOTHER, iptr, 'CODE', ix)
      gensUp, gensDown, half, spouseStart, spouseEnd = string.match(mcode, template)   
      if mcode > '' then
        ism =  true
        aRLT =  '03'
        mGU = gensUp 
        mGD = gensDown 
        mHf = half 
        mSS = spouseStart 
        mSE = spouseEnd 
        mRLT = string.format('%02d.%02d.%02d.%02d.%02d.%02d', 
          aRLT, mGU, mGD, mHf, mSS, mSE)
      else
        mRLT = '88.88.88.88.88.88'
      end
    else
      mRLT = '99.99.99.99.99.99'
    end     
    if ptrROOT:IsNotNull() then
      local gensUp, gensDown, half, spouseStart, spouseEnd = ''
      rcode = fhCallBuiltInFunction('Relationship', ptrROOT, iptr, 'CODE', ix)
      gensUp, gensDown, half, spouseStart, spouseEnd = string.match(rcode, template)   
      if rcode > '' then
        aRLT = '00'
        rGU = gensUp 
        rGD = gensDown 
        rHf = half 
        rSS = spouseStart 
        rSE = spouseEnd 
        rRLT = string.format('%02d.%02d.%02d.%02d.%02d.%02d', 
          aRLT, rGU, rGD, rHf, rSS, rSE)
      else
        rRLT = '88.88.88.88.88.88'
      end
    else
      rRLT = '99.99.99.99.99.99'
    end

    out = (trim(swrlt) .. ',' .. rRLT .. ',' .. fRLT .. ',' .. mRLT)
    if not bigrlt[out] then
      bigrlt[out] = out 
    end

  end   
  local fhrlt = fhCallBuiltInFunction('Relationship', ptrROOT, iptr, 'TEXT', ix)
  if fhrlt == nil then
    swrlt = '' 
  end

  if not lineage[fhrlt] then
    swrlt = fhrlt
    swrlt = swrlt:gsub( '%-removed', ' removed' )          -- fix error (removed -removed 1st cousins
    swrlt = swrlt:gsub( 'once', '1 times' )                -- text to numeric 
    swrlt = swrlt:gsub( 'twice','2 times' )                -- text to numeric
    swrlt = swrlt:gsub( 'great great%-', 'great (x02) ' )  -- reduce great great-
    swrlt = swrlt:gsub( '^(%d[^%d])(.*)', ' %1%2' )        -- align leading numerics
    swrlt = swrlt:gsub( '%(x(%d)%)', '(x0%1)' )            -- (xd) padded to (x0d) 

    -- d or dd times to (xdd)
    pre, rpl, pst = string.match(swrlt, '(.*[^%d])(%d+ times)(.*)')  
    if rpl  ~= nil then
      rpl    = tonumber(string.match(rpl, '(%d+)'))
      if rpl < 10 then
        rpl  = ('0'..rpl)
      end 
      swrlt  = (pre .. '(x'.. rpl .. ')' .. pst)
    end
    -- rmv great- add 1 to x(dd)
    pre, rpl, tho, pst = string.match(swrlt, '(.*) %(x(%d+)%) (great%-)(.*)') 
    if tho  ~= nil then
      rpl    = (tonumber(rpl) + 1)
      if rpl < 10 then
        rpl  = ('0'.. rpl)
      end
      rpl    = '(x' .. rpl .. ')'
      swrlt  = pre .. ' ' .. rpl .. ' ' .. pst 
    end 

    swrlt = swrlt:gsub( 'great%-', 'Great ' )      
    swrlt = swrlt:gsub( 'great',   'Great'  )      
    swrlt = swrlt:gsub( 'grand',   'Grand'  )      
    swrlt = swrlt:gsub( 'uncle',   'Uncle'  )      
    swrlt = swrlt:gsub( 'aunt',    'Aunt'   )   
    swrlt = swrlt:gsub( 'half',    '½'      )  
    lineage[fhrlt] = trimr(swrlt) 
  end

  swrlt = lineage[fhrlt] 
  if swrlt > '' then
    rtvside(iptr)
  end
end  --fn rtvRLT
 


here is where I loop thru the file.

Code: Select all

ptrROOT = fhNewItemPtr()
ptrFAMC = fhNewItemPtr()
ptrMOTHER = fhNewItemPtr()
ptrFATHER = fhNewItemPtr()
local ptrINDI = fhNewItemPtr()
ptrROOT:MoveToFirstRecord('INDI')
while ptrROOT:IsNotNull() do
  ptrFAMC = fhGetItemPtr(ptrROOT, '~.FAMC')
  ptrFATHER:MoveTo(fhGetValueAsLink(ptrFAMC), '~.HUSB>')
  ptrMOTHER:MoveTo(fhGetValueAsLink(ptrFAMC), '~.WIFE>')
  ptrINDI:MoveToFirstRecord('INDI')
  while ptrINDI:IsNotNull() do
    rtvRLT(ptrINDI)
    ptrINDI:MoveNext()           
  end  
  ptrROOT:MoveNext()           
end  



Relation Root Father Mother
["root 00.00.00.00.00.00 02.00.01.00.00.00 03.00.01.00.00.00"]
["root 00.00.00.00.00.00 02.00.01.00.00.00 99.99.99.99.99.99"]
["root 00.00.00.00.00.00 99.99.99.99.99.99 03.00.01.00.00.00"]
["root 00.00.00.00.00.00 99.99.99.99.99.99 99.99.99.99.99.99"]
["husband 00.00.00.00.00.01 02.00.01.00.00.01 03.00.00.00.00.01"]
["husband 00.00.00.00.00.01 02.00.01.00.00.01 03.00.01.00.00.01"]
["husband 00.00.00.00.00.01 02.00.01.00.00.01 03.01.01.00.00.00"]
["husband 00.00.00.00.00.01 02.00.01.00.00.01 99.99.99.99.99.99"]
["husband 00.00.00.00.00.01 99.99.99.99.99.99 03.00.01.00.00.01"]
["husband 00.00.00.00.00.01 99.99.99.99.99.99 99.99.99.99.99.99"]
["wife 00.00.00.00.00.01 02.00.01.00.00.01 03.00.01.00.00.01"]
["wife 00.00.00.00.00.01 02.00.01.00.00.01 99.99.99.99.99.99"]
["wife 00.00.00.00.00.01 02.00.02.00.00.00 03.00.01.00.00.01"]
["wife 00.00.00.00.00.01 02.00.02.00.00.00 03.00.02.00.00.00"]
["wife 00.00.00.00.00.01 99.99.99.99.99.99 03.00.01.00.00.01"]
["wife 00.00.00.00.00.01 99.99.99.99.99.99 99.99.99.99.99.99"]
["husband's wife 00.00.00.00.01.01 02.00.01.00.00.01 03.00.01.00.00.01"]
["husband's wife 00.00.00.00.01.01 02.01.02.00.01.00 03.01.02.00.00.00"]
["husband's wife 00.00.00.00.01.01 88.88.88.88.88.88 88.88.88.88.88.88"]
["husband's wife 00.00.00.00.01.01 99.99.99.99.99.99 88.88.88.88.88.88"]
["husband's wife 00.00.00.00.01.01 99.99.99.99.99.99 99.99.99.99.99.99"]
["wife's husband 00.00.00.00.01.01 02.02.01.00.01.00 03.02.01.00.00.00"]
["wife's husband 00.00.00.00.01.01 02.02.03.00.01.01 03.01.01.01.01.01"]
["wife's husband 00.00.00.00.01.01 88.88.88.88.88.88 03.02.02.00.01.01"]
["wife's husband 00.00.00.00.01.01 02.00.01.00.00.01 03.00.01.00.00.01"]
["wife's husband 00.00.00.00.01.01 02.00.03.00.00.00 03.00.03.00.00.00"]
["wife's husband 00.00.00.00.01.01 88.88.88.88.88.88 88.88.88.88.88.88"]
["wife's husband 00.00.00.00.01.01 99.99.99.99.99.99 99.99.99.99.99.99"]
["son 00.00.01.00.00.00 02.00.02.00.00.00 03.00.01.00.00.00"]
["son 00.00.01.00.00.00 02.00.02.00.00.00 03.00.02.00.00.00"]
["son 00.00.01.00.00.00 02.00.02.00.00.00 99.99.99.99.99.99"]
["son 00.00.01.00.00.00 99.99.99.99.99.99 03.00.02.00.00.00"]
["son 00.00.01.00.00.00 99.99.99.99.99.99 99.99.99.99.99.99"]
["daughter 00.00.01.00.00.00 02.00.01.00.00.00 03.00.01.00.00.00"]
["daughter 00.00.01.00.00.00 02.00.02.00.00.00 03.00.02.00.00.00"]
["daughter 00.00.01.00.00.00 02.00.02.00.00.00 99.99.99.99.99.99"]
["daughter 00.00.01.00.00.00 99.99.99.99.99.99 03.00.02.00.00.00"]
["daughter 00.00.01.00.00.00 99.99.99.99.99.99 99.99.99.99.99.99"]
["son-in-law 00.00.01.00.00.01 02.00.01.00.00.00 03.00.01.00.01.00"]
["son-in-law 00.00.01.00.00.01 02.00.01.00.00.01 03.00.01.00.00.01"]
FH V.6.2.7 Win 7 64 bit

Post Reply