NaturalHistoryMuseum / scratchpads2

Scratchpads 2.0
http://scratchpads.org
GNU General Public License v2.0
199 stars 83 forks source link

Morphological terms in taxon pages not linked to terms in the Anatomical Glossary [Related to #6220] #6550

Open REHarbach opened 2 years ago

REHarbach commented 2 years ago

Morphological terms in taxon pages are not linked to the terms in the Anatomical Glossary. Also, the identifiers [no-lexicon] and [/no-lexicon] are showing in the text where morphological terms are not supposed to be linked to terms in the glossary. This issue seems to be linked to the previous issue I submitted regarding the problem with illustrations not being displayed in the Anatomical Glossary. These problems apparently stem from the site being moved to https: and myspecies. If possible please have a look at the site before the transition to see the links between text and glossary. These links were automatically created by the software in the past.

Archilegt commented 2 years ago

This problem was reported by me two years ago, on 13 May 2020: Autotagging of taxon descriptions with terms from lexicon #6220 Morphological term autotagging is one of the most important features of Scratchpads.

therobyouknow commented 2 years ago

ongoing analysis

I've linked that other issue based on your above comment. They may indeed be linked. My ongoing investigation in #6549 will eventually confirm.

This issue seems to be linked to the previous issue I submitted regarding the problem with illustrations not being displayed in the Anatomical Glossary.

https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6549

therobyouknow commented 2 years ago

ongoing analysis

Can you show me which pages need to be linked please?

image

REHarbach commented 2 years ago

I think I have not explained the problem properly. It is not a matter of linking pages. Before myspecies, all of the morphological terms in all of the taxon pages were automatically liked to the definitions of the terms in the Anatomical Glossary. In the case of terms that should not be linked, e.g. Root as a surname as opposed to "root" in the list of Adult terminology, the term was enclosed in “[no-lexicon] … [/no-lexicon]”. It was my understanding that the ScratchPad software was configured to automatically make the links. Each time I added a new taxon page, the anatomical terms were automatically linked, indicated by highlight in blue. I then was able to identify terms that should not have been linked and I was able to block the link by enclosing the term within “[no-lexicon] … [/no-lexicon]”.

I thought the linking feature was common to all sites, but I now wonder if it was unique to my site. The original programmer for ScatchPads, Simon Rycroft, designed my sight, which has features that are not standard for ScratchPads.

I hope this will help to re-establish the links between anatomical terms in the taxon pages and those in the Anatomical Glossary.

Thank you for further consideration of this problem.

Ralph

Ralph E. Harbach

Scientific Associate

Natural History Museum

London SW7 5BD, UK

Tel. +44 (0)20 7942 5768

Fax. +44 (0)20 7942 2559

http://www.nhm.ac.uk/our-science/departments-and-staff/staff-directory/ralph-harbach.htmlhttp://www.nhm.ac.uk/research-curation/stall-directory/entomology/r-harbach/index.html

https://mosquito-taxonomic-inventory.myspecies.info/


From: therobyouknow @.> Sent: 29 July 2022 11:25 To: NaturalHistoryMuseum/scratchpads2 @.> Cc: Ralph Harbach @.>; Author @.> Subject: Re: [NaturalHistoryMuseum/scratchpads2] Morphological terms in taxon pages not linked to terms in the Anatomical Glossary [Related to #6220] (Issue #6550)

Can you show me which pages need to be linked please?

[image]https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F1080646%2F181739352-2bca55a2-31c2-4f41-9db6-bdddbff64ab5.png&data=05%7C01%7Cr.harbach%40nhm.ac.uk%7Cac56ca762cdd4b2cbf2108da714c9bda%7C73a29c014e78437fa0d4c8553e1960c1%7C1%7C0%7C637946871084324275%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=0oEYRvyVpgvhG2uh4CvIXBkv2co76SN7rMuNWkGjkog%3D&reserved=0

— Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FNaturalHistoryMuseum%2Fscratchpads2%2Fissues%2F6550%23issuecomment-1199116649&data=05%7C01%7Cr.harbach%40nhm.ac.uk%7Cac56ca762cdd4b2cbf2108da714c9bda%7C73a29c014e78437fa0d4c8553e1960c1%7C1%7C0%7C637946871084324275%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2fMQRVVpFM%2BPjDJMv9r%2BayXoAY%2BBq4rVPT%2F2tzF53l4%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAXCNV47EYHVZPQMHTETN2ADVWOWQFANCNFSM5WVQNT5A&data=05%7C01%7Cr.harbach%40nhm.ac.uk%7Cac56ca762cdd4b2cbf2108da714c9bda%7C73a29c014e78437fa0d4c8553e1960c1%7C1%7C0%7C637946871084324275%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oF8WvhH76NqMatNYkrjXItk7LVub2uD%2Fgu7UKP4zwQE%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>

therobyouknow commented 2 years ago

ongoing analysis

Thank you @REHarbach

I'm very grateful for the further information. I certainly appreciate there's more to it than linking pages.

I can see that it is terms within these pages that need to be linked, rather than just the overall pages.

https://mosquito-taxonomic-inventory.myspecies.info/simpletaxonomy/term/6427 https://mosquito-taxonomic-inventory.myspecies.info/node/11027

Archilegt commented 2 years ago

Hi, Rob. The autotagging feature is common to all Scratchpads. Please read section "Semantic enrichment (tagging)" in: Smith, V.S., Rycroft, S.D., Harman, K.T. et al. Scratchpads: a data-publishing framework to build, share and manage information on the diversity of life. BMC Bioinformatics 10, S6 (2009). https://doi.org/10.1186/1471-2105-10-S14-S6 The Taxonomy Autotagger module can be found at https://www.drupal.org/project/autotag

How it is meant to work: A user creates a glossary (= lexicon) which, except for the more advanced taxonomy for scientific names, is essentially a Drupal taxonomy. The user enters terms "head" and "leg" in a glossary, e.g., a morphology glossary. Then the user creates taxon pages via the Taxon Description content type, and includes text describing head and leg features. If configured correctly, upon clicking on the TD save button, the autotagging will be triggered and call existing glossaries. If there is a word match, the word in the taxon page will be highlighted in blue and enriched with a link to the corresponding glossary term.

Manual configuration is done through a separate interface. See #6220 for partial description.

Archilegt commented 2 years ago

Tagging is partially working, what might be wrong is the configuration interface. It seems that some options have been lost. Testing in Myriatrix: The taxon description for Chilopoda already existed. I edited the description, section "Morphology", with the following text: "Body composed of head and trunk." See https://myriatrix.myspecies.info/taxonomy/term/7151/descriptions The terms "body", "head", and "trunk" already existed in the "Morphology" lexicon/glossary. See https://myriatrix.myspecies.info/nontaxonomy/term/38678 Results: 1) Desired result not achieved. The words in section "Morphology" (https://myriatrix.myspecies.info/taxonomy/term/7151/descriptions) are not highlighted and do not link to the "Morphology" glossary. 2) Undesired result: The words "body", "head", and "trunk" now appeared in the former blue banner Chilopoda, which now reads "Chilopoda, Body, Head, Trunk" in capital letters (see https://myriatrix.myspecies.info/taxonomy/term/7151/descriptions). This is the natural result of an unnatural configuration. When configuring the Taxon Description content type via admin/structure/types/manage/spm -> Tag options, the "Field to populate " is a required field but only has one option: "Taxonomic name". Together with option "Append", the settings cause the undesired result in 2. Expected visual behavior: 1) The words should be highlighted in blue and directly linked to terms in the relevant glossaries. 2) Blue banners should not be affected by the "Field to populate " option. Either make it optional or add options that are invisible or can be configured for visibility.

Rob, please notify me when you are done inspecting what I wrote about Myriatrix. I will then change the settings or delete the text because I don't want the blue banner Chilopoda to be affected.

Archilegt commented 2 years ago

The AntKey Scratchpad used to be a flagship Scratchpad for illustrating how good taxon descriptions could be autotagged with morphological terms in a glossary. Until recently, that Scratchpad used to have a separate installation at AntKey.org, with the glossary terms correctly highlighted in taxon pages and the links to the glossary working. That site is now gone but I found https://antkey.myspecies.info which is mostly working but with the morphological glossary unreachable at http://antkey.org/lexicon/43 and the morphological terms not highlighted in taxon pages.

therobyouknow commented 2 years ago

ongoing analysis

Thank you very much @Archilegt this information is most appreciated! It will certainly help in my analysis of how to fix. I will read through thoroughly and then advise my approach based on my updated understanding. Thank you again.

therobyouknow commented 2 years ago

ongoing analysis

Rob, please notify me when you are done inspecting what I wrote about Myriatrix. I will then change the settings or delete the text because I don't want the blue banner Chilopoda to be affected.

Thank you @Archilegt I have captured screenshots of the pages you refer to for my own reference as I continue to look into this problem.

You can now change the settings back to how they were.

https://myriatrix.myspecies.info/node/1183/edit relates to https://myriatrix.myspecies.info/taxonomy/term/7151/descriptions

image

also:

https://myriatrix.myspecies.info/nontaxonomy/term/38678

image

I've also re-read your comments and have an improved understanding of the issue as a result.

With that information I can now experiment with the settings on my personal setup and observe the results to help determine how to fix the problem.

therobyouknow commented 2 years ago

ongoing analysis

https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6550#issuecomment-1199269706

When configuring the Taxon Description content type via admin/structure/types/manage/spm -> Tag options, the "Field to populate *" is a required field but only has one option: "Taxonomic name".

Yes, observing that I also see this:

https://myriatrix.myspecies.info/admin/structure/types/manage/spm/auto_label

which is what you are referring to when you say "Tag options", I think. This is provided by https://www.drupal.org/project/autotag module you mentioned, I think.

image

[node:field_taxonomic_name]

Next steps are to see if there is scope on that page to adjust the configuration, to see if that helps fix the problem.

[node:field_taxonomic_name] looks like a Drupal token and if so, there are many tokens supported.

therobyouknow commented 2 years ago

ongoing analysis

Looking at tokens to see if we can select certain ones to help with solution.

For a full list of Tokens, go here:

https://myriatrix.myspecies.info/admin/help/token

(I have enabled the Help module to provide this facility)

then click on "Browse available tokens."

and you get:

image

Or direct URL:

https://myriatrix.myspecies.info/token/tree?options=%7B%22token_types%22%3A%22all%22%2C%22click_insert%22%3Afalse%2C%22show_restricted%22%3Atrue%2C%22recursion_limit%22%3A2%7D&token=aF_IkyMHOK1EKLWVkPNBJAnp8ayrHL4WcEjaA0pCb40

I will experiment with this but I think there is potential for code changes required, including for the autokey module.

therobyouknow commented 2 years ago

ongoing analysis

Antkey has the same configuration as https://myriatrix.myspecies.info/admin/structure/types/manage/spm/auto_label

See below:

https://antkey.myspecies.info/admin/structure/types/manage/spm/auto_label

image

Being the same and that @Archilegt you've said that Antkey was a good source of examples for tagging, I would think there is potentially a bug in the software that I would need to fix,

Some questions for you @Archilegt please:

Do you know when it stopped working?

Can you show me existing pages on https://myriatrix.myspecies.info where the tagging has worked?

therobyouknow commented 2 years ago

ongoing analysis

Apologies @Archilegt by "tag options", I can now see you were referring to the vertical tab on the left on this page:

https://myriatrix.myspecies.info/admin/structure/types/manage/spm

image

When configuring the Taxon Description content type via admin/structure/types/manage/spm -> Tag options, the "Field to populate *" is a required field but only has one option: "Taxonomic name".

I had though that the "field to populate" - "taxonomic name" corresponded to the token set here: https://myriatrix.myspecies.info/admin/structure/types/manage/spm/auto_label - which is [node:field_taxonomic_name] so I temporarily changed it on https://myriatrix.myspecies.info/admin/structure/types/manage/spm/auto_label to [node:field_morphology] to see if that field would then be available as a drop down below "field to populate", but not the case. My experimentation of the configuration there.

My previous 2 questions still apply, so let me know your replies to them.

dev notes

Meanwhile, I think I'm going to need to inspect and debug the code for https://myriatrix.myspecies.info/admin/structure/types/manage/spm/auto_label and its dependency https://www.drupal.org/project/tag modules

These modules are open sourced in the Drupal community contrib ecosystem, however they actually appear to exist in the Scratchpads codebase not as contrib modules but as custom modules:

Comparing the equivalents (using Scootersoftware Beyond Compare) with their contrib modules shows some code differences. The impression so far I get from my visual inspection of the comparison is that the custom modules are newer in terms of functionality.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

I set xdebug some breakpoints in the above custom modules on my personal copy of the site, but break points not hit. So will try to choose some other ones, then I can inspect the variables and data to help my analysis as to why this issue is happening.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

Succinct summary of how it works in previous comment on this ticket further up:

https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6550#issuecomment-1199217147

Next steps:

Once fixed, https://scratchpads.readthedocs.io/en/latest/index.html may need updating to include this feature, as I did not come across it in my use of this training.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

Followed the steps in https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6550#issuecomment-1199217147

on personal local demo test training site:

created a biological taxonomy called fruit with terms orange, lime, lemon

created a Taxon Description node, expe

image

Saved.

image

noting message:

Biological terms must be added using the classification editor.

is that significant.

now to examine config and use xdebug and see also if there's info in this ticket and elsewhere about this used to work.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

A problem I can see is that the only field available in the Tag Options - presumably the configuration to populate to the tags into, is the title of the Taxon Description. The title field being field_taxonomic_name .

If I reference term names in field_taxonomic_name they don't get linked to the terms themselves, perhaps because that field is plain text being a title.

But also, the drop down options on Tag Options section (vertical tab) should offer other fields:

admin/structure/types/manage/spm

image

I thought adding options could be done here:

/admin/structure/types/manage/spm/auto_label

[node:field_taxonomic_name] - Taxonomic Name [node:field_general_description] - General Description

But this didn't result in further fields offered to be populated in Tag Options

image

I can see that default drop down option for Tag Options field seems to be set here: _scratchpads_autotag_save_defaults_for_node_type in sites/all/modules/custom/scratchpads/scratchpads_autotag/scratchpads_autotag.module

Next steps would be to add further fields e.g. field_general_description to see if they then appear in Tag Options on admin/structure/types/manage/spm

therobyouknow commented 2 years ago

ongoing analysis, dev notes

Good morning. Continuing to work on this issue. Will now do the 'next steps' mentioned above.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

I've looked into this further to try to solve the issue.

I'll summarise what I understand the requirement is that is needed to be restored and then go on to comment on the situation with the Scratchpads software.

In summary, this issue is about the restoration of a facility to link words entered into a content field to taxonomy terms that have those names.

e.g.
1- You have a taxonomy fruit with terms apple, orange, pear. 2 - You create content of type Taxon Description and during creation of the content, In one of the Long text type fields (i.e. General Description field (field_general_description) or Morphology field (field_morphology), you write a sentence which includes one or more of the above terms, e.g. "I like fruit salad, especially when it has pear and orange". 3- Click save of your Taxon Description content. 4 - Then, on viewing the content, you look for your "I like fruit salad, especially when it has pear and orange" sentence and observe that pear and orange each link to the page for their respective taxonomy terms.

Now, looking at the Scratchpads software. It looks like this facility has only been code developed Taxonomic Name / field_taxonomic_name in Taxon Description.

This field_taxonomic_name field seems to behave like the title of the content which doesn't make sense to me as a field that would be parsed to embed links to terms in. Moreover the field type of this seemingly title field is a taxonomy term, rather than a text type field that would be parsed. So I am a bit puzzled as to what is going on here.

I also can't imagine how this facility could have ever worked if this is the only field apparently supported in the code.

I have come to the above conclusion by analysing _tagtag_fields_list in tagtag.module and scratchpads_taxonomic_name_field_tag_field_types_alter in scratchpads_taxonomic_name_field module.

I could try to add code to support for Long text type fields such as field_general_description and field_morphology, which I will do. However, I note that there is an entire Drupal custom module dedicated to the field_taxonomic_name: scratchpads_taxonomic_name_field which concerns me that there is more to it than it seems in attempting to support these 2 additional fields.

I have some specific questions for the end users, which I will ask separately in a subsequent smaller comment below, so that they don't have to read all of the above technical analysis before asking my question.

therobyouknow commented 2 years ago

questions for the end-users

@REHarbach @Archilegt

I have some questions for you:

  1. Which fields do you want this facility to be working for and in which content type? Do you want it working for the General Description field and the Morphology field of Taxon Description?
  2. Any other fields you want it working for?
  3. Did this ever work properly for you?
  4. Do you have some content where it has worked now?
  5. I note that https://mosquito-taxonomic-inventory.myspecies.info/ doesn't have any content of type Taxon Description. Did you want this facility working for another content type?
therobyouknow commented 2 years ago

ongoing analysis, dev notes

Just adding entries for the 2 fields didn't work I'm afraid.

I tried adding these 2 lines:...

  $populate_fields['field_morphology'] = "Morphology";
  $populate_fields['field_general_description'] = "General Description";

...after this existing line:...

$populate_fields = _tagtag_fields_list($form['#node_type']->type, 'populate');

in file sites/all/modules/custom/tagtag/tagtag.module

"Back to the drawing board" - I need to think further about how this works.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

2 things appear to be broken in the code which could be the root cause as to why the tagging is not working:

Next steps: further xdebug debugging to confirm and testing. Then to formulate a possible solution and initially test.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

Following on from my analysis noted in my previous comment, mentioning missing and incorrectly name code, on the basis of this, I can't see how this functionality ever worked.

Therefore the outline of the solution is to add new code, that makes use of the Drupal core hook node save/update hook functions, instead of those currently. Those current seem to attempt the same thing - to launch the tagging code on a node save. This could be done with a standard hook save or update. I'll look into implementing this now, should be a small amount of code.

Archilegt commented 2 years ago

Recap on previous comment https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6550#issuecomment-1199269706

Tagging is partially working, what might be wrong is the configuration interface. It seems that some options have been lost. Testing in Myriatrix: The taxon description for Chilopoda already existed. I edited the description, section "Morphology", with the following text: "Body composed of head and trunk." See https://myriatrix.myspecies.info/taxonomy/term/7151/descriptions The terms "body", "head", and "trunk" already existed in the "Morphology" lexicon/glossary. See https://myriatrix.myspecies.info/nontaxonomy/term/38678 Results: 1) Desired result not achieved. The words in section "Morphology" (https://myriatrix.myspecies.info/taxonomy/term/7151/descriptions) are not highlighted and do not link to the "Morphology" glossary.

I now think that I may have missed another essential tagging feature. It seems that the Lexicon module may have built-in tagging features, but they seem not to be working either. Needs investigation. What to investigate: In any site, try the path admin/config/system/lexicon In the case of Myriatrix: https://myriatrix.myspecies.info/admin/config/system/lexicon When prompted, see Lexicon Settings -> General settings -> checkbox Show/mark lexicon terms even if there is no description. See also the explanatory text that appears when hovering over that option.

image

The checkbox was previously unchecked in Myriatrix. I checked it, saved, and then tried to edit and save the Pauropoda taxon description (https://myriatrix.myspecies.info/taxonomy/term/6570/descriptions), to see if the tagging would be forced upon save. Nothing happened, but I am inclined to believe that the checkbox and its code may be part of the answer we need, e.g., using a given lexicon to automatically tag (= mark?) words throughout the website.

See also Lexicon Settings -> Term marking settings -> checkbox Mark terms in content. The drop-down menu Match type could also be tried, especially the option Any substring.

image

I hope that this brings us closer to the answer!

therobyouknow commented 2 years ago

ongoing analysis, dev notes

estimation for further work

3h

day and a half to implement - total 2 days.

Archilegt commented 2 years ago

Additional study material as in https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6595#issuecomment-1265287480

About the automatic taxon recognition in keywords: This is a feature that has been stable and it is working correctly as far as I know. It is doing what we are not managing other vocabularies to do: It brute-forces dictionary-based recognition of scientific names in the "Keywords" field and then takes those recognized terms and adds them as comma-separated values into the field "Taxonomic name". If we want other dictionaries and recognition routines to work, we need to provide output fields where the recognized terms can be added as cs values. I am just mentioning this here because the "Keyword" to "Taxonomic name" pair across Scratchpads represents the successful routine that we want to recreate.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

dev setup

Dev setup issues will impact my ability to work on this today, by up to a few hours. Hopefully they can be resolved asap by me.

image

therobyouknow commented 2 years ago

ongoing analysis, dev notes

dev setup

switching to another machine for now to unblock myself, out of my 5 computers I have with me.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

dev setup

error on first machine was:

image

will have a look at this issue later.

These issues aren't to do with this issue but rather my setup. I'm logging them here for the record so I can give a reason as to why my response timescale is not as quick as I'd like.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

to check function not called - 1h

confirming tag_on_save_tag_update in sites/all/modules/contrib/tag/modules/tag_on_save/tag_on_save.module not called - breakpoint not hit in debugger. Also I inserted a die(); in the code too to be doubly sure.

Next, to look at the hook invoke to see if that code can 'see' the tag_on_save_tag_ui_info which is a hook implementation that calls tag_on_save_tag_update.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

remember where to look, assuming its in the tagtag api file, inspect the hook invoke, debug to see if it is seeing that function that's not being called - yes or no - it is or isn't being called - 2h

Analysing tag_form_node_type_form_alter in sites/all/modules/contrib/tag/tag.module

therobyouknow commented 2 years ago

ongoing analysis, dev notes

I looked into tag_form_node_type_form_alter in sites/all/modules/contrib/tag/tag.module which has a number of module_invoke_all function calls, but breakpoint for first line of this function not being hit either, it would appear.

By the way I'm doing a node save where I expect this hook to be invoked.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

now, I'm getting somewhere. The other function I mentioned earlier is used in config, not a node save. This one below is one of those I think I should be looking at and it does indeed xdebug break on node save:

image

tag_form_alter in sites/all/modules/contrib/tag/modules/tag_on_save/tag_on_save.module

Will continue to investigate.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

2 questions I have for myself for my analysis:

~1 - this line looks incorrect: if(isset($form['#node_edit_form']) && $form['#node_edit_form']){~

~The $form array never contains that index id. according to what I observered with the xdebug breakpoints. The code inside the if never runs as a result. So we need to replace the index.~

~2 - what do we replace the index with. The debugger shows that there is a spm content type in one of the form arrays that one of the calls to this function is made. We need something more generic I'd say which covers all content types where we want to have the word to tag insertion.~

To further re-affirm that this function needs work to fix, inside the if is: $search_services = module_invoke_all('tag_ui_info'); which should call a hook in tag_on_save sub module that will then call the tag_on_save_tag_update word to tag code.

update

Above 1 and 2 points incorrect. The if(isset($form['#node_edit_form']) && $form['#node_edit_form']){ does work. But one question I have now is when should this code run: when the form is being built or when it is submitted?

therobyouknow commented 2 years ago

ongoing analysis, dev notes

image

therobyouknow commented 2 years ago

ongoing analysis, dev notes

image

therobyouknow commented 2 years ago

ongoing analysis, dev notes

image

therobyouknow commented 2 years ago

ongoing analysis, question to scratchpad user

Additional study material as in https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6595#issuecomment-1265287480

About the automatic taxon recognition in keywords: This is a feature that has been stable and it is working correctly as far as I know. It is doing what we are not managing other vocabularies to do: It brute-forces dictionary-based recognition of scientific names in the "Keywords" field and then takes those recognized terms and adds them as comma-separated values into the field "Taxonomic name". If we want other dictionaries and recognition routines to work, we need to provide output fields where the recognized terms can be added as cs values. am just mentioning this here because the "Keyword" to "Taxonomic name" pair across Scratchpads represents the successful routine that we want to recreate.

Thank you @Archilegt for advising of this existing functionality. Here's a picture of what I think you have said:

image

Is this correct? Please show me an example of this on your site or someone elses.

And here is a picture of what I am fixing for this issue 6550 here:

image

Any comments let me know. Thank you!

therobyouknow commented 2 years ago

ongoing analysis, dev notes

potential root cause as to why tagging words not working (this issue)

in function tag_submit_form the index used for $search_services array is not correct, because it is an index that doesn't exist in the array.

image

The $search_services array contains the tagging code, having had module_invoke_all which calls tag_on_save_tag_ui_info

image

Next steps:

REHarbach commented 2 years ago

I confess this is all gobbly-gook to me. I do not understand the two questions. As for replacement of "index", this brings to mind the word "lexicon" that was used before the site was moved to https and myspecies. What changed when the site was moved?

Ralph E. Harbach

Scientific Associate

Natural History Museum

London SW7 5BD, UK

Tel. +44 (0)20 7942 5768

Fax. +44 (0)20 7942 2559

http://www.nhm.ac.uk/our-science/departments-and-staff/staff-directory/ralph-harbach.htmlhttp://www.nhm.ac.uk/research-curation/stall-directory/entomology/r-harbach/index.html

https://mosquito-taxonomic-inventory.myspecies.info/


From: therobyouknow @.> Sent: 03 October 2022 15:50 To: NaturalHistoryMuseum/scratchpads2 @.> Cc: Ralph Harbach @.>; Mention @.> Subject: Re: [NaturalHistoryMuseum/scratchpads2] Morphological terms in taxon pages not linked to terms in the Anatomical Glossary [Related to #6220] (Issue #6550)

ongoing analysis, dev notes

2 questions I have for myself for my analysis:

1 - this line looks incorrect: if(isset($form['#node_edit_form']) && $form['#node_edit_form']){

The $form array never contains that index id. according to what I observered with the xdebug breakpoints. The code inside the if never runs as a result. So we need to replace the index.

2 - what do we replace the index with. The debugger shows that there is a spm content type in one of the form arrays that one of the calls to this function is made. We need something more generic I'd say which covers all content types where we want to have the word to tag insertion.

To further re-affirm that this function needs work to fix, inside the if is: $search_services = module_invoke_all('tag_ui_info'); which should call a hook in tag_on_save sub module that will then call the tag_on_save_tag_update word to tag code.

— Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FNaturalHistoryMuseum%2Fscratchpads2%2Fissues%2F6550%23issuecomment-1265582364&data=05%7C01%7Cr.harbach%40nhm.ac.uk%7C57ca88ab00fa42db008b08daa54e933f%7C73a29c014e78437fa0d4c8553e1960c1%7C1%7C0%7C638004054140686029%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DiK2bP%2B8bqExhT4jsjYqzvzyvDlzjRbgaoKV0KMgv2c%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAXCNV4YB52RS65T76VXZB7DWBLXCHANCNFSM5WVQNT5A&data=05%7C01%7Cr.harbach%40nhm.ac.uk%7C57ca88ab00fa42db008b08daa54e933f%7C73a29c014e78437fa0d4c8553e1960c1%7C1%7C0%7C638004054140686029%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=IKcCenTN4vkOQlGmSmPMdhACrSBS6pXKKa2k9x9NAG8%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

therobyouknow commented 2 years ago

Don't worry Ralph! Apologies as the notes I'm making are technical. This is so it is the quickest for me to pick up from where I last left off, to share technical knowledge with other devs and my future self and to generally show that the issue is being worked on for your reassurance and for my bosses! :)

I always precede each technical comment entry with the heading title ongoing analysis, dev notes - when you see this please feel free to ignore the comment entry. If I have a question for the user like yourself, I'll indicate in the heading title.

Thank you!

therobyouknow commented 2 years ago

potential fix on release sprint development branch rob/release-sprint-2022-10-03-2022-10-10. Now to test.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

debug testing outcome - more coding work needed

tag_on_save_tag_form_alter is the callback function name being constructed in tagtag_form_alter, which doesn't exist in the code base.

But tag_on_save_tag_update does exist which calls the tagtag_add_tags function, but I haven't found anything that calls it yet, so it won't run.

therobyouknow commented 2 years ago

ongoing analysis, dev notes

getting somewhere - this code below where the breakpoint is hit, is called on clicking save on a node.

The debugger shows the tag_on_save tag_on_save_tag_update function is present in the array.

But my past breakpoint sets on this function have shown it not to be called. So I will simplify this code to help me debug in smaller steps to see if I can pinpoint an issue.

image
therobyouknow commented 2 years ago

ongoing analysis, dev notes

The code that adds the submit handler we need calling, isn't being called. My thinking is that there is an incorrect assumption being made about the construction of names to index into these arrays.

image

therobyouknow commented 2 years ago

Re-doing https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6550#issuecomment-1246836931 too see if we can get the fields to be populated.

Commit commit a715f73c330f7f7e0f68f45a803c40d19050f933 (HEAD -> rob/release-sprint-2022-10-03-2022-10-10, origin/rob/release-sprint-2022-10-03-2022-10-10) results in:

image

So I'll select General Description, save and then re-save my node to see if it is populated as per https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6550#issuecomment-1266720598

therobyouknow commented 2 years ago

This hasn't worked. I can't spend any more time on this ticket.

The code seems to be more complicated than necessary to do: https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6550#issuecomment-1266720598

And the config form in section 'Tag options' is not as straightforward as it should be:

/admin/structure/types/manage/spm

image

The form shows 3 fields: 1 - fields to search 2 - taxonomies 3 - fields to populate

If we're doing https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6550#issuecomment-1266720598 Why then do we need "1 - fields to search" . We only need the fields we want to link words in text to the tag "3 - fields to populate" iin the list above, and to know what tags to match with the text "2 - taxonomies" in the list above. And, no, we don't need to over engineer with UX just to make the form clearer.

So I'm pausing the work on this ticket for now because a) the form settings are not clear and appear to have additional information and don't explain why b) the code is overly complex and reasonable attempts at repair have not worked c) this has taken a large amount of time out of the sprint so I need to put time into other tickets

therobyouknow commented 2 years ago

ongoing analysis, usage process understanding and dev notes

Updated understanding following study of custom module tagtag contrib module counterpart https://www.drupal.org/project/autotag:

  1. we specify the tags we want to search for in content fields
  2. we specify which content fields we want to do that search within, I call this "input fields", note plural
  3. we specify the output as to where the tagged words in those fields, i.e the output field (note singular) to output to that tagged text. Presumably because we can select multiple input fields then the block of text with words that link to found tags by same name will be concatenated from all the fields.

This will need a new diagram from me to explain this. A picture paints...

Above understanding based on:

An additional option is provided on a content type configuration page

admin/structure/types/manage/page admin/structure/types/manage/spm

specify which text fields should be searched for terms in specified vocabularies, and which field should then be populated with the results

image

This updated understanding has let me revisit the code to continue to troubleshoot the issue rather than consider a new module. Analysis and troubleshooting ongoing.

REHarbach commented 2 years ago
  1. As far as I can recall, the facility previously worked for all content type, except content under literature, valid species and What's new on the main menu.
  2. I don't know what you mean by "fields". It should work for content in all content except as noted above.
  3. Yes, this worked properly before being switched to myspecies and https. In cases where terms were not to be linked, e.g. the surname "Root". the word was enclosed in [no-lexicon] [/no-no-lexicon]. Those commands are now showing in places in the content.
  4. As far as I know, it is not working anywhere in the site. I have not seen any words highlighted in blue to indicate a link, but I have seen many of the commands to prevent a link.
  5. As I mentioned some time ago, my site was one of the very first to be developed, and for that reason it deviates from the standard format, i.e. the taxon pages are uniquely formatted. If I don't currently have "Taxon Description", then it is not needd.

Ralph E. Harbach

Scientific Associate

Natural History Museum

London SW7 5BD, UK

Tel. +44 (0)20 7942 5768

Fax. +44 (0)20 7942 2559

http://www.nhm.ac.uk/our-science/departments-and-staff/staff-directory/ralph-harbach.htmlhttp://www.nhm.ac.uk/research-curation/stall-directory/entomology/r-harbach/index.html

https://mosquito-taxonomic-inventory.myspecies.info/


From: therobyouknow @.> Sent: 14 September 2022 12:23 To: NaturalHistoryMuseum/scratchpads2 @.> Cc: Ralph Harbach @.>; Mention @.> Subject: Re: [NaturalHistoryMuseum/scratchpads2] Morphological terms in taxon pages not linked to terms in the Anatomical Glossary [Related to #6220] (Issue #6550)

@REHarbachhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FREHarbach&data=05%7C01%7Cr.harbach%40nhm.ac.uk%7C19fa89e02b544729c83e08da96438a61%7C73a29c014e78437fa0d4c8553e1960c1%7C1%7C0%7C637987514070831116%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rFpUSA93c6GdxPHKu1wojXiGgDgAbR%2FhFVXdBmUoSeE%3D&reserved=0 @Archilegthttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FArchilegt&data=05%7C01%7Cr.harbach%40nhm.ac.uk%7C19fa89e02b544729c83e08da96438a61%7C73a29c014e78437fa0d4c8553e1960c1%7C1%7C0%7C637987514070831116%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=M%2BcRCM5xyr5psuk4nZHMMQUKCGzogQbq1pa9%2B64SDV8%3D&reserved=0

I have some questions for you:

  1. Which fields do you want this facility to be working for and in which content type? Do you want it working for the General Description field and the Morphology field of Taxon Description?
  2. Any other fields you want it working for?
  3. Did this ever work properly for you?
  4. Do you have some content where it has worked now?
  5. I note that https://mosquito-taxonomic-inventory.myspecies.info/https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmosquito-taxonomic-inventory.myspecies.info%2F&data=05%7C01%7Cr.harbach%40nhm.ac.uk%7C19fa89e02b544729c83e08da96438a61%7C73a29c014e78437fa0d4c8553e1960c1%7C1%7C0%7C637987514070831116%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=dRPpijK%2Foc5h%2BkmUDr1Qj4JaJwcgxi11ezmIa3Mn3JE%3D&reserved=0 doesn't have any content of type Taxon Description. Did you want this facility working for another content type?

— Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FNaturalHistoryMuseum%2Fscratchpads2%2Fissues%2F6550%23issuecomment-1246622594&data=05%7C01%7Cr.harbach%40nhm.ac.uk%7C19fa89e02b544729c83e08da96438a61%7C73a29c014e78437fa0d4c8553e1960c1%7C1%7C0%7C637987514070831116%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Kdh%2BX%2BaKjLuM1u4NogfthTAQTM%2F6ofm7ig6LJVx9UiQ%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAXCNV44XQINEHCWX6UFNPJTV6GYSXANCNFSM5WVQNT5A&data=05%7C01%7Cr.harbach%40nhm.ac.uk%7C19fa89e02b544729c83e08da96438a61%7C73a29c014e78437fa0d4c8553e1960c1%7C1%7C0%7C637987514070831116%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=GyrbFcJ706HxBbHo3j%2BcJ%2BcKMFPzmMhER%2FRAfkKwyfI%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>