#!/usr/bin/perl-w use strict; use warnings; use open ':utf8'; open (INPUT1, ") { my $line = $_; chomp $line; my @words = $line; } while () { my $line2 = $_; chomp $line2; my @words2 = $line2; } #### open (OUTPUT1, ">FF.txt"); open (OUTPUT2, ">Unmatched.txt"); for (my $falsefriend = 0; $ falsefriend <= $#words; $ falsefriend ++) { for (my $bilingualword = 0; $ bilingualword <= $#words; $ bilingualword++) { if ($falsefriend eq $ bilingualword) { print OUTPUT1 “$falsefriend"\n"; } else { print OUTPUT2 "$bilingualword\n"; } } } #### #!/usr/bin/perl-w use strict; #use warnings; use open ':utf8'; #open files open (FALSEF, ") { #assign each line to $line my $line = $_; #chomp off the new line chomp $line; #increment $line $falsef{$line}++; } #declare variables my $token; my %hash; #open output files open (OUTPUT1, ">YayOutputFalseFriends.txt"); open (OUTPUT2, ">AhhUnsortedWordList.txt"); #while input is received while () { #assign each line to $line my $line = $_; #chomp off the new line chomp $line; #assign $line to the array my @wordlist = $line; #split/\t/, $line; #a for-loop to 'clean up' the words, to get rid of all the commas, full stops, etc, except the apstrophes and hyphens for (my $x = 0; $x <= $#wordlist; $x++) { my $token = $wordlist[$x]; if ($token =~ /('?\w+)/) { #$word is now clean my $searchword = $1; #checks to see whether the word exists in the false friends list if (exists $hash{$searchword} || exists $falsef{$searchword}) { my $existingfalsefriend; $existingfalsefriend{$searchword}++; } else { #print to unsorted.txt print OUTPUT2 "$searchword\n"; } } } } my $searchword; foreach my $searchword(sort keys %existingfalsefriend) { #sorts the matched words alphabetically my $value = $existingfalsefriend{$searchword}; print OUTPUT1 "$searchword\t $value\n"; }