#!/usr/bin/perl -Imodules

use WWW::Wikipedia;

$file = $ARGV[0];

die "perl $0 TEXTFILE.TXT" unless (defined($file));
print "\n########### Wikipedia->Bot() ###########\n\n";

open(RH,"<$file");
	my $content = do { local( $/ ) ; <RH> } ;
close RH;

@content = split(' ',$content);

open(WH,">$file.html") or die;
$| = 1;

foreach $search (@content){


	$tmp_search = $search;
	
	# hier alle sonderzeichen entfernen aus dem tmp_search
	$tmp_search =~ s/\.//ig;
	$tmp_search =~ s/,//ig;
	$tmp_search =~ s/;//ig;
	$tmp_search =~ s/-//ig;
	$tmp_search =~ s/\+//ig;
	$tmp_search =~ s/\)//ig;
	$tmp_search =~ s/\(//ig;
	
	print "Gesucht: $tmp_search ";
	
	my $wiki = WWW::Wikipedia->new(language => 'de');
	$wiki->timeout( 20 );
	my $result = $wiki->search( $tmp_search );
  
	if (defined($result)) {
  
		if ( $result->text() ) { 
			@text = split('\n', $result->text());
			
			print WH "<a href=\"wikilink\" title=\"@text[0] @text[1] @text[2]\">$search</a> ";
			print " - found\n";
			
		} else {
			print WH "$search ";
			print " - not found!\n";
		}
	}  else {
		print WH "$search ";
		print " - not found!\n";
	}

}
close WH;

=pod

=head1 NAME

EasySpiderTCPClient, EasySpiderTCPServer

=head1 SYNOPSIS

system("perl EasySpiderTCPServer.pl --config=easyspider.server.cfg");

=head1 DESCRIPTION

Nowadays working with Deep Learning, Machine Learning or even Artificial Intelligence you need a lot of Training Data. This crawling framework was developed by me in 2005 and 2006 in Perl5. I am releasing it so that Perl beginners can take a look at code. I am using deep learning to realize mostly language related tools in the field of Natural Language Generation like Text Generation. My most advanced Text Generator is ArtikelSchreiber.com. 

=over
=item * Crawling and mirroring of Webpages
=item * Extracting of HTML Tags and Content between Tags
=item * Client/Server Modus
=item * Configuration file support
=item * Extracting of HTML, PDF, DOC/DOCX
=item * Convertion to XML File Format
=back

=back
=head1 LICENSE
Copyright 2005, 2006 

This is released under the Artistic 
License.


=head1 AUTHOR
Sebastian Enger, M.Sc., B.Sc.

L<Dein automatischer ArtikelSchreiber|http://www.artikelschreiber.com/>	-	
L<Deutscher ArtikelSchreiber Blog|http://www.artikelschreiber.com/de/blog/>	-	
L<Text Generator: Article Writer|http://www.artikelschreiber.com/en/>	-	
L<English ArtikelSchreiber Blog|http://www.artikelschreiber.com/en/blog/>	-	
L<ArtikelSchreiber Marketing Tools|http://www.artikelschreiber.com/marketing/>	-	
L<Text Generator deutsch - KI Text Generator|http://www.unaique.net/>	-	
L<KI Blog|http://www.unaique.net/blog/>	-	
L<CopyWriting: Generator for Marketing Content by AI|http://www.unaique.net/en/>	-	
L<Recht Haben - Muster und Anleitung fuer Verbraucher|http://rechthaben.net/>	-	
L<AI powered intelligent language transformation|http://www.unaique.com/>

=cut