Hi,
I have an issue that I am trying to resolve using arrays in awk. I have two files, the first one is a dictionary with this format:
FILE 1 (dictionary)
'Abrir' 'Open'
'Aceptar' 'Accept'
Every line has two fields, a word in two languages.
The second file is a simple list of words, that can be in either of the languages of the dictionary or not present in the dictionary.
FILE 2 (wordlist)
'Open'
'Aceptar'
'Absoluto'
...
I need to split this second file in three parts:
- words in dictionary, first language
- words in dictionary, second language
- words not in dictionary
What I have done with awk:
BEGIN {
dictfile=ARGV[1];
listfile=ARGV[2];
}
if (FILENAME == dictfile) {
dic[$1] = $2;
tran[$2];
}
else { #FILENAME = listfile;
if ($1 in dic) {
print "word in dictionary", $1, dic[$1];
}
else {
if ($1 in tran) {
print "word already translated", $1;
}
else {
print "word not in dictionary", $1;
}
}
}
The problem comes with the case of words already translated. Seems like the array "tran" is not properly constructed, and I can�t fix it.
I know the code is quite messy, my apologies. I will thank any help and/or suggestions