Modify stop words list for HTML5 output

This forum is for all Flare related Tips and Tricks.
Have a tip or trick you use while working in Flare? Share it here.

Modify stop words list for HTML5 output

Postby JRtechw on Wed Aug 28, 2019 6:38 pm

Yes, it’s possible, but it does involve making an extremely minor change to one of Flare’s main .js files and overwriting this file in the output. I’m not sure if this kind of solution is frowned upon in the user forums, so if this needs to be quietly excised, so be it.

However, in my defence:

1. It’s such a minor change it doesn’t even deserve to be called a ‘hack’. You don’t need to know Javascript in the slightest. All you need is Notepad. I'd say it's about equivalent to over-riding skin styling with custom CSS.

2. The business case for being able to modify the stop word list is so phenomenally strong that I don’t care that much anyway. Just adding three stop words to the default list stripped a huge number of junk results out of our Knowledge Base search and our users love the new search.

So, here it is. This works for Flare 2019 at least, and I'm pretty sure it would work for Flare 2018 versions too.

1. Generate your HTML5 output as normal.
2. Go to the Scripts folder in your output: Output / <username> / <target> / Resources / Scripts.
3. Copy the file MadCapAll.js.
4. Open this file in a basic text editor.
5. Search for ‘stop’. You’ll be taken to this chunk of code:

Code: Select all

(It should be the first result, but if it isn’t, keep searching until you find it.)

6. Add or delete the stop words you want, within double quotes and separated by commas. Don’t worry about ordering. Don’t edit anything outside the parentheses.
7. Save the file with the same name in a local folder.
8. Add a post-build command in your HTML5 Target > Build Events tab:

Code: Select all
copy /Y "C:\<path>\MadCapAll.js" "$(OutputDirectory)\Resources\Scripts\"

Where <path> is where you saved the modified .js file. The /Y forces the overwrite without prompting.

9. Rerun your build and publish and check the difference in search in the output. Your new stop words should produce no results.
10. Distribute the modified file and path to any collaborative authors. If you use source control, each author working on the project will need to put the modified file in the same local path.
11. Each time a new build of Flare is released, repeat the edit of the MadCapAll.js file to capture any new build changes.

That’s it.

Possible Troubleshooting

If nothing has changed, check the timestamp of the MadCapAll.js file in the output > Scripts folder. It should be different to the other files in the folder.

If it’s the same, check your build log to see if your post build command worked or failed.

If it’s different, view the output project in the browser, right-click, and select Inspect. At the bottom of the Inspection window (in Chrome, might be different for other browsers) check the Console tab for error messages. If you see any Javascript errors, you might have accidentally edited outside of the array definition. Start again. It's also possible that you may have saved the file with a different encoding, but this *shouldn't* matter.

I strongly recommend editing MadCapAll.js from the Output folder rather than the original source file that is loaded during build.

Hope this is useful.
Propeller Head
Posts: 61
Joined: Thu Oct 05, 2017 8:08 pm

Re: Modify stop words list for HTML5 output

Postby WriterAndrew on Fri Aug 30, 2019 2:23 am

Sounds interesting...
I didn't see it mentioned in your post, but what "three stop words" did you add that stripped lots of your junk results? (If they worked so well for you, they might work equally well for others...)
Propeller Head
Posts: 37
Joined: Tue Mar 05, 2019 2:43 am

Re: Modify stop words list for HTML5 output

Postby JRtechw on Sun Sep 01, 2019 2:43 pm

They were 'I', 'how', and 'which' (or at least I'm pretty sure the third one was 'which'). Definitely adding 'I' helped, because most Google-esque search attempts seemed to be 'how do I..', 'how can I...', and variations thereof.
Propeller Head
Posts: 61
Joined: Thu Oct 05, 2017 8:08 pm

Re: Modify stop words list for HTML5 output

Postby kodster28 on Thu Mar 05, 2020 8:55 am

Howdy all,

Thanks JRtechw for your solution.

I made some improvements to make it a bit easier for my team:
1. Created a python program to add stop words
2. Built an .exe file to run the program for other people on our team
3. Added the .exe file to a post-build event

I've included the files in a Google Drive folder if they're helpful: ... sp=sharing

I'll at least have to double-check the program every time Flare creates a new release, but it's a start!
Jr. Propeller Head
Posts: 3
Joined: Wed Mar 04, 2020 4:19 pm

Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 2 guests