User:Ozzyslovechild~enwiktionary

stop don't go

The first version that ran through entire wordlist without dying.
<?PHP  #php script to open a word list file, check if there's an entry for it on wikitionary, and spit out a file that could be inserted into MediaWiki to facilitate adding entries for missing words

$array = file("allwords.txt"); set_time_limit(0) ; $outputfile = fopen("outputfile.txt","w"); //opens asdfcounter.txt to read $notfoundstr = "Wiktionary does not have an entry for"; $randrange1 = 250000; $randrange2 = 550000;

foreach ($array as $line_num => $line) { $line=chop($line); 					#echo "line=$line"; #file_get_contents("http://en.wiktionary.org/wiki/". str_replace(" ", "_", $line)	#str_rep to convert to wiktionary naming convention	#read page into var. for loop to retry on timouts			# i like that this works to as such.	# getcha that url, but real gentleman-like..	$wait=0;	usleep(rand($randrange1,$randrange2));	for (	$wiktionary = file_get_contents("http://en.wiktionary.org/wiki/". str_replace(" ", "_", $line) ) ; $wiktionary==FALSE; sleep($wait+=10) # not needed, pauses increasingly before next call so as not not to hammer server. ) {						$z++; if ($z==100) {echo "Zee z is greater than thee. Exiting."; exit;}					$wiktionary = file_get_contents("http://en.wiktionary.org/wiki/". str_replace(" ", "_", $line) ) ; 					echo " Timeout on $line. Waiting $wait and retrying. Time: " . time . ""; flush;		ob_flush; 					} #echo " Out of loop. wiktionary=$wiktionary";

$notfound = strpos($wiktionary, $notfoundstr); if ($notfound) { #echo " In not found loop. Line=$line."; #echo "notfoundpos: $notfound.notfoundstr=$notfoundstr wiktionary=wiktionary;"; echo "Wikt's missing: $line"; /*echo "FYI: Google it - 					 <A HREF=http://m-w.com/dictionary/$line>m-w.com?</A>  - 					 <A HREF=http://dictionary.reference.com/search?q=$line>reference.com?</A>  - 					 <A HREF=http://dictionary.cambridge.org/results.asp?searchword=$line>cambridge.org</A> - 					 <A HREF=http://www.urbandictionary.com/define.php?term=$line>urbandictionary.com</A> - 					 <A HREF=http://www.bartleby.com/cgi-bin/texis/webinator/sitesearch?query=$line>bartleby.com</A>					 <BR>"; */ fwrite($outputfile, "* $line - (FYI: Google it. - m-w.com? - reference.com? - cambridge.org? - urbandictionary.com? - bartleby.com?)\n"); #	echo "<BR>* $line <BR> (FYI: Google it. - m-w.com? - reference.com? - cambridge.org? - urbandictionary.com? - bartleby.com?)<BR>"; } #end if notfound # keeps browser connection alive, hopefully:	 may not need. echo '~';		flush;		ob_flush; #$i++; if ($i > 5) { exit;	} # break loop during testing. } #end of file as array echo "<BR>End of file<BR>. Program finished. Judge success for yourself.<BR>"; fclose($outputfile);

#now i spent quite some number of hours figuring out how to do this, so be kind and please remember, the goal wasn't solely or even mostly to write a program that would produce something that could be used to facilitate filling in holes on a Wiktionary. #no, it was also to give myself cause to explore the PHP manual, and to learn some things that i didn't need to learn, and to leave the remnants of those detours somewhere where i could later visit. #so be kind, and realize that your programming critique's been thought of, and deemed unworthy of creedence,, yet. #so be kind, cuz it's fun 2b. exit;

?>