[2023.1.22] Imported Thesaurus will not be merged

Started by Rene Toepfer, August 09, 2023, 11:45:10 AM

Previous topic - Next topic

Rene Toepfer

I have an issue with the thesaurus reg. to import an existing "imths" file.

From an outdated database I have exported the thesaurus as described in [1]. I have opened the exported IMTHS file and did a spot check for several keywords. Everything is fine with this file.
I opened the current database and imported the IMTHS into the thesaurus as per [2]. As import option I choose "Mit bestehendem Thesaurus mischen" (merge). But then the existing thesaurus will be overwritten by the IMTHS. If I use "Thesaurus ersetzen" (replace) the behaviour is the same.
Of course I have not saved the thesaurus of the current database.

I was expecting that the groups of keywords of the exported IMTHS will be add in the current thesaurus.


[1] https://www.photools.com/help/imatch/thes_basics.htm?dl=exporting
[2] https://www.photools.com/help/imatch/thes_basics.htm?dl=hid-38

Mario

Merge is on a per-tag basis.
If you import a thesaurus and it has keywords, it will replace all keywords in your thesaurus.
If your thesaurus also has other tag values, e.g. titles or descriptions, but the imported has none, the existing title values and description values will be retained in merge mode, but not in replace mode.

The import does not merge keywords from your thesaurus with the keywords from the imported thesaurus - if this is what you expect merge to do.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Rene Toepfer

Quote from: Mario on August 09, 2023, 12:55:28 PMThe import does not merge keywords from your thesaurus with the keywords from the imported thesaurus - if this is what you expect merge to do.
This was what I have expected.

Do you have a hint how to import keywords of another database?

Mario

QuoteDo you have a hint how to import keywords of another database?
Keywords contained in files indexed by that database or keywords in its thesaurus?
I did never bother to implement merge operations for thesaurus, because they are only rarely needed.

Maybe export both thesauri to text format, merge in an editor, re-import?
Note: This will lose all additional properties for keywords, from descriptions to exclusions to include sub-elements.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

thrinn

Quote from: Rene Toepfer on August 09, 2023, 02:29:11 PMDo you have a hint how to import keywords of another database?
An IMTHS file is also a text file, just with an XML based structure. So, in theory (!) it should be possible to do a manual merge. At least if you are only interested in keywords. It is a manual process and a bit tricky because you have to be very careful to not destroy the structure of the file. So, I would try this:

Export your production thesaurus to a production.imths file. Make an additional backup of this file!
Export your legacy thesaurus to a legacy.imths file.
Open legacy.imths using a good text editor (best if it "understands" XML and can collapse XML nodes).
Locate the line containg <tentry xml:id="VKW">. If I am right, this is the start of the Keywords entries.
Locate the corresponding closing </tentry> tag. For example, in Visual Studio Code I can just collapse the node and see that the entries between lines 141 and 368 belong to keywords.

2023-08-09 18_51_42-TRn GPX 2023-08.imths - Vue3 TS - Visual Studio Code.jpg
Now, delete all lines before the opening <tentry xml:id="VKW"> tag and also all lines after the corresponding </tentry>. The remaining part should contain, among others, a sub node called <elements>. Under this node, the actual keyword entries can be found.

Open the production.imths. Locate the <tentry xml:id="VKW">  node. Nested under this node, locate the <elements> node.
From your stripped legacy.imths, copy everything inside the <elements> node (that is, the <elem entries) and paste these lines into production.imths inside the <elements> node (which in turn is inside the <tentry xml:id="VKW"> node). Make sure that you not accidentally duplicate <elements> and/or </elements>.

If all went well, you should now have a well-formed imths file with keywords from both thesauri. Of course, try the import first with a test database. I have no idea what will happen if the imths structure is somehow not consistent...

NOTE: I am just looking at my IMTHS files and try to reengineer the structure from there. You have been warned...


As an IMTHS file contains more information than the text export Mario recommended, you might be able to recover all special settings (groups, links, ...) with this method.

Thorsten
Win 10 / 64, IMatch 2018, IMA

Mario

#5
The abysses of IMatch.
Who comes up with all this technology...
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Rene Toepfer

@thrinn
Interessting proposal. I guess I will dig deeper into this. 

Rene Toepfer

Thanks for the hint with manual merging! I have tested it and it worked very well. Currently I do some tests in a separate database but it looks that IM can run with such an XML.