SCRIPT TO TRAP ILLEGAL COMBOS


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SCRIPT TO TRAP ILLEGAL COMBOS
# 1  
Old 03-08-2011
SCRIPT TO TRAP ILLEGAL COMBOS

Hello,
I am trying to identify names which are "illegal" in the sense that they do not comply with the spelling norms of a culture. I have written NGrams for initial and final combos which are illegal. These are lists stored in 2 files named Initial and Final. Here are few examples
Initial:
bb
bc
bd
bbb
bbc

Final:
bx
bbx

I want to run these on a file containing a large amount of data and identify and store those words which are "illegal"
e.g.of illegal names
Initial
bbarry
bbclaude

Final
robx
hirambbx


Of course an add-on would be that if the correct name was found in the input file, the "illegal" output would be shown as:
Initial
b+barry
bb+claude

Final
rob+x
hiram+bbx

This assuming that claude, barry, rob and hiram are part of the input file.

The input file of names would be very large. So a large array would be needed.

Could anyone help me with a Perl or an Awk script to do the job. The ones I wrote are so bad they are just not worth displaying.

Many thanks in advance for any help,

Gimley
# 2  
Old 03-08-2011
first off:
Code:
Initial:
bb
bc
bd
bbb
bbc

Final:
bx
bbx

if you find bx, you have by default also found bbx, since bx is a substring of bbx.
Revised list
Code:
Initial:
bb
bc
bd

Final:
bx

Code:
awk ' /bb/ || /bc/ || /bd/ {for(i=1;i<=NF;i++) 
            {if($i~/bc/ || $i~/bb/ || $i~/bd/ ) {print $i} } ' initial

use the same logic on final.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 03-08-2011
Hi,
Many thanks for the answer. That would work if the number of NGrams were few. How do I load an NGram from a file.
Sorry for the hassle and many thanks in advance
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Trap the EXIT_CODE from a script

Hi All, I have a script which calls SQLPLUS and do some data cleanup. But sometimes the SQL hangs and the script keeps on running. In that case, we kill the script using "kill" command, but as soon as we kill the script it exists with a non zero exit code which makes the job fail( we have a... (7 Replies)
Discussion started by: LoneRanger
7 Replies

2. Shell Programming and Scripting

Call two files and merge all entities to create all combos

Hello, I am preparing an expanded verb morphology of Indian languages for the Open Source Community and have developed two files. The first file called root contains the verbal roots and the second (called prefix) contains all the syntactic elements which can be appended to the root file. An... (8 Replies)
Discussion started by: gimley
8 Replies

3. Shell Programming and Scripting

Trap Oracle error in shell script

sqlplus -s usrname/password@dbSID <<-SQL >> logfile @create_table.sql commit; quit; SQL I am running this script to execute an sql file. I want to display the oracle error if anything found during execution of the sql file and exit from script. Please suggest How do it. (1 Reply)
Discussion started by: millan
1 Replies

4. Homework & Coursework Questions

VM trap may work differently than a pure install trap.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: That is the last reply I received from my instructor, and I'm looking for some alternatives. When using... (2 Replies)
Discussion started by: newuser45
2 Replies

5. Shell Programming and Scripting

script help Undefined /illegal variable using cat

Hello group, Still fairly new at the whole scripting thing so be gentle. I'm trying to write a simple script that archives my log files into a master log broken into weeks of the year. My script runs fine up till the "cat" lines which I get a undefined or illegal variable name error. But... (2 Replies)
Discussion started by: dpreviti
2 Replies

6. Shell Programming and Scripting

How trap a signal in shell script?

Hi , i have a scenario where...i have to put a check where if script is executing more than 15mins i have to kill that script and n retry again 2nd time. i this case i can use background process to do it but i feel trap will be the efficent way to do so... but i dont know much about it... (1 Reply)
Discussion started by: crackthehit007
1 Replies

7. UNIX for Advanced & Expert Users

trap ctrl c in shell script

how to trap the ctrl c in unix shell script my script is running in while loop it should not be terminate with ctrl c. if i press ctrl c while running script it shloud ignore the same. please healp.......... thanks in advance (2 Replies)
Discussion started by: arvindng
2 Replies

8. Shell Programming and Scripting

Cntl+z Trap is not detecting ??? Help required to add a trap detection ???

Hi folks, I have tried to add some trap detection in the below script....this script is used to monitor database activities...in a rather awkward way :rolleyes:.... The idea behind adding trap is that....this script creates lots of temporary files in the running folder to store the count... (1 Reply)
Discussion started by: frozensmilz
1 Replies

9. Shell Programming and Scripting

Trap key press in a script

How can I trap a character press in the shell script. For eg:- I have a script runinng a infinite loops , I will need to quit if q is pressed. I have seen the traping the signal , but they give option only for traping the defined interrupt signals. But those does not help me here. (3 Replies)
Discussion started by: praveenbvarrier
3 Replies

10. UNIX for Advanced & Expert Users

how to use trap command in shell script

Right now I have implemented autossh between ServerA & ServerB which are sun solaris based. I have made this shell script. I am facing one problem which I am going to discuss now. The problem is when I sftp some files (suppose there is 10 files I have to transfer through sftp) from one server to... (2 Replies)
Discussion started by: girish.batra
2 Replies
Login or Register to Ask a Question