Identifying single words in a dictionary database


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Identifying single words in a dictionary database
# 1  
Old 09-07-2016
Identifying single words in a dictionary database

I am reworking a Marathi-English dictionary to be out on open-source. My dictionary has the Headword in Marathi, followed by its Part of Speech and subsequently by its English glosses as in the examples below;
Code:
अकरसणें v i To contract, shrink.
अकरा a Eleven.
अकराळ a Frightful, terrible.
विकराळ a Frightful, terrible.
अकरोट m A walnut.
अकरोड m A walnut.
अकर्त्तव्य a That which is not proper to be done; improper.
अकर्त्ता a Incapable, incompetent.
अकर्तृत्व n Impotence, incapability.
अकर्म n A bad action, sin. 
अकर्मी a Wicked.
कुकर्मी a Wicked.
अकर्मक a Intransitive or neuter.
अकलंक a Exempt from stain, blemish.
अंकलिपि f Figure-writing.
अकलेचा खंदक m A wiseacre.
अकल्पनीय a Inconceivable; undevisable
अकल्पित a Unexpected; unthought of.
अकल्मष a Sinless.
अकल्याण n Infelicity; injury.
अकस m Malice, spite, grudge.
अकसखोर a Spiteful, malicious
अकसी a Spiteful, malicious
अकस्मात् ad Suddenly, unexpectedly, inconsiderately.
अकस्मात ad Suddenly, unexpectedly, inconsiderately.

As can be seen the delimiter of the gloss is either a comma or a semi-colon
To make the dictionary more accessible and easily readable and concise, I want to retain only single words or words with the following
Code:
to 
A

At present I have written a macro in Ultraedit: a Word processor to do the job. It uses a regex to identify all glosses with single words (with the condition specified above)
However Macros are slow and since the database is around 400.000+ words,I wonder if there is a means of identifying such single glosses through an awk or perl script. Thus in the example above, only the following will be retained
Code:
अकरसणें v i To contract, shrink.
अकरा a Eleven.
अकराळ a Frightful, terrible.
विकराळ a Frightful, terrible.
अकरोट m A walnut.
अकरोड m A walnut.
अकर्त्तव्य a That which is not proper to be done; improper.
अकर्त्ता a Incapable, incompetent.
अकर्तृत्व n Impotence, incapability.
अकर्म n A bad action, sin. 
अकर्मी a Wicked.
कुकर्मी a Wicked.
अकर्मक a Intransitive,neuter.
अकलंक a Exempt from stain, blemish.
अंकलिपि f Figure-writing.
अकलेचा खंदक m A wiseacre.
अकल्पनीय a Inconceivable; undevisable
अकल्पित a Unexpected; unthought of.
अकल्मष a Sinless.
अकल्याण n Infelicity; injury.
अकस m Malice, spite, grudge.
अकसखोर a Spiteful, malicious
अकसी a Spiteful, malicious
अकस्मात् ad Suddenly, unexpectedly, inconsiderately.
अकस्मात ad Suddenly, unexpectedly, inconsiderately.

I normally have the painful task of further removing cases where a word has a single gloss as well as a long definition as in
Code:
अकर्त्तव्य a That which is not proper to be done; improper.

which is reduced to
Code:
अकर्त्तव्य a improper.

If both stages can be handled, it would really help a lot.
I work in a Windows environment. Many thanks for any help given which will be gratefully acknowledged by the community once this simplified dictionary is put on line.
# 2  
Old 09-07-2016
This is a *nix forum. What *nix tools would be available on your windows environment?
The only difference I see in the output file is
Code:
अकर्मक a Intransitive,neuter.

. What exactly is the operation of the script to be?
# 3  
Old 09-07-2016
I have Awk/Gawk and Perl.

May be I did not explain myself clearly. What I need is to remove all glosses which have two or more words and retain only the single words.

This implies a two stage operation. In Stage 1 at present I use a regex to identify such unique words within each string and store the string in a separate file. But then it can so happen that within the string there could also be glosses containing more than one word.
Code:
अकर्त्तव्य a That which is not proper to be done; improper.

In stage 2 I write a second regex to identify the gloss delimited by
Code:
, ; .

resulting in
Code:
अकर्त्तव्य a improper.

and which contains more than one word.
It works but the two stage operation is long and tedious and I was wondering if an Awk or Perl script could do the trick.
Thanks a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regex to identify unique words in a dictionary database

Hello, I have a dictionary which I am building for the Open Source Community. The data structure is as under HEADWORD=PARTOFSPEECH=ENGLISH MEANING as shown in the example below अ=m=Prefix signifying negation. अँहँ=ind=Interjection expressing disapprobation. अं=int=An interjection... (2 Replies)
Discussion started by: gimley
2 Replies

2. Shell Programming and Scripting

Reducing multiple entries in a tri-lingual dictionary to single entries

Dear all, I am editing a tri-lingual dictionary for open source which has the following data structure English headwords <Tab>Devanagari Headwords<Tab>PersoArabic headwords as in the example below to mark, to number अंगणु (اَنگَڻُ) The English headword entry has at times more than one word,... (2 Replies)
Discussion started by: gimley
2 Replies

3. UNIX for Dummies Questions & Answers

Count words in a single column

Dear All, I have set of CSV files (comma separated) and each column have some information in them separated by space. Now I want to count them but have not been successful... Example data desired outcome I have tried few things including the link below. for C in $FILES do... (8 Replies)
Discussion started by: A-V
8 Replies

4. Shell Programming and Scripting

Identifying dupes within a database and creating unique sub-sets

Hello, I have a database of name variants with the following structure: variant=variant=variant The number of variants can be as many as thirty to forty. Since the database is quite large (at present around 60,000 lines) duplicate sets of variants creep in. Thus John=Johann=Jon and... (2 Replies)
Discussion started by: gimley
2 Replies

5. Shell Programming and Scripting

Counting all words that start with a capital letter in a string using python dictionary

Hi, I have written the following python snippet to store the capital letter starting words into a dictionary as key and no of its appearances as a value in this dictionary against the key. #!/usr/bin/env python import sys import re hash = {} # initialize an empty dictinonary for line in... (1 Reply)
Discussion started by: royalibrahim
1 Replies

6. UNIX for Dummies Questions & Answers

extract text between two words on a single line

Hi Guys, Can someone help me with a way to extract text between two words on a single line. For example if the file has below content I want to extract all text between b and f inclusive of b and f. Aparently sed does this but does it line by line and I guess it cannot read word by word. ... (11 Replies)
Discussion started by: krishnaux
11 Replies

7. Shell Programming and Scripting

grep multiple words in a single line

Hi.. How to search for multiple words in a single line using grep?. Eg: Jack and Jill went up the hill Jack and Jill were best friends Humpty and Dumpty were good friends too ---------- I want to extract the 2nd statement(assuming there are several statements with... (11 Replies)
Discussion started by: anduzzi
11 Replies

8. Shell Programming and Scripting

Grep all words with "con" in them from a dictionary?

Is it possible to grep all words with the string "con" "Con" "CON" etc. etc. from a dictionary? for instance "magic command 'con' dictionary" will spit out words such as Confluence, contended, inconceivable etc etc. I really need this! Thank you! (14 Replies)
Discussion started by: guptaxpn
14 Replies

9. UNIX for Advanced & Expert Users

dictionary words in vim

how can i get the dictionary words in vim using keyboard keys? and how can i get the current directory filename? (1 Reply)
Discussion started by: lakshmananindia
1 Replies
Login or Register to Ask a Question