Recherche:Les chemins du langage/Programme d'aide au calcul
Les chemins du langage
Toute réaction ou commentaire par rapport à ce travail de recherche sont les bienvenus sur cette page de discussion.
Cette page fait partie de l’espace recherche de Wikiversité et dépend de la faculté langues. Pour plus d'informations, consultez le portail de l'espace recherche ou rendez-vous sur l'index des travaux de recherche par faculté.
De la même façon que les correcteurs orthographiques, il est possible d’utiliser dans traitement de texte, un calculateur de phrase, selon un ou plusieurs codes donnés. Par exemple, gratuitement avec OpenOffice.org Writer, une version du programme ci-dessous est téléchargeable ici.
Compter toutes les consonnes et voyelles d'un texte
modifierSub CompterConsonneVoyelle
Document1 = ThisComponent
Controleur1 = Document1.CurrentController
VCurseur1 = Controleur1.ViewCursor
VCurseur1.gotoStart(false)
VCurseur1.gotoEnd(true)
msgbox ConsonneVoyelle(VCurseur1.string)
End Sub
Public Function ConsonneVoyelle(champ As String) As string
For p = 1 To Len(champ) + 1
l = Mid(champ, p, 1)
If Mid(champ, p, 1) = "(" Then
Do Until (Mid(champ, p, 1) = ")")
p = p + 1
Loop
End If
If l = "a" Or l = "A" Or l = "á" Or l = "à" Or l = "ä" Or l = "ã" Or l = "å" Or l = "æ" Or l = "e" Or l = "E" Or l = "é" Or l = "è" _
Or l = "ë" Or l = "ê" Or l = "i" Or l = "I" Or l = "í" Or l = "o" Or l = "O" Or l = "ò" Or l = "ó" Or l = "õ" Or l = "ô" Or l = "ö" _
Or l = "œ" Or l = "u" Or l = "U" Or l = "ü" Or l = "û" Or l = "ú" Or l = "ù" Or l = "y" Or l = "Y" Then voyelle = voyelle + 1
if l = "b" Or l = "B" Or l = "c" Or l = "C" Or l = "ç" Or l = "d" Or l = "D" Or l = "f" Or l = "F" Or l = "g" Or l = "G" Or l = "h" _
Or l = "H" Or l = "k" Or l = "K" Or l = "l" Or l = "L" Or l = "m" Or l = "M" Or l = "n" Or l = "N" Or l = "p" Or l = "P" Or l = "q" _
Or l = "Q" Or l = "r" Or l = "R" Or l = "s" Or l = "S" Or l = "t" Or l = "T" Or l = "v" Or l = "V" Or l = "w" Or l = "W" Or l = "x" _
Or l = "X" Or l = "z" Or l = "Z" Then consonne = consonne + 1
Next p
ConsonneVoyelle = ("Voyelles : " & voyelle & ". Consonnes : " & consonne)
End Function
Résultats d'un code d'entraînement cérébral qui tend vers zéro
modifierPhrase par phrase :
' Boite de message par phrase
Sub RechercheTout
Dim Plage As Object
Dim Phrase As String
Dim oCSD As Object
oCSD = ThisComponent.createSearchDescriptor
Phrase = "." & ".*" & "."
oCSD.SearchString = Phrase
oCSD.SearchRegularExpression = True
Phrases = ThisComponent.FindAll(oCSD)
For i = 0 To Phrases.Count - 1
msgbox ("Phrase " & (i+1) & " : " & Valeur(Phrases(i).String)
Total = Total + Valeur(Phrases(i).String)
Next
msgbox ("Total : " & Total)
End Sub
' Insertions de résultats par phrase
Sub InsertionsResultats
Dim monDocument, monTexte, monCurseur As Object
monDocument = ThisComponent
monTexte = monDocument.Text
monCurseur = monTexte.createTextCursor
monCurseur.gotoStart(false) ' Positionnement au début du document
debut = true
While monCurseur.string <> "" or debut = true
debut = false
monCurseur.gotoNextSentence(true)
monCurseur.CharEscapement = 20
Phrase = monCurseur.string
monCurseur.gotoPreviousSentence(false)
monCurseur.gotoNextSentence(false) ' Positionnement après la phrase courante pour l'insertion de son résultat
monTexte.insertString(monCurseur, Valeur(Phrase) & " ", false)
monCurseur.goright(len(Valeur(Phrase) & " "),true) ' Positionnement après le résultat inséré
Wend
End Sub
Public Function Valeur(champ As String) As Variant
Dim p As Integer ' position
Dim l As String ' lettre
Dim h, e, cv As Integer ' codes
For p = 1 To Len(champ) + 1
l = Mid(champ, p, 1)
If Mid(champ, p, 1) = "(" Then
Do Until (Mid(champ, p, 1) = ")")
p = p + 1
Loop
End If
' Les prononciations sont entre [...] ou /.../
If l = "[" or l = "/" Then
Do Until l = "]" or l = "/"
If Mid(champ, p, 1) = "(" Then
Do Until (Mid(champ, p, 1) = ")")
p = p + 1
Loop
End If
l = Mid(champ, p, 1)
If l = "a" Or l = "á" Or l = "@" Or l = "ø" Or l = "æ" Or l = "c" Or l = "C" Or l = "ç" Or l = "g" Or l = "J" Or l = "h" Or l = "k" Or l = "l" Or l = "L" Or l = "o" Or l = "ó" Or l = "%" Or l = "r" Or l = "y" Or l = "u" Or l = "H" Or l = "w" Or l = "P" Or l = "ã" Or l = "H" Or l = "U" Or l = "G" Or l = "^" Or l = "*" Or l = "U" Then h = h - 1
If l = "b" Or l = "d" Or l = "e" Or l = "é" Or l = "E" Or l = "f" Or l = "i" Or l = "I" Or l = "í" Or l = "Z" Or l = "m" Or l = "n" Or l = "p" Or l = "s" Or l = "t" Or l = "v" Or l = "z" Or l = "F" Or l = "0" Or l = "$" Or l = "X" Or l = "d" Or l = "T" Or l = "M" Or l = "I" Then h = h + 1
p = p + 1
Loop
Else
If l = "a" Or l = "A" Or l = "á" Or l = "à" Or l = "ä" Or l = "ã" Or l = "å" Or l = "æ" Or l = "c" Or l = "C" Or l = "ç" Or l = "e" Or l = "E" Or l = "é" Or l = "è" Or l = "g" Or l = "G" Or l = "h" Or l = "H" Or l = "k" Or l = "K" Or l = "l" Or l = "L" Or l = "o" Or l = "O" Or l = "ò" Or l = "ó" Or l = "õ" Or l = "ô" Or l = "ö" Or l = "œ" Or l = "q" Or l = "Q" Or l = "r" Or l = "R" Or l = "u" Or l = "U" Or l = "ü" Or l = "û" Or l = "ú" Or l = "ù" Or l = "w" Or l = "W" Then e = e - 1
If l = "b" Or l = "B" Or l = "d" Or l = "D" Or l = "f" Or l = "F" Or l = "i" Or l = "I" Or l = "í" Or l = "j" Or l = "J" Or l = "m" Or l = "M" Or l = "n" Or l = "N" Or l = "p" Or l = "P" Or l = "s" Or l = "S" Or l = "t" Or l = "T" Or l = "v" Or l = "V" Or l = "y" Or l = "Y" Or l = "z" Or l = "Z" Or l = "é" Or l = "ê" Or l = "è" Or l = "ë" Then e = e + 1
End If
Next p
Valeur = e
End Function