Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

one entry in the on database is:

LPE-1*story#1/1 of pearl#1/2*historia de la perla*storia della perla* histoire de la perle* história da pérola*istoria perlei*TOPIC

The fields are separated by stars, *. They are:

sentence ID|English NP|Spanish translation|Italian translation|French translation|Portuguese translation|Romanian translation|Semantic relation

The English NP field has the following format:

noun1#sense/i [preposition] noun2#sense/j

where i and j can be either 1 or 2 indicating the position of the semantic argument in the NP instance (note that the preposition might be missing). For example, in the NP instance chair#1/2 arm#1/1 which encodes a part-whole relation (P-W), the noun chair indicates the whole (and thus is labeled as 2), and the noun arm encoded the part (and is labeled as 1).

Problem:

Write a shell script containing a combination of UNIX and AWK commands that will give the answer to the following questions. The shell script should be executed only once and output (to standard output, unless mentioned otherwise):

  1. the number of English NP instances in the file;
  2. the number of unique English NPs (consider for this the entire field $2);
  3. the list of unique semantic relations considered in this database (store it in "sr.uniq.txt");
  4. the frequency of each semantic relation in the database with the following format: Semantic_relation frequency (store this in "sr-freq.txt");

How to do for question 2,3,4

share|improve this question
4  
Is this a homework assignment? What have you tried so far? –  Paul Oct 11 '13 at 4:43
    
awk has associative arrays, and the keys in an associative array will be unique. –  glenn jackman Oct 11 '13 at 21:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.