[Resolu] AddList pour récupérer de mots d'une page web

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

[Resolu] AddList pour récupérer de mots d'une page web

Message par Ar-S »

Salut à tous,
Dans le cadre d'un contest (defis) sur le site Hackingcontest,
j'ai un soucis (enfin pas qu'un mais je vais commencer par le 1er) pour récupérer une liste de mots avec AddList.

Explication du défi :
Une page PHP génère une liste de 10 mots toutes les 30 secondes,
on a à disposition un dico de mots en fichier .txt contenant tous les mots utilisés. Le soucis est que les 10 mots de la page web sont mélangés (exemple : bonbon dans le dico sera ecrit nbonob sur la page web)

Le but est donc de remettre les 10 mots dans l'ordre en retrouvant les bons dans le dico, le tout en moins de 30 secondes.

Je trouve cet exercice très intéressant mais pas facile du tout.

Page du defi : http://hackbbs.org/miss/15/gene.php

Voilà mon code :

Code : Tout sélectionner

url$="http://hackbbs.org/miss/15/gene.php" ; page du défis
Path$=GetCurrentDirectory()

Procedure.s Affichentre(string.s, LString.s, RString.s)
  Protected Affichentre.s, lindex.l, RIndex.l
  lindex = FindString(string, LString, 0)
  RIndex = FindString(string, RString, lindex+Len(LString))
  If lindex And RIndex
    lindex  + Len(LString)
    Affichentre = Mid(string, lindex, RIndex-lindex)
  EndIf
  ProcedureReturn Affichentre
EndProcedure

ProcedureDLL.s Url2Text2(Url.s, OpenType.b,ProxyAndPort.s)
  ;/ Author : Pille
  isLoop.b=1
  INET_RELOAD.l = $80000000
  hInet.l=0
  hURL.l=0
  Bytes.l=0
  Buffer.s= Space (2048 )
  RES.s= ""
  hInet = InternetOpen_ ( "" , OpenType, ProxyAndPort, "" , 0)
  hURL = InternetOpenUrl_ (hInet, Url, #Null , 0, INET_RELOAD, 0)
  Repeat
    InternetReadFile_ (hURL,@Buffer, Len (Buffer), @Bytes)
    If Bytes = 0
      isLoop=0
    Else
      RES = RES + Left (Buffer, Bytes)
    EndIf
  Until isLoop=0
  InternetCloseHandle_ (hURL)
  InternetCloseHandle_ (hInet)
  ProcedureReturn RES
EndProcedure
ProcedureDLL.s Url2Text(Url.s)
  ProcedureReturn Url2Text2(Url,1, "" )
EndProcedure 

;1 je chope la source
Source$=Url2Text(url$)
;2 je fais le ménage dedans
newSource$=Trim(Source$)
newSource$=RemoveString(newSource$,Chr(10))
newSource$=RemoveString(newSource$,Chr(34))
newSource$=RemoveString(newSource$," ")
newSource$=RemoveString(newSource$,"</td>")
newSource$=RemoveString(newSource$,"</TR>")
newSource$=RemoveString(newSource$,"</tr>")
newSource$=RemoveString(newSource$,"<TR>")
newSource$=RemoveString(newSource$,"<tr>")
newSource$=RemoveString(newSource$,"<td>")
newSource2$=Affichentre(newSource$,"<table>","</table>")
newSource2$=RemoveString(newSource2$,"Listofscrambledwords:&nbsp;&nbsp;&nbsp;")
;2 fin - Maintenant il ne reste que les 10 mots entourés des balises <li> et </li>

;3 - test pour voir si ça a bien marché
Debug newSource2$

;4 là ça chie, car j'obtiens 10 fois le 1er mot ?
NewList mot.s()
For i=1 To 10
AddElement(mot()) 
mot() = Affichentre(newSource2$,"<li>","</li>")
;newSource2$=RemoveString(newSource2$,mot())
Next i

FirstElement(mot()) : mot1$=mot()
NextElement(mot()) : mot2$=mot()
NextElement(mot()) : mot3$=mot()
NextElement(mot()) : mot4$=mot()
NextElement(mot()) : mot5$=mot()
NextElement(mot()) : mot6$=mot()
NextElement(mot()) : mot7$=mot()
NextElement(mot()) : mot8$=mot()
NextElement(mot()) : mot9$=mot()
NextElement(mot()) : mot10$=mot()

Debug mot1$+mot2$+mot3$+mot4$+mot5$+mot6$+mot7$+mot8$+mot9$+mot10$
;newSource2$=Affichentre(newSource$,debut$,fin$)
Pourquoi mon addlist ne s'incrémente pas des mots suivants après avoir lu le 1er ?
Dernière modification par Ar-S le mer. 26/nov./2008 15:41, modifié 2 fois.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

Bon vu que je suis impatient, j'ai résolu mon problème en barbare
je suis tout de même preneur pour la solution à mon soucis précédent si quelqu'un veut bien me répondre.

Code : Tout sélectionner

url$="http://hackbbs.org/miss/15/gene.php" ; page du défis
Path$=GetCurrentDirectory()

Procedure.s Affichentre(string.s, LString.s, RString.s)
  Protected Affichentre.s, lindex.l, RIndex.l
  lindex = FindString(string, LString, 0)
  RIndex = FindString(string, RString, lindex+Len(LString))
  If lindex And RIndex
    lindex  + Len(LString)
    Affichentre = Mid(string, lindex, RIndex-lindex)
  EndIf
  ProcedureReturn Affichentre
EndProcedure

ProcedureDLL.s Url2Text2(Url.s, OpenType.b,ProxyAndPort.s)
  ;/ Author : Pille
  isLoop.b=1
  INET_RELOAD.l = $80000000
  hInet.l=0
  hURL.l=0
  Bytes.l=0
  Buffer.s= Space (2048 )
  RES.s= ""
  hInet = InternetOpen_ ( "" , OpenType, ProxyAndPort, "" , 0)
  hURL = InternetOpenUrl_ (hInet, Url, #Null , 0, INET_RELOAD, 0)
  Repeat
    InternetReadFile_ (hURL,@Buffer, Len (Buffer), @Bytes)
    If Bytes = 0
      isLoop=0
    Else
      RES = RES + Left (Buffer, Bytes)
    EndIf
  Until isLoop=0
  InternetCloseHandle_ (hURL)
  InternetCloseHandle_ (hInet)
  ProcedureReturn RES
EndProcedure
ProcedureDLL.s Url2Text(Url.s)
  ProcedureReturn Url2Text2(Url,1, "" )
EndProcedure 

;1 je chope la source
Source$=Url2Text(url$)
;2 je fais le ménage dedans
newSource$=Trim(Source$)
newSource$=RemoveString(newSource$,Chr(10))
newSource$=RemoveString(newSource$,Chr(34))
newSource$=RemoveString(newSource$," ")
newSource$=RemoveString(newSource$,"</td>")
newSource$=RemoveString(newSource$,"</TR>")
newSource$=RemoveString(newSource$,"</tr>")
newSource$=RemoveString(newSource$,"<TR>")
newSource$=RemoveString(newSource$,"<tr>")
newSource$=RemoveString(newSource$,"<td>")
newSource2$=Affichentre(newSource$,"<table>","</table>")
newSource2$=RemoveString(newSource2$,"Listofscrambledwords:&nbsp;&nbsp;&nbsp;")
;2 fin - Maintenant il ne reste que les 10 mots entourés des balises <li> et </li>

;3 - test pour voir si ça a bien marché
Debug newSource2$

;4 Je récupère les 10 mots en les nommant motNUM$
mot1$=Affichentre(newSource2$,"<li>","</li>")
newSource2$=RemoveString(newSource2$,"<li>"+mot1$+"</li>")
mot2$=Affichentre(newSource2$,"<li>","</li>")
newSource2$=RemoveString(newSource2$,"<li>"+mot2$+"</li>")
mot3$=Affichentre(newSource2$,"<li>","</li>")
newSource2$=RemoveString(newSource2$,"<li>"+mot3$+"</li>")
mot4$=Affichentre(newSource2$,"<li>","</li>")
newSource2$=RemoveString(newSource2$,"<li>"+mot4$+"</li>")
mot5$=Affichentre(newSource2$,"<li>","</li>")
newSource2$=RemoveString(newSource2$,"<li>"+mot5$+"</li>")
mot6$=Affichentre(newSource2$,"<li>","</li>")
newSource2$=RemoveString(newSource2$,"<li>"+mot6$+"</li>")
mot7$=Affichentre(newSource2$,"<li>","</li>")
newSource2$=RemoveString(newSource2$,"<li>"+mot7$+"</li>")
mot8$=Affichentre(newSource2$,"<li>","</li>")
newSource2$=RemoveString(newSource2$,"<li>"+mot8$+"</li>")
mot9$=Affichentre(newSource2$,"<li>","</li>")
newSource2$=RemoveString(newSource2$,"<li>"+mot9$+"</li>")
mot10$=Affichentre(newSource2$,"<li>","</li>")

Debug mot1$+","+mot2$+","+mot3$+","+mot4$+","+mot5$+","+mot6$+","+mot7$+","+mot8$+","+mot9$+","+mot10$

~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

Salut,

Voilà un petit code pour récupérer la wordlist dans le presse-papier et la cocooner dans une DataSection.

Code : Tout sélectionner

Procedure ClearLm()

  SetClipboardText("")

EndProcedure


Procedure PutLm(St.S)

  SetClipboardText(GetClipboardText() + Chr(13) + Chr(10) + St)

EndProcedure


  Define FileNo.L
  Define FileName.S
  Define Word.S
  Define St.S
  Define WordCount.L

  FileNo = 0
  FileName = OpenFileRequester("Parcourir", "", "*.*", 0)
  ClearLm()
  PutLm("DataSection")
  St = ""
  WordCount = 0
  If ReadFile(FileNo, FileName)

    Repeat

      Word = Chr(34) + ReadString(FileNo) + Chr(34)
      
      WordCount + 1
      
      QuitLoop = Eof(FileNo)
      
      If St = ""

        St = "Data.S " + Word

      Else

        St = St + ", " + Word

      EndIf
      
      If QuitLoop Or Len(St) > 50
      
        PutLm(St)
        St = ""

      EndIf

    Until QuitLoop

    CloseFile(FileNo)

  EndIf
  
  PutLm("EndDataSection")
  
  PutLm("#WordCount = " + Str(WordCount) )
  
  MessageRequester("Message", "Ctr + V pour coller le contenu du presse-papier dans l'éditeur !")
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

Merci Ollivier, très efficace la création de la datasection.
la wordlist je l'ai en .txt et ça ne me dérange pas de lire les mots ligne après ligne (donc mot apres mot) avec un

Code : Tout sélectionner

If ReadFile(0, "wordlist.txt")  ; Si le fichier peut être lu , on continue...
  While Eof(0) = 0           ; Boucle tant que la fin du fichier n'est pas atteinte. (Eof = 'End Of File') 
    MotDico$=ReadString(0) 
car ce sont les mots de la page web que je n'arrivait pas a chopper avec AddElement(mot()) (code num 1) mais j'ai pu avec le code num2..
Mon soucis maintenant est l'utilisation des expressions régulières pour comparer mes mot1$,mot2$...mot10$ avec chauqe mots du dico pour trouver a quoi ils correspondent.

j'ai posté un exemple de mon soucis dans le topic sur les expressions rég :
http://www.purebasic.fr/french/viewtopi ... 7&start=15

En tout cas merci pour ce beau code que tu as fait ! j'enregistre directe :D
Il me resservira surement prochainement.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

Avec les anagrammes (angl. : scramble), les instructions sur les expressions régulières n'ont pas grande utilité puisque les expressions en questions sont «irrégulières»...

Mode d'emploi du code ci-dessous :
1) Tu ouvres la page web avant ou après avoir exécuté le code
2) Tu sélectionnes correctement la liste des 10 mots (sans prendre plus au-dessus de cette liste sinon ça ne va pas le faire!)
3) Tu copies (Ctrl + C)
4) Tu te places dans la zone de saisie (en cliquant dessus par exemple)
5) Tu colles (Ctrl + V)

Et le tour est joué car, entre le moment où tu as copié et le moment où tu as collé, le code s'est chargé de faire le travail ! (Et il ne met pas trois heures car j'ai utilisé une table d'accès par composition pour accélérer le processus) :)

PS: Grâce au code plus haut, la wordlist est intégrée.

Code : Tout sélectionner

DataSection
Data.S "html:)", "121212", "131313", "123123", "654321"
Data.S "8675309", "666666", "696969", "888888", "1234567"
Data.S "21122112", "12345678", "asdfjkl;", "hal9000"
Data.S "bond007", "ncc1701d", "ncc1701e", "ncc1701"
Data.S "thx1138", "a12345", "abcd1234", "1234qwer", "1a2b3c"
Data.S "1q2w3e", "test123", "1p2o3i", "puppy123", "kitten12"
Data.S "qwerty12", "john316", "apollo13", "ne1469", "amanda1"
Data.S "mazda1", "angela1", "alpha1", "sarah1", "nirvana1"
Data.S "bubba1", "scuba1", "rambo1", "charlie1", "david1"
Data.S "digital1", "dragon1", "honda1", "shadow1", "eagle1"
Data.S "freak1", "james1", "1sanjose", "apple1", "master1"
Data.S "happy1", "martin1", "jason1", "larry1", "number1"
Data.S "robert1", "soccer1", "direct1", "chester1", "welcome1"
Data.S "french1", "hockey1", "chevy1", "scooter1", "chris1"
Data.S "lucky1", "teddy1", "phoenix1", "hello1", "julie1"
Data.S "kevin1", "pookie1", "viper1", "jenny1", "jesus1"
Data.S "kelly1", "money1", "mouse1", "sting1", "justin1"
Data.S "molly1", "sunny1", "front242", "jordan23", "2welcome"
Data.S "h2opolo", "bird33", "4runner", "babylon5", "star69"
Data.S "ib6ub9", "america7", "seven7", "number9", "porsche9"
Data.S "barbara", "database", "banana", "bananas", "canada"
Data.S "jamaica", "amanda", "valhalla", "samantha", "yamaha"
Data.S "natasha", "alaska", "tamara", "zapata", "avatar"
Data.S "basketba", "baseball", "basebal", "bastard"
Data.S "nebraska", "banane", "abigail", "sabrina", "batman"
Data.S "cocacola", "cascade", "cardinal", "claudia"
Data.S "packard", "cannonda", "apache", "america", "canela"
Data.S "camera", "caesar", "warcraft", "catalog", "chapman"
Data.S "zachary", "alicia", "patricia", "carolina", "nicarao"
Data.S "captain", "nautica", "pascal", "rascal", "camaro"
Data.S "nascar", "deadhead", "adidas", "alexande", "airhead"
Data.S "alexandr", "andrea", "gandalf", "grandma", "happyday"
Data.S "indiana", "paladin", "miranda", "adrian", "dakota"
Data.S "dallas", "mayday", "pandora", "sandra", "xanadu"
Data.S "angela", "margaret", "stargate", "savage", "gateway"
Data.S "athena", "ariane", "pearljam", "maryjane", "oatmeal"
Data.S "pamela", "pantera", "vanessa", "graymail", "iguana"
Data.S "jaguar", "galaxy", "gasman", "hannah", "hawaii"
Data.S "mariah", "jonathan", "marshal", "martha", "nathan"
Data.S "italia", "aikman", "saskia", "vanilla", "mailman"
Data.S "animal", "animals", "impala", "attila", "marina"
Data.S "mariposa", "nirvana", "arizona", "joanna", "january"
Data.S "lakota", "avalon", "alyssa", "yomama", "montana"
Data.S "mantra", "tazman", "tarzan", "starwars", "bobcat"
Data.S "badboy", "barbie", "babies", "basketb", "rabbit"
Data.S "bamboo", "rebecca", "abcdef", "abcdefg", "blackie"
Data.S "excalibu", "campbell", "tacobell", "bigmac"
Data.S "jsbach", "columbia", "buddha", "badger", "butthead"
Data.S "bradley", "brenda", "bernard", "ladybug", "diablo"
Data.S "blizzard", "brandi", "bandit", "brandon", "brandy"
Data.S "beagle", "isabelle", "elizabet", "beanie", "beatles"
Data.S "webmaste", "beaner", "beaver", "fireball", "beautifu"
Data.S "gabriell", "gabriel", "poohbear", "bertha", "benjamin"
Data.S "bailey", "beavis", "basket", "blaster", "albert"
Data.S "blazer", "barney", "strawber", "braves", "buffalo"
Data.S "football", "softball", "footbal", "foobar", "bigman"
Data.S "gambit", "global", "malibu", "library", "brasil"
Data.S "brazil", "rainbow", "obiwan", "kombat", "snowball"
Data.S "marlboro", "snowbal", "playboy", "absolut", "wombat"
Data.S "canced", "icecream", "chance", "celica", "cracker"
Data.S "cancer", "access", "pacific", "chicago", "chocolat"
Data.S "arctic", "clancy", "cactus", "dickhead", "maddock"
Data.S "medical", "claude", "sundance", "dancer", "crawford"
Data.S "richard", "wildcat", "picard", "colorado", "conrad"
Data.S "corrado", "changeme", "chelsea", "peaches", "research"
Data.S "teachers", "teacher", "creative", "cleaner"
Data.S "france", "challeng", "michael", "charlie", "archie"
Data.S "hacker", "chanel", "rachel", "charles", "patches"
Data.S "jackie", "janice", "jessica", "maverick", "metallic"
Data.S "caroline", "special", "claire", "iceman", "maurice"
Data.S "maveric", "veronica", "carrie", "cassie", "active"
Data.S "slacker", "packer", "packers", "marcel", "coltrane"
Data.S "carole", "lacrosse", "scarlet", "scarlett", "castle"
Data.S "carmen", "pacers", "racerx", "stacey", "catfish"
Data.S "californ", "francois", "francis", "falcon", "graphic"
Data.S "logical", "garlic", "camping", "racing", "cougars"
Data.S "cougar", "chiquita", "christia", "nicholas"
Data.S "champion", "cynthia", "charity", "charlott"
Data.S "champs", "caitlin", "victoria", "tricia", "patrick"
Data.S "calvin", "monica", "macintos", "action", "picasso"
Data.S "jackson", "malcolm", "coolman", "classroo", "carlos"
Data.S "crystal", "compaq", "tomcat", "marcus", "cannon"
Data.S "corona", "cyrano", "topcat", "tractor", "laddie"
Data.S "undead", "edward", "maddog", "diamond", "donald"
Data.S "woodland", "greenday", "danielle", "dreamer"
Data.S "reader", "garfield", "alfred", "reading", "gerald"
Data.S "garden", "shithead", "daniel", "ireland", "raider"
Data.S "raiders", "daytek", "leonard", "dreams", "anderson"
Data.S "darren", "sanders", "andrew", "retard", "tuesday"
Data.S "asdfghjk", "asdfgh", "dragonfl", "florida", "friday"
Data.S "asdfjkl", "digital", "godzilla", "douglas", "dragon"
Data.S "harold", "rhonda", "zaphod", "howard", "shadows"
Data.S "shadow", "thursday", "indian", "island", "lindsay"
Data.S "lizard", "madison", "pyramid", "darwin", "tardis"
Data.S "wizard", "majordom", "jordan", "dollars", "orlando"
Data.S "portland", "ronald", "rodman", "raymond", "monday"
Data.S "sunday", "password", "passwd", "jeanette", "sweetpea"
Data.S "jaeger", "general", "eagles", "heather", "kathleen"
Data.S "hawkeye", "elephant", "sheena", "theresa", "theatre"
Data.S "whatever", "whateve", "amelie", "melanie", "elaine"
Data.S "valerie", "jeanne", "yankees", "walleye", "please"
Data.S "seattle", "weasel", "awesome", "netware", "teresa"
Data.S "grateful", "frankie", "fireman", "ferrari", "farmer"
Data.S "safety", "maggie", "georgia", "aggies", "imagine"
Data.S "galileo", "goalie", "enigma", "mirage", "wrangler"
Data.S "angels", "german", "orange", "oranges", "ranger"
Data.S "garnet", "voyager", "garrett", "target", "health"
Data.S "katherin", "sheila", "stephani", "sapphire"
Data.S "asshole", "harley", "stealth", "whales", "ashley"
Data.S "hammer", "herman", "theman", "hamster", "matthew"
Data.S "panther", "hearts", "harvey", "jasmine", "mikael"
Data.S "mailer", "melissa", "valentin", "lorraine", "alpine"
Data.S "aliens", "tequila", "reality", "laurie", "alexis"
Data.S "sammie", "maxime", "marine", "vampire", "insane"
Data.S "painter", "petunia", "praise", "pirate", "sierra"
Data.S "asterix", "xavier", "jasper", "lakers", "walker"
Data.S "kramer", "market", "tanker", "wanker", "parker"
Data.S "startrek", "skater", "maxwell", "stella", "montreal"
Data.S "temporal", "sampler", "marley", "samuel", "napoleon"
Data.S "espanol", "snapple", "planet", "lauren", "stanley"
Data.S "apples", "players", "player", "raquel", "slayer"
Data.S "travel", "walter", "lestat", "superman", "masters"
Data.S "master", "tanner", "suzanne", "newpass", "peanut"
Data.S "warren", "tiffany", "wolfgang", "flamingo", "farming"
Data.S "fugazi", "franklin", "family", "fountain", "wolfman"
Data.S "smashing", "virginia", "sailing", "training"
Data.S "stingray", "giants", "guitar", "magnum", "morgan"
Data.S "mustang", "gymnast", "august", "mishka", "harrison"
Data.S "spanish", "shanti", "joshua", "kathryn", "shalom"
Data.S "hansolo", "phantom", "thomas", "shannon", "hanson"
Data.S "anthony", "sharon", "hatton", "author", "arthur"
Data.S "nikita", "williams", "william", "raistlin", "olivia"
Data.S "julian", "jasmin", "allison", "marilyn", "alison"
Data.S "polaris", "sailor", "quality", "sylvia", "ironman"
Data.S "mountain", "tinman", "marino", "martin", "marvin"
Data.S "matrix", "nissan", "passion", "station", "tristan"
Data.S "austin", "utopia", "warriors", "warrior", "artist"
Data.S "travis", "krystal", "spanky", "sparky", "apollo"
Data.S "salmon", "psalms", "larson", "royals", "taylor"
Data.S "norman", "snowman", "sampson", "samson", "mozart"
Data.S "watson", "saturn", "tattoo", "toyota", "sparrow"
Data.S "parrot", "passwor", "qwaszx", "stuart", "taurus"
Data.S "bubbles", "debbie", "bluebird", "bigbird", "pebbles"
Data.S "robbie", "hobbit", "jimbob", "booboo", "december"
Data.S "quebec", "robotech", "republic", "october", "public"
Data.S "zxcvbnm", "broncos", "cowboys", "scooby", "cowboy"
Data.S "firebird", "bigred", "bridges", "dogbert", "thunderb"
Data.S "birdie", "blondie", "dilbert", "doobie", "blonde"
Data.S "rosebud", "bigdog", "bulldog", "sunbird", "remember"
Data.S "septembe", "homebrew", "herbert", "biteme", "bernie"
Data.S "reebok", "rebels", "byteme", "brewster", "webster"
Data.S "boogie", "junebug", "goblue", "goober", "shelby"
Data.S "theboss", "kimberly", "zombie", "timber", "bonnie"
Data.S "benoit", "business", "nesbitt", "bootsie", "bluesky"
Data.S "brooke", "volleyb", "bullet", "blowme", "trouble"
Data.S "butler", "boomer", "benson", "booster", "trebor"
Data.S "buster", "bigfoot", "blowfish", "bright", "bowling"
Data.S "biology", "gibson", "bullshit", "robinhoo", "bookit"
Data.S "wilbur", "bonjour", "symbol", "boston", "browns"
Data.S "buttons", "button", "brutus", "cccccc", "electric"
Data.S "science", "chicken", "cricket", "celtics", "cyclone"
Data.S "connect", "concept", "soccer", "success", "church"
Data.S "chucky", "scotch", "cloclo", "cuddles", "depeche"
Data.S "mercedes", "frederic", "deutsch", "duckie", "wicked"
Data.S "cinder", "director", "orchid", "dominic", "doctor"
Data.S "cheese", "coffee", "fletcher", "gretchen", "college"
Data.S "michelle", "michele", "speech", "chester", "celine"
Data.S "eclipse", "pierce", "service", "colleen", "telecom"
Data.S "welcome", "spencer", "center", "except", "secret"
Data.S "chiefs", "fletch", "fuckme", "fucker", "michell"
Data.S "mitchell", "michel", "chipper", "hockey", "cheryl"
Data.S "techno", "porsche", "hector", "cherry", "justice"
Data.S "pickle", "mickey", "snicker", "snickers", "cookie"
Data.S "cookies", "nicole", "police", "clipper", "mexico"
Data.S "connie", "vincent", "prince", "princess", "picture"
Data.S "pisces", "security", "cruise", "rocket", "puckett"
Data.S "tucker", "clover", "computer", "compute", "mercury"
Data.S "newcourt", "courtney", "cooper", "scooter", "coyote"
Data.S "copper", "fuckoff", "scruffy", "fiction", "fuckyou"
Data.S "gocougs", "christin", "christop", "chrissy"
Data.S "christ", "christy", "school", "psycho", "politics"
Data.S "knicks", "lincoln", "unicorn", "scorpion", "corwin"
Data.S "sonics", "scorpio", "victor", "victory", "curtis"
Data.S "trucks", "control", "compton", "moocow", "cosmos"
Data.S "popcorn", "xcountry", "country", "scotty", "deedee"
Data.S "dundee", "freddy", "dodger", "dodgers", "defense"
Data.S "freedom", "fender", "legend", "deliver", "denise"
Data.S "kennedy", "ledzep", "denver", "speedo", "speedy"
Data.S "dexter", "friend", "friends", "doggie", "digger"
Data.S "goldie", "redwing", "design", "doogie", "dougie"
Data.S "golden", "hendrix", "thunder", "inside", "kinder"
Data.S "redskin", "dookie", "lindsey", "dennis", "trident"
Data.S "sendit", "sidney", "detroit", "spider", "strider"
Data.S "donkey", "reynolds", "elwood", "redrum", "wonder"
Data.S "notused", "student", "sydney", "windsurf", "oxford"
Data.S "midnight", "dwight", "hotdog", "indigo", "kingdom"
Data.S "snoopdog", "gordon", "phurivdli", "judith", "dolphin"
Data.S "dolphins", "hotrod", "dorothy", "midori", "skidoo"
Data.S "domino", "nimrod", "wisdom", "windows", "dustin"
Data.S "stupid", "drizzt", "london", "studly", "voodoo"
Data.S "peewee", "reefer", "eugene", "sweetie", "kleenex"
Data.S "skeeter", "penelope", "steelers", "steele", "eeyore"
Data.S "weezer", "jeffrey", "jennifer", "jenifer", "ferret"
Data.S "reggie", "george", "wheeling", "genesis", "sergei"
Data.S "energy", "hershey", "kenneth", "shelley", "helpme"
Data.S "wheels", "promethe", "hermes", "stephen", "einstein"
Data.S "jessie", "nellie", "leslie", "letmein", "zeppelin"
Data.S "etoile", "nemesis", "internet", "pierre", "jewels"
Data.S "jeremy", "jensen", "jester", "kelsey", "loveme"
Data.S "people", "explorer", "wrestle", "letter", "wesley"
Data.S "velvet", "western", "newuser", "steven", "popeye"
Data.S "europe", "pepper", "express", "tester", "stever"
Data.S "testtest", "sweets", "sweety", "tweety", "griffey"
Data.S "golfer", "fisher", "spitfire", "flipper", "xfiles"
Data.S "fozzie", "sunflowe", "flowers", "flower", "flyers"
Data.S "forest", "surfer", "future", "ginger", "tigger"
Data.S "google", "nugget", "gregory", "theking", "gopher"
Data.S "gemini", "gilles", "piglet", "penguin", "guinness"
Data.S "singer", "testing", "genius", "tigers", "gretzky"
Data.S "gunner", "nguyen", "grover", "shirley", "memphis"
Data.S "sunshine", "phoenix", "whitney", "zenith", "hootie"
Data.S "sophie", "joseph", "huskers", "shelly", "mother"
Data.S "thumper", "hornets", "hornet", "hunter", "shooter"
Data.S "topher", "horses", "zephyr", "sherry", "millie"
Data.S "willie", "olivier", "minnie", "winnie", "trixie"
Data.S "jupiter", "killme", "killer", "mookie", "kermit"
Data.S "kristen", "tinker", "kittens", "kitten", "pookie"
Data.S "skipper", "miller", "soleil", "elliot", "little"
Data.S "merlin", "simple", "smiles", "smiley", "online"
Data.S "wolverin", "liverpoo", "iloveyou", "oliver"
Data.S "louise", "violet", "silver", "sylvie", "mortimer"
Data.S "swimmer", "emmitt", "monique", "pentium", "mittens"
Data.S "niners", "intern", "winner", "tennis", "senior"
Data.S "sniper", "sunrise", "winter", "tootsie", "puppies"
Data.S "ripper", "sprite", "monkey", "smokey", "network"
Data.S "newyork", "volley", "yellow", "russell", "lennon"
Data.S "nelson", "looney", "loveyou", "protel", "wolves"
Data.S "purple", "russel", "turtle", "memory", "summer"
Data.S "monster", "vermont", "trumpet", "system", "newton"
Data.S "yvonne", "runner", "preston", "entropy", "reznor"
Data.S "sunset", "rooster", "property", "porter", "export"
Data.S "trevor", "qwerty", "fluffy", "muffin", "snuffy"
Data.S "golfing", "froggy", "kingfish", "fishing", "flight"
Data.S "gofish", "goforit", "informix", "pinkfloy", "foxtrot"
Data.S "frosty", "zhongguo", "knights", "knight", "nothing"
Data.S "hunting", "wright", "shotgun", "lionking", "skiing"
Data.S "vikings", "viking", "swimming", "running", "roping"
Data.S "spring", "grumpy", "topgun", "groovy", "phillip"
Data.S "philip", "whisky", "timothy", "smiths", "sunshin"
Data.S "horizon", "history", "johnson", "johnny", "murphy"
Data.S "houston", "python", "shorty", "kristin", "kristi"
Data.S "million", "mission", "tintin", "vision", "spirit"
Data.S "junior", "justin", "pumpkin", "punkin", "skinny"
Data.S "stinky", "skippy", "kristy", "suzuki", "willow"
Data.S "wilson", "moroni", "mirror", "morris", "stimpy"
Data.S "winston", "poiuyt", "squirt", "spunky", "spooky"
Data.S "monopoly", "molson", "moomoo", "stormy", "toronto"
Data.S "snoopy", "support", "sports"
EndDataSection
#WordCount = 1275

Structure WORDATTR
  Coef.L
  Root.L
EndStructure

Structure COEF
  Begin.L
  End.L
EndStructure

  Define LastWord.L
  Define i.L
  Define j.L
  Define k.L
  Define m.L
  Define Tmp.S
  Define TestSt.S
  Define A.L
  Define FirstCoef.L
  Define LastCoef.L
  Define LI.L
  Define LS.L
  Define St.S
  Define Word.S
  Define LWord.L
  Define Paste.S
  
  OpenWindow(0, 0, 0, 320, 0, "Initialisation...", $CF0001)
  StickyWindow(0, 1)  

  LastWord = #WordCount - 1
  Global Dim WordList.S(LastWord)
  Global NewList WordAttr.WORDATTR()
  
  ;- On sort la liste de la DataSection
  
  For i = 0 To LastWord
    Read.S WordList(i)
    WordList(i) = LCase(WordList(i) )
    AddElement(WordAttr() )
    WordAttr()\Root = i
    ;-> Un coef par mot
    For j = 1 To Len(WordList(i) )
      A = Asc(Mid(WordList(i), j, 1) )
      WordAttr()\Coef + A
    Next j
  Next i

  ;- On fait un tri par coef

  SortStructuredList(WordAttr(), #PB_Sort_Ascending, OffsetOf(WORDATTR\Coef), #PB_Sort_Long)
  
  ;- On réfère les coefs au premier de la liste...
  
  SelectElement(WordAttr(), 0)
  
  FirstCoef = WordAttr()\Coef
  
  ForEach WordAttr()
    WordAttr()\Coef - FirstCoef
  Next
  
  ;- ...Pour la table d'accès par composition
  
  LastCoef = WordAttr()\Coef
  
  Global Dim Coef.COEF(LastCoef)
  
  ;(Mise à zéro)
  For i = 0 To LastCoef
    Coef(i)\Begin = -1
    Coef(i)\End = -1
  Next i
  
  ; Modif de Fred ! >> CountList devient ListSize...
  
  LS = ListSize(WordAttr() )

  ForEach WordAttr()
  
      LI = ListIndex(WordAttr() )
      A = WordAttr()\Coef
      Coef(A)\Begin = LI

      If LI + 1 < LS

        For i = LI + 1 To LS
          SelectElement(WordAttr(), i)
          If WordAttr()\Coef <> A
            Coef(A)\End = i - 1
            SelectElement(WordAttr(), i - 1)
            Break
          EndIf
        Next i

      Else

        Coef(A)\End = LS - 1

      EndIf

  Next
  
  CloseWindow(0)
  
  ;- On vide le presse-papier
  
  SetClipboardText("")
  
  ;- On attend que le presse-papier contienne qqch...
  Repeat
    Delay(5)
    St = GetClipboardText()
  Until St <> ""

  ;- On traite...  
  
  OpenWindow(0, 0, 0, 320, 0, "Traitement...", $CF0001)  
  StickyWindow(0, 1)
  Paste = "" 
  For i = 0 To 9
    Word = LCase(Trim(StringField(St, i << 1 + 1, Chr(13) + Chr(10) ) ) )
    If Asc(Left(Word, 1) ) = 10
      Word = Right(Word, Len(Word) - 1)
    EndIf
    LWord = Len(Word)
    Coef = 0
    For j = 1 To Len(Word)
      A = Asc(Mid(Word, j, 1) )
      Coef + A
    Next j
    Coef - FirstCoef
    If Coef(Coef)\Begin = Coef(Coef)\End
      SelectElement(WordAttr(), Coef(Coef)\Begin)
      Paste + WordList(WordAttr()\Root) + ", "
    Else
      For j = Coef(Coef)\Begin To Coef(Coef)\End
        SelectElement(WordAttr(), j)
        TestSt = WordList(WordAttr()\Root)
        Tmp = TestSt
        If Len(TestSt) = LWord
          For k = 1 To LWord
            For m = 1 To Len(Tmp)
              If Mid(Word, k, 1) = Mid(Tmp, m, 1)
                Tmp = Left(Tmp, m - 1) + Right(Tmp, Len(Tmp) - m)
              EndIf
            Next m
          Next k
          If Tmp = ""
            Paste + TestSt + ", "
            Break
          EndIf 
        EndIf
      Next j
    EndIf
  Next i
  
  ;- Et on renvoie dans le presse-papier
  
  SetClipboardText(Paste)
  CloseWindow(0)
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

C'est énorme !
Mille merci pour ce code de furieux. Par contre il est pour quelle version ?
J'utilise la 4.20 et j'ai une erreur au lancement :
ligne 300 : Read.S WordList(i) => synthaxe error

Comme le ListSize, faut que je le remplace par CountList ??
je n'ai pas installé de beta de la 4.30 alors je suis un peu paumé.


-----EDIT ------

Je viens de tester avec la 4.3 beta 4

J'obtiens une erreur ligne 397 : If Coef(Coef)\Begin = Coef(Coef)\End
"Array Index Out of Bounds"
"debbuger quit unexpectedly"


Décidément j'ai pas de chance...
pourtant je selectionne bien les 10 mots uniquement..

Si je désactive le debbuger, ça crash
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

En effet, tu n'as pas de chance car, chez moi, le copier/coller magique fonctionne cash, et je n'ai pas obtenu d'erreur. Quel OS et quel matériel as-tu ? Un exemple:

Code : Tout sélectionner

igreoag
 
nnethke
 
mfaliy
 
utufre
 
eypontr
 
ecacdn
 
lnoias
 
iddsaa
 
sengitt
 
eavtci
 
===> georgia, kenneth, family, future, entropy, canced, alison, adidas, testing, active, 
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

Je suis sous XP Pro SP3 - 2go DDR - carte GFX ATI HD4850 - avec une MSI P35 Neo2 comme carte mère. Donc rien de trop "exotique"

Par contre tu le test sous quel version de PB ?
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

4.30 Beta 4 (x86).

Mais, à mon avis, tu as dû couiller quelquepart (dans la copie du code par exemple) parce que, aujourd'hui comme hier, ça marche toujours aussi bien chez moi. J'ai même fait le test avec mon exemple ci-dessus : ça marche aussi. Tu veux un EXE ?
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

Ollivier a écrit :4.30 Beta 4 (x86).

Mais, à mon avis, tu as dû couiller quelquepart (dans la copie du code par exemple) parce que, aujourd'hui comme hier, ça marche toujours aussi bien chez moi. J'ai même fait le test avec mon exemple ci-dessus : ça marche aussi. Tu veux un EXE ?
Pas de couillage dans le copier/coller (tout de même !) mais je suis preneur pour un exe. J'ai reessayé moults fois, rien ni fait :(
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

Ma foi... Voici.

Et ton navigateur?
Dernière modification par Ollivier le mar. 25/nov./2008 14:35, modifié 1 fois.
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

Arrrgg
Comme quoi ça ne vient pas de mon PB...

Je lance le soft et dès que je copie les 10 mots...

BoOm

Image
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

Bon... Arrête les dégâts! Je regarderai ce soir!!
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

Ollivier a écrit :Bon... Arrête les dégâts! Je regarderai ce soir!!
Pas de prob, merci de ta patience.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

@Ar-S

Au lieu de faire la conversion, le code suivant va charger une chaîne hexadécimale dans le presse-papier, une fois que tu as copié la liste.

>> Peux-tu me poster cette chaîne en pm stp.

Ollivier
Répondre