Link all unlinked mentions with one click

Curious why my previous post was flagged and hidden - are ChatGPT mentions not welcome?

1 Like

Yeah why the hell was that comment flagged and hidden? I demand an explanation

This is correct. We have had to deal with numerous instances of people trying to be helpful by copying and pasting false info from LLMs. Then other users take that and run with it, causing all sorts of trouble.

Please don’t do it. Thanks for understanding!

1 Like

I’ll just add, while this is a fairly simple Python snippet that you can read and understand, you’ve posted a code snippet that you don’t necessarily understand (I don’t know you or your skill level with code). A snippet that traverses multiple directories and modifies files.

This is relatively safe. But in unskilled hands, and for someone who doesn’t have good backups, it could mangle a vault. It’s not our job as moderators to do code reviews. So yes, hallucinated GPT answers are not encouraged.

Furthermore as a Python developer, let me give some specific feedback:

  1. Why is glob imported? Because you are running code that has been blindly mushed together from multiple sources.

  2. Do you know what f.read() does? It reads the entire file into a string. On most notes this would be perfectly fine. On an enormous file, this could cause memory issues. True, it would have to be pretty huge.

A better Python pattern would be to iterate over the lines:

with open() as note:
    for line in note:
        # do your loop on each line
  1. Do you understand what the IGNORECASE flag does? It’s pretty clear by reading it that it would ignore case, right?

replaces all instances of " ProGuides " with " [[ProGuides]]

No. That is false. It would replace all instances of ProGuides, proguides, PROGUIDES or PrOGuIdEs with [[ProGuides]].

It would also replace OhWhoopsyDoodleProGuides with OhWhoopsyDoodle[[ProGuides]].

Which in this one specific example is pretty safe. But if someone was trying to replace a fairly generic word, or an easily-stemmed word, again they could mangle their vault. This wasn’t bug-tested. This wasn’t thought through. You didn’t seem to understand the code you posted.


So if you don’t know the answer to something, please don’t post a hallucinated auto-generated answer.

Did that satisfy your concerns?

3 Likes

I ran the code and it worked fine. The search string includes whitespace before and after the string so it wouldn’t replace OhWhoopsyDoodleProGuides as you suggest, as it specifically searches for the whitespace as well as the text string. I’m not an expert coder and I was just trying to help. I don’t have a problem with the post being removed and understand your policy and why you are enforcing it, but I have to say I found your reply really hostile and condescending.

No problem

Apologies to you, I can see what you mean. Most of the tone of my reply was directed at obsequious “demanding” an explanation; not at you.

I’m not trying to belittle your skill or insult you. I’m explaining why we don’t encourage GPT answers like this in general. There are consequences and potential bugs one doesn’t consider when they post code they haven’t written.

1 Like

All good, no worries.

Ryan’s reply was sufficient.

I don’t know if your answer was rude, but the censoring of Chris’s comment without explanation was rude, IMO. And Ryan addressed my concern.

Anyway, thanks.

hi,
indeed i want to start my post by saying:

time flies, now i am empowered by GPXX…, thus i can make the topic happen by myself.

HOWEVER, now i found that is not a good idea.

i got many notes, and if every item was backlinked, sometimes it make

  1. too many backlinks,
    OR 2. it become out of focus: suppose you got [[hypoparathyroidism]] and [[pseudohypoparathyroidism]], the plugin wont know how should it back link to, for a text of ‘‘hypoparathyroidism’’

so, manually backlink is a fine tune, is a preferred method for me now.
but it wont hurt if there is a button that backlink all.

I’d be interested in a command to wrap all instances of a selected word with double square brackets without the need to manually write it in search & replace.

So the command could be added to a button somewere or a shortcut, using the editing toolbar plugin or commander or whatever else.

It would enable you to select a word, and with the click of a button, link all instances of that word.