Bonjour,

j'ai deux fichiers identiques, l'un est complet et l'autre où il manque quelques chaînes de caractères. Je voudrai créer des vecteurs de telle sorte que quand les chaînes sont identiques on insert dans un fichier résultat un +1 suivie de cette même chaîne, et dans le cas où une chaîne n'est pas contenu dans le second fichier, l'insérer avec un -1 avant.

Exemple:

Fichier 1:

Le/PREP soleil/NOM est/VERBE brûlant/ADJ et/PREP brillant/ADJ ./PUNC

fichier 2 :

Le/PREP soleil/NOM est/VERBE brillant/ADJ ./PUNC


Le fichier résultat contiendra alors:

+1 Le/PREP soleil/NOM est/VERBE
-1 brûlant/ADJ et/PREP
+1 brillant/ADJ ./PUNC

Voici mon code mais mon fichier résultat atteint 4go ce qui est impossible:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 Dim sr As New StreamReader("C:\Users\...\fichier.txt")
        Dim contains As String = sr.ReadToEnd
        Dim tab() As String = contains.Split(" ")
        Dim res As String
        Dim res1 As String
 
        Dim path1 As String = "C:\Users\...\" & i & "fichier2.txt"
 
        Dim sr2 As New StreamReader(path1, Encoding.UTF8)
        Dim container As String = sr2.ReadToEnd
        Dim tab1() As String = container.Split(" ")
 
       Dim sw As StreamWriter = New StreamWriter("C:\Users\......\resultat.txt")
 
        Dim v As Integer = 0
        Dim w As Integer = 0
 
        While v < UBound(tab) 'And w < UBound(tab1)
            If tab(v) = tab1(w) Then
                Dim empl As Long = InStr(tab(v), "/")
                res &= vbCrLf & "+1 " & (Mid(tab(v), empl + 1) + Chr(32))
 
                sw.WriteLine(res)
                If v < UBound(tab) Then
                    v = v + 1
                End If
                If w < UBound(tab1) Then
                    w = w + 1
                End If
                While tab(v) = tab1(w)
                    Dim empl2 As Long = InStr(tab(v), "/")
                    res &= Mid(tab(v), empl2 + 1) + Chr(32)
 
                    sw.WriteLine(res)
                    If v < UBound(tab) Then
                        v = v + 1
                    End If
                    If w < UBound(tab1) Then
                        w = w + 1
                    End If
                End While
 
            Else
                Dim empl As Long = InStr(tab(v), "/")
                res1 &= vbCrLf & "-1 " & Mid(tab(v), empl + 1) + Chr(32)
                sw.WriteLine(res1)
 
                If v < UBound(tab) Then
                    v = v + 1
                End If
                While tab(v) <> tab1(w)
                    Dim empl1 As Long = InStr(tab(v), "/")
                    res1 &= Mid(tab(v), empl1 + 1) + Chr(32)
                    sw.WriteLine(res1)
 
                    If v < UBound(tab) Then
                        v = v + 1
                    End If
                End While
            End If
 
 
        End While
 
        sr.Close()
        sr2.Close()
        sw.Close()
Merci pour votre aide.