logo elektroda
logo elektroda
X
logo elektroda

Program Options for Detecting Repeated Words in Long Text: Highlighting Tools & More

michalak92 42126 18
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 7093702
    michalak92
    Level 18  
    Is there any program that checks if there are words that repeat in a given text? Ie. I introduce some long text, and it would somehow highlight repeated words, etc.
  • ADVERTISEMENT
  • #2 7093715
    fuutro
    Level 43  
    Word has this feature turned on by default.
  • #3 7093738
    michalak92
    Level 18  
    Where ? I don't mean the usual repetitions like "I bought a new car yesterday", but repetitive words in different parts of the text.
  • ADVERTISEMENT
  • #4 7093859
    sens
    Level 14  
    If you want how many times a specific string of characters has occurred, the "change" function and enter the same string of characters you are looking for and the same to change - it will count the number of times it has been changed.
  • #5 7093906
    michalak92
    Level 18  
    The point is that I have such a long list of words in Word and I would like to check what words are repeated there (and they certainly are) so as not to unnecessarily print it.
  • #6 7093917
    sens
    Level 14  
    How many words are there in the entire text?
    If not much, I will try to write something in VB quickly ... when I find a moment ...
  • #7 7093968
    michalak92
    Level 18  
    About 500.
  • ADVERTISEMENT
  • Helpful post
    #9 7096711
    sens
    Level 14  
    It will count and save in a new document :)
    Tested in MSWord 2003
    I hope it will come in handy and that's what it was about :)
    Obviously as in VB in msword

    
    
             Dim Slowo As String           'slowo z tekstu - szukane
             Const max_ilo_slow = 9000              'ilosc maksymalna slow ... ograniczenia :(
             Dim Slowa(max_ilo_slow) As String      'tablica z slowami
             Dim Licznik_slowa(max_ilo_slow) As Integer      'tablica z iloscia wystapienia konkretnego slowa
             Dim Unikalne_licznik As Integer             'ilosc slow unikalnych w tekscie
             Dim Sortowanie As Boolean              'sortowanie - po ilosci wystapien
             Dim Ilosc_slow As Long                 'ilosc slow w dokumencie - wszystkie
             Dim Wylaczenia As String             'Slowa ktore wylaczyc z liczenia
             Dim F As Boolean               'flaga pomocnicza
             Dim j, k, l, Temp As Integer       'liczniki itp.
             Dim TmpSlowo As String                ' Tyczasowe slowo
    
             Wylaczenia = ""
             Wylaczenia = InputBox$("Wpisz słowa które chcesz wyłączyć z przesukiwanego tekstu, słowa umieść w nawiasach [ ].", " Wyłączone słowa", "")
    'poniżej przykład jak wpisać:
    '"[z][i][do][o][w]" itp
             ' pytanie czy sortować po ilości wystąpień
             Sortowanie = True
    
             Selection.HomeKey Unit:=wdStory
             System.Cursor = wdCursorWait
             Unikalne_licznik = 0
             Ilosc_slow = ActiveDocument.Words.Count
             WSlowa = ActiveDocument.Words.Count
    
             ' liczymy :)
             For Each aword In ActiveDocument.Words
                 Slowo = Trim(aword)
                 If Slowo < "A" Or Slowo > "z" Then Slowo = ""
                 If InStr(Wylaczenia, "[" & Slowo & "]") Then Slowo = ""
                 If Len(Slowo) > 0 Then
                     F = False
                     For j = 1 To Unikalne_licznik
                         If Slowa(j) = Slowo Then
                             Licznik_slowa(j) = Licznik_slowa(j) + 1
                             F = True
                             Exit For
                         End If
                     Next j
                     If Not F Then
                         Unikalne_licznik = Unikalne_licznik + 1
                         Slowa(Unikalne_licznik) = Slowo
                         Licznik_slowa(Unikalne_licznik) = 1
                     End If
                     If Unikalne_licznik > max_ilo_slow - 1 Then
                         j = MsgBox("W tekście jest więcej unikalnych słów niż podałeś. Zwiększ maksymalną ilość słów", vbOKOnly)
                         Exit For
                     End If
                 End If
                 Ilosc_slow = Ilosc_slow - 1
                 StatusBar = "Pozostało: " & Ilosc_slow & "     Unikalnych: " & Unikalne_licznik
             Next aword
    
             ' sortowanie
             For j = 1 To Unikalne_licznik - 1
                 k = j
                 For l = j + 1 To Unikalne_licznik
                     If (Not Sortowanie And Slowa(l) < Slowa(k)) Or (Sortowanie And Licznik_slowa(l) > Licznik_slowa(k)) Then k = l
                 Next l
                 If k  j Then
                     TmpSlowo = Slowa(j)
                     Slowa(j) = Slowa(k)
                     Slowa(k) = TmpSlowo
                     Temp = Licznik_slowa(j)
                     Licznik_slowa(j) = Licznik_slowa(k)
                     Licznik_slowa(k) = Temp
                 End If
                 StatusBar = "Sortowanie: " & Unikalne_licznik - j
             Next j
    
             ' Wyniki w nowy dokument :) i jako tabelke :)
             tmpName = ActiveDocument.AttachedTemplate.FullName
             Documents.Add Template:=tmpName, NewTemplate:=False
             Selection.ParagraphFormat.TabStops.ClearAll
             With Selection
                 For j = 1 To Unikalne_licznik
                 .TypeText Text:=Slowa(j) & vbTab & Trim(Str(Licznik_slowa(j))) & vbCrLf
                 Next j
             End With
             ActiveDocument.Range.Select
             Selection.ConvertToTable
             Selection.Collapse wdCollapseStart
             ActiveDocument.Tables(1).Rows.Add BeforeRow:=Selection.Rows(1)
             ActiveDocument.Tables(1).Cell(1, 1).Range.InsertBefore "Słowo"
             ActiveDocument.Tables(1).Cell(1, 2).Range.InsertBefore "Ilość wystąpień"
             ActiveDocument.Tables(1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
             ActiveDocument.Tables(1).Rows.Add
             ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count, 1).Range.InsertBefore "Ilość wszystkich słów w dokumencie"
             ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count, 2).Range.InsertBefore WSlowa
             ActiveDocument.Tables(1).Rows.Add
             ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count, 1).Range.InsertBefore "Ilość unikalnych słów w dokumencie"
             ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count, 2).Range.InsertBefore Trim(Str(Unikalne_licznik))
             System.Cursor = wdCursorNormal
         Selection.HomeKey wdStory
    
  • #10 7096824
    michalak92
    Level 18  
    OK thanks. And how to run it in MS Word?
  • #12 7097078
    michalak92
    Level 18  
    I press the button and I start MS Visual Basic (compiler?).
  • #13 7097106
    Anonymous
    Anonymous  
  • #14 7097303
    michalak92
    Level 18  
    The thing is, I don't know how to turn them on :D
  • #15 7097329
    Anonymous
    Anonymous  
  • ADVERTISEMENT
  • #16 7098313
    michalak92
    Level 18  
    I hit alto and F8, and there are no macros in the list. I have MS Word 2003.
  • #17 7099842
    sens
    Level 14  
    Options> Security> Macro Security> Select Medium Security.

    When you open the file again, it will ask if you want to enable macros and click enable.

    Left Alt + F11 opens the VisualBasic editor ... because it's not a macro :)
  • #18 7101074
    michalak92
    Level 18  
    Thank you very much ! Now it is working.
  • #19 16852355
    3do18
    Level 2  
    michalak92 wrote:
    Thank you very much ! Now it is working.

    hey, but it doesn't work in office 2016, doesn't it? nothing is happening to me

Topic summary

The discussion centers around finding programs that can detect and highlight repeated words in long texts. Users inquire about features in Microsoft Word, with one noting that Word has a default feature for detecting repetitions. However, they seek a method to identify repeated words across different sections of a text. Suggestions include using the "change" function in Word to count occurrences of specific strings. Additionally, online tools like Textalyser and offline tools like Text Analyzer are recommended for analyzing text. A user shares a Visual Basic (VB) script that can count and save repeated words in a new document, with instructions on enabling macros in MS Word 2003. Some users express concerns about compatibility with newer versions of Office, such as Office 2016.
Summary generated by the language model.
ADVERTISEMENT