Welcome to yEd Q&A!
Here you can ask questions and receive answers from other members of the community and yEd developers. And you can tell us your most wanted feature requests.

Categories

Build a pattern for Properties Mapper

0 votes
Hello,
I have difficulties for build a pattern Regex.. I forgot my lessons  ...

This is an example of my Gedcom files
0 HEAD
1 ......
1 CHAR UTF-8
1 PLAC
2 FORM Town , Area code , County , Region , Country, Subdivision
0 @1I@ INDI
1 NAME Eugénie Joséphine/Lefeuvre/
2 GIVN Eugénie Joséphine
2 SURN Lefeuvre
1 SEX F
.....
1 BIRT
2 DATE 30 JUL 1860
3 TIME 1:0
2 PLAC Bayonne,64100,Pyrénées-Atlantiques,Aquitaine,FRANCE,Pyrénées Atlantiques
2 _FNA NO
2 SOUR @8S@
2 NOTE Témoins :
3 CONT Jean Baptiste
3......
0 @4U@ FAM
1 HUSB @2I@
1 WIFE @1I@
1 CHIL @3I@
1 MARR
2 DATE 6 OCT 1883
3 TIME 11:0
2 PLAC Saint-Maur-des-Fossés,94210,Val-de-Marne,Île-de-France,FRANCE,
2......

Q1 - How to Extract the <Date> from tag <MARR> sub-tag <DATE> ?
Q2 - How to Extract the sub-tag <Town> and the sub-tag <Country> from tag <MARR> sub-tag <PLAC> and build <Town - Country>  <Town> + caracter "-" + <Country> ?
Sometimes <MARR> <PLAC>
    doesn't exist,
    is partially empty i.e. < , Area code , County , Region , Country, Subdivision>
    is partialy empty i.e. <Town ,   , County , Region , Country, Subdivision>
    and so ..
   
Thanks in advance for your help
Regards
in Help by

1 Answer

0 votes

A1

This works very much as described in Place of birth in Family Tree Layout from GEDCOM PLAC data:
(?ms).*^\d\sDATE\s(.*)$

A2

Unfortunately, this is not really supported. Processing "irregular" data requires additional logic that is beyond the scope of yEd's properties mapper and regular expressions in general.
Your best bet is to "sanitize" (i.e. make sure <PLACE> always exists and its data is always "well-formed") your data before processing it in yEd.

by [yWorks] (160k points)
Hello,
I am Sorry, but I think you are wrong ..
I want to extract the subtag <DATE> in the tag <MARR>, ie; <6 OCT 1883> in this example

1 SEX F
.....
1 BIRT
2 DATE 30 JUL 1860
3 TIME 1:0
2 PLAC Bayonne,64100,Pyrénées-Atlantiques,Aquitaine,FRANCE,Pyrénées Atlantiques
2 _FNA NO
2 SOUR @8S@
2 NOTE Témoins :
3 CONT Jean Baptiste
3......
0 @4U@ FAM
1 HUSB @2I@
1 WIFE @1I@
1 CHIL @3I@
1 MARR
2 DATE 6 OCT 1883
3 TIME 11:0
2 PLAC Saint-Maur-des-Fossés,94210,Val-de-Marne,Île-de-France,FRANCE,
2......

1- In <MARR>, your pattern <(?ms).*^\d\sDATE\s(.*)$> + <$1> extract :
"
6 OCT 1883
3 TIME 11:0
2 PLAC Saint-Maur-des-Fossés,94210,Val-de-Marne,Île-de-France,FRANCE,
2 _FNA NO
2 SOUR @10S@
2 NOTE Témoins
Achille Dubois, oncle de Georges, 65 ans, employé au gaz, domicilié 20 rue Clavel à  Paris 19 ieme.
Ma (?), Viviez 34 ans, commercant domicilié 34 rue de Moscou à  Paris 8 ieme."

2- In <MARR>,my pattern <(?ms).*^\d\sDATE\s([^,]*),.*$> + <$1> extract :
"
"6 OCT 1883
3 TIME 11:0
2 PLAC Saint-Maur-des-Fossés"

So, all of these patterns doesn't run fine

The test, of the Regex in a Regtester seems OK, so where is the error ?

Regards

Well, try
(?ms).*^\d\sDATE\s(.*?)$.*

You have to keep in mind that yEd's properties mapper performs "regular expression replacement". If the expression matches only a part of the input data, the unmatched part will remain unchanged.

Hello,

Finaly, I wrote these Regex pattern for extract :

<MARR-DATE>                        <(?ms).*^\d\sDATE\s([^\r\n]*).*$>
                       
<MARR-PLAC-Town>                <(?ms).*^\d\sPLAC\s([^,]*),.*$>

<BIRT-or-DEAT-PLAC-Area Code>    <(?ms).*^\d\sPLAC\s[^,]*,([^,]*),.*$>

<BIRT-or-DEAT-PLAC-Country>        <(?ms).*^\d\sPLAC\s[^,]*,([^,]*),([^,]*),([^,]*),([^,]*),.*$>
                                or better
                                <(?ms).*^\d\sPLAC\s(?:[^\,]*\,){4}([^,]*).*$>
   
It seems working.
Q1 - Do you feel there are correct ?

<<BIRT-or-DEAT-PLAC-Town+Country>    you are right .. it seems impossible

Thanck you very much for your help
Best regards
Problem PROPERTIES MAPPER or Reg ex or Gedcom ?
Hello
In this Gedcom I try to extract for a the label <9> <MARR-DATE> with <(?ms).*^\d\sDATE\s(.*?)$.*>

The second marriage date is extract <29 JAN 1854> is extract, the first marriage <19 JUL 1820> is not extract !!
Something is wrong in the Mapper or in the Regex or in the Gedcom.

Note the extraction for example of the <MARR> <PLAC> run well for each of the marriage
Thanks in advance

Best Regards

Why a particular regular expression mapping is not working can only be determined when the actual data for which the mapping is applied is available. None of the GEDCOM snippets in this thread contains the dates 29 JAN 1854 or 19 JUL 1820, thus I cannot help unless you provide the corresponding GEDCOM file.

Please do not post GEDCOM snippets, but upload a complete GEDCOM file. Moreover, please upload a reasonably small GEDCOM file that demonstrates the problem but does not include lots and lots of unrelated records.

Do not create a new thread for uploading the file, but add an answer in this thread (or edit your original question). Please see How to upload files to yEd Q&A? for information on uploading files here. In addition to uploading a GEDCOM test file, please also export your mapping from properties mapper and upload the exported mapping file as well.

Hello
Sorry for my last message very ....

Finally I found the origin of the problem.... but not the solution

This a part of my Gedcom.
0 HEAD
1 SOUR WHEDIS
2 VERS 14
2 NAME CFGC
................
0 @191U@ FAM
1 HUSB @24I@
1 WIFE @1I@
1 CHIL @23I@
1 CHIL @25I@
1 CHIL @26I@
1 MARR
2 DATE 11 SEP 2010
2 PLAC Guet,6410,nnées iques, Baue,FRANCE,énéeantiques
2 _FNA NO
2 OBJE
3 FORM jpg
3 FILE C:\Documents\Ma-G-Media\Mar1.jpg
3 NOTE Mariaxxnbnbn, Laurent  .... (nn,notre Cbnbv !!)
3 DATE
2 OBJE
3 FORM jpg
3 FILE C:\Documents\Ma-G-Media\Nocbcel-2019.JPG
3 DATE 1 OCT 1900
2 OBJE
3 FORM avi
..........

In this section <FAM>

When I try to extract the <MARR> <DATE> with this Regex <(?ms).*^\d\sDATE\s(.*?)$.*> I extract <1 OCT 1900> but not the <MARR DATE> i.e. <11 SEP 2010>, so how to write the correct Regex ?

Thank in advance

Best regards

I saw you posted a complete GEDCOM example as a comment in thread From the tag "PLAC" in Gedcom, How to extract only the value "Town" or "Area code" for a label.

Well, first off, this is not a yEd problem, not at all. It is a pure regular expression problem. You really need to learn regular expressions. Unfortunately, teaching regular expressions is really out-of-scope for this forum.

That said, let me give some pointers on how to tackle your current problem:

  1. Import your GEDCOM file into yEd.
  2. Find the family node corresponding to the record for which the regular expression "fails".
  3. Click on said node to select it.
  4. Go to the properties view in yEd's lower right corner.
  5. In section "Data" there will be one property that contains the DATE information your regular expression fails to extract.
  6. Copy the value of said property into e.g. a text file.
    This way you will have the exact text on which yEd will apply the regular expression from the appropriate properties mapper configuration later on.
  7. Find a regular expression tool (i.e. a tool that lets you apply a regular expression on text in a quick and easy manner), preferably one that supports the Java regular expression syntax because that is the syntax yEd uses as well.
  8. Use the tool to test and test and test your regular expression until it matches and extracts the data you need from your text.
  9. Once you have the correct expression, create a corresponding properties mapper configuration in yEd.

Still, the most important thing is to learn regular expressions. E.g. you absolutely need to understand what your current regular expression(?ms).*^\d\sDATE\s(.*)$  does and why it does what it does to be able to write new regular expressions for other cases.

Regarding step 7 above, lots of advanced text editors support regular expression search which usually works well for testing purposes. E.g. have a look at Notepad++ and/or jEdit.

Thanks a lot for your help and patience

Best regards
Hello

I build a template for each of the 3 nodes the node Family, the node Male and the node Female.
Each time, after opening a new gedcom I have step by step to select a node type and to apply the node template.

Do exist another way to open the family tree and in one click apply the 3 template ?

Best regards
Unfortunately, yEd's GEDCOM Import does not offer a more convenient way to do that.
Thancks for your answer
regards
I need your help...

I use the property manager in order to extract some labels for a family layout.

My Gecom file is :
_____________________
1 BIRT
2 DATE 26 FEB 1820
2 PLAC Saint-Gein,40190,Landes,Aquitaine,FRANCE,1 Espe lette
2 _FNA NO
2 SOUR @47S@
1 DEAT
2 DATE 18 JUN 1824
2 PLAC Saint,43190,Andes,Aquine,FRCE,Nou eau
2 _FNA NO
2 SOUR @51S@
_____________________

I want to write a Reg Ex in order to extact the words after "," fiveth commas in the line containing "PLAC". For exemple in the Gedcom lines
firts extract "1 Espe lette
second extract "'Nou eau"
and so on in the Gedcom.

I try this Re EX "(?ms).*^\d\sPLAC\s(?:[^\,]*\,){5}([^,]*).*$"
It does'nt run fine
What is the correct Reg Ex

Thanck a lot from France
What do you mean by "it does not run fine"? What result do you get instead of the expected "1 Espe lette"?
Hello,
Thancks to take some instant for answer

My RegEx extract the words "1 Espe lette" that I look for, but it adds the following line of the file for exemple :
"1 Espe lette
2 _FNA NO"

It does'nt stop at the end of line !!
Waiting for your answer.
Best regards
"(?ms).*^\d\sPLAC\s(?:[^,]*,){5}([^,]*?)$.*$"
Thancks a lot

IT is strange twice "$" but any way its run.

Have a nice day
Legal Disclosure | Privacy Policy
...