7 Replies Latest reply on Dec 2, 2014 11:46 PM by Sudha K

    Hyphenated word in CS6

    Sudha K Level 1

      Hi,

       

        If a word contains more than 1 lines, it is hyphenated. But, for the below occurrences is not hyphenated but its also reporting as hyphenated when using the line concept.

       

      Screen shot 2014-12-02 at 11.17.18 AM.png

       

      Screen shot 2014-12-02 at 11.17.04 AM.png

       

      1. if url contains more than 1 line

      2. word contains dot (.) . if it contains more than 1 line

       

      But actually its not hyphenated

       

      Can anyone help me.

       

      Thanks in advance

      Sudha K

        • 1. Re: Hyphenated word in CS6
          Chinnadk Level 4

          Hi Sudha,

           

          Try this.

           

          var sel = app.selection[0],
              paras = sel.parentTextFrames[0].paragraphs.everyItem().getElements(),
              str = "";
          for(var i =0;i<paras.length;i++)
          {
              var _lines = paras[i].lines.everyItem().getElements();
              if(_lines.length > 1)
              {
                  for(var j =0;j<_lines.length;j++)
                  {
                       if(_lines[j].words[-1].lines.length >1 && _lines[j].words[-1].contents.indexOf(".") == -1)
                       {
                              str +=_lines[j].words[-1].contents + "\r";
                           }
                      }
                  }
              }
          alert(str);
          

           

          Regards,

          Chinna

          • 2. Re: Hyphenated word in CS6
            Sudha K Level 1

            Hi,

             

              Thanks for ur reply...

             

              If i use the above code, both url and the word contains dot (".") is skipped.  But for below case, the word software is hyphenated but its contains dot so its skipped. But i want to report this word.

             

            Also I need to get the hyphenated word from tables and footnotes.

             

             

            Screen shot 2014-12-03 at 10.16.40 AM.png

             

            - Sudha K

            • 3. Re: Re: Hyphenated word in CS6
              Chinnadk Level 4

              Hi Sudha,

               

              Try this,

               

              var doc = app.activeDocument;
              var _stories = doc.stories.everyItem().getElements();
              var str = "";
              for(var k =0;k<_stories.length;k++)
              {
                  var paras = _stories[k].paragraphs.everyItem().getElements(),
                      fn = _stories[k].footnotes.everyItem().getElements(),
                      _tables = _stories[k].tables.everyItem().getElements();
                  findhyphenation(paras)
                  for(var l=0;l<fn.length;l++)
                  {
                      var paras1 = fn[l].paragraphs.everyItem().getElements();
                      findhyphenation(paras1)
                      }
                  for(var m=0;m<_tables.length;m++)
                  {
                      var _cells = _tables[m].cells.everyItem().getElements();
                      for(var n=0;n<_cells.length;n++)
                      {
                          var paras2 = _cells[n].paragraphs.everyItem().getElements();
                          findhyphenation(paras2)
                          }
                      }
                  }
              function findhyphenation(paras)
              {
                  for(var i =0;i<paras.length;i++)  
                  {  
                      var _lines = paras[i].lines.everyItem().getElements();  
                      if(_lines.length > 1)  
                      {  
                          for(var j =0;j<_lines.length;j++)  
                          {
                               if(_lines[j].words[-1].lines.length >1 && _lines[j].words[-1].contents.indexOf(".") == -1&&_lines[j].words[-1].contents.indexOf(".") != _lines[j].words[-1].characters.length-1)  
                               {  
                                      str +=_lines[j].words[-1].contents + "\r";  
                                   }  
                              }  
                          }  
                      }
                  }
              alert(str); 
              

               

              Regards,

              Chinna

              • 4. Re: Hyphenated word in CS6
                Sudha K Level 1

                Hi Chinna,

                 

                  Thank you....

                 

                  Its working for tables and footnote.  But for the above attachment  (software.) is skipped from report. Its hyphenated word so it should be reported.

                 

                  Our condition is word's lines is greater than 1 is hyphenated. when using condition ".",  If a word contains 2 lines using any other special character it will be reported as hyphenated.  But it should not report know.Screen shot 2014-12-03 at 11.32.38 AM.png(Samples created for testing purpose)

                 

                  In the above attachment We should reported only consoleWriteLine(     (2nd one).  1st and 3rd one is not hyphenated but it contains 2 lines.

                 

                - Sudha K

                • 5. Re: Hyphenated word in CS6
                  Sudha K Level 1

                  Hi Chinna,

                   

                    If i changed the condition like this, Its working for the word "software."

                   

                  function findhyphenation(paras) 

                      for(var i =0;i<paras.length;i++)   

                      {   

                          var _lines = paras[i].lines.everyItem().getElements();   

                          if(_lines.length > 1)   

                          {   

                              for(var j =0;j<_lines.length;j++)   

                              {                  

                                   if(_lines[j].words[-1].lines.length >1 &&(( _lines[j].words[-1].contents.indexOf(".") == -1) || (_lines[j].words[-1].contents.indexOf(".") == _lines[j].words[-1].characters.length-1)))

                                   {   

                                          str +=_lines[j].words[-1].contents + "\r";   

                                       }   

                                  }   

                              }   

                          } 

                      } 

                   

                    But my doubt is, will it work for all cases (If contain any other special character) when the non-hyphenated word with two lines...

                   

                  - Sudha K

                  • 6. Re: Re: Hyphenated word in CS6
                    Chinnadk Level 4

                    Hi Sudha,

                     

                    Try now,

                     

                    var doc = app.activeDocument,
                        _stories = doc.stories.everyItem().getElements(),
                        str = "";  
                    for(var k =0;k<_stories.length;k++)  
                    {  
                        var paras = _stories[k].paragraphs.everyItem().getElements(),  
                            fn = _stories[k].footnotes.everyItem().getElements(),  
                            _tables = _stories[k].tables.everyItem().getElements();  
                        findhyphenation(paras)  
                        for(var l=0;l<fn.length;l++)  
                        {  
                            var paras1 = fn[l].paragraphs.everyItem().getElements();  
                            findhyphenation(paras1)  
                            }  
                        for(var m=0;m<_tables.length;m++)  
                        {  
                            var _cells = _tables[m].cells.everyItem().getElements();  
                            for(var n=0;n<_cells.length;n++)  
                            {  
                                var paras2 = _cells[n].paragraphs.everyItem().getElements();  
                                findhyphenation(paras2)  
                                }  
                            }  
                        }  
                    function findhyphenation(paras)  
                    {  
                        for(var i =0;i<paras.length;i++)    
                        {    
                            var _lines = paras[i].lines.everyItem().getElements();    
                            if(_lines.length > 1)    
                            {    
                                for(var j =0;j<_lines.length;j++)    
                                {  
                                     if(_lines[j].words[-1].lines.length >1)    
                                     {    
                                        var _char = _lines[j].words[-1].characters,
                                            bool = true;
                                        for(var o=0;o<_char.length-1;o++)
                                        {
                                            if(_char[o].contents == ".")
                                            {
                                                bool = false;
                                                break;
                                                }
                                            }
                                        if(bool == true)
                                        {
                                            str +=_lines[j].words[-1].contents + "\r";    
                                            }
                                         }    
                                    }    
                                }    
                            }  
                        }  
                    alert(str);  
                    

                     

                    Regards,

                    Chinna

                    • 7. Re: Hyphenated word in CS6
                      Sudha K Level 1

                      Hi Chinna,

                       

                         In the above code, If a word contains 2 lines and last character is "." and we skipped that dot, treated it as a hyphenated word.  Where as, a word contains 2 lines and a word contains dot inbetween the word is treated as non-hyphenated word right???

                       

                       

                      Screen shot 2014-12-03 at 11.32.38 AM.png

                       

                       

                      In this image, Console/WriteLin( is reported as hyphenated word.  But its not hyphenated.

                       

                      If we use this condition, it will work wrongly when any other character breaks word... Its my ques....

                       

                      - Sudha K