2 Replies Latest reply on Oct 28, 2016 1:46 AM by Liphou

    [JS] Dictionary

    Liphou Level 2



      Est-il possible de détecté, une citation anglaise ou autre dans un paragraphe exemple Français (dictionnaire Fr) sans dictionnaire appliqué à la citation à l'aide d'un script ou autre?








      Is it possible to detected, an English quotation or another example in a paragraph French (Fr dictionary) without a dictionary applied to the citation with a script or another?

      Thank you


        • 1. Re: [JS] Dictionary
          Trevorׅ Adobe Community Professional

          Hi Lipou,


          This is a start.

          There are probably much better ways.

          I've used an object dictionary which you obviously would not want to do. You would probably import from a Hunspell dictionary or the likes.

          They would need some interpretation.


          Here's 3 words from that dictionary





          The /Y means that abundantly is valid one would have to look up there other codes







          // by Trevor www.creative-scripts.com
          var doc, dic, c, l, n, i, stories, words, englishWords, englishWord, minPhraseLength, nonEnglishReg;
          doc = app.activeDocument;
          stories = doc.stories.everyItem().getElements().slice();
          englishWords = [];
          minPhraseLength = 2;
          nonEnglishReg = /[^-A-za-z0-9]/g;
          dic = getDictionary();
          l = stories.length;
          for (c = 0; c < l; c++) {
              words = stories[c].words.everyItem().getElements().slice();
              i = words.length;
              for (n = 0; n < i; n++) {
                  if (words[n].contents.replace(nonEnglishReg, '') in dic) { // You might want to add .toLowerCase()
                  } else {
              englishPhrase(); // for English phrase at end of story
          function englishPhrase() {
              if (englishWords.length >= minPhraseLength) {
                  while (englishWord = englishWords.pop()) {
                      englishWord.fillColor = doc.colors.itemByName('Magenta');
                  return true;
              if (englishWords.length) {
                  englishWords.length = 0;
          function getDictionary() {
              // you would normally fetch the dictionary from a dictionary file
              // for simplicities sake we are not
              var myDic = {
                  'added': true,
                  'English': true,
                  'here': true,
                  'some': true,
                  'words': true,
              return myDic;



          Screen Shot 2016-10-27 at 15.54.26.png


          Screen Shot 2016-10-27 at 15.56.30.png

          • 2. Re: [JS] Dictionary
            Liphou Level 2

            Thank you Trevor,

            Beautiful example and a good approach.

            After some research and testing, I will look to test the resulat the "Dynamic spelling"

            If the spelling is incorrect, test with another dictionary, to have a reponce "True".

            This now I recheche the order and method to do it tested.

            to be continued ...


            Merci Trevor,


            Belle exemple et une bonne approche.


            Après quelque recherche et test, je vais regarde pour tester avec le resulat du "Dynamic spelling"


            Si l'orthographe n'est pas exacte, tester avec un autre dictionnaire, pour avoir une reponce "Vrai".


            Maitenant, je recheche le commande et methode pour y faire les testes.


            à  suivre ...