| | |
trying to put it all together
![]() |
•
•
Join Date: Apr 2009
Posts: 13
Reputation:
Solved Threads: 0
Hi,
I am Mike and run a small law student site,
recently I was donated a dictionary and have a glossary system installed on my forum.
I am pretty bad with scripting but hope someone can help me along,
What I want is to put the dictionary written like this,
several thousand long,
I want to script this so that the word (in capitols) is placed into one column and the definition in an another column,
I can then place this in to my database, by import..
Can someone help me out?
I am Mike and run a small law student site,
recently I was donated a dictionary and have a glossary system installed on my forum.
I am pretty bad with scripting but hope someone can help me along,
What I want is to put the dictionary written like this,
•
•
•
•
A MENSA ET THORO, from bed and board. A divorce a mensa et thoro, is rather a separation of the parties by act of law, than a dissolution of the marriage. It may be granted for the causes of extreme cruelty or desertion of the wife by the hushand. 2 Eccl. Rep. 208.
This kind of divorce does not affect the legitimacy of children, nor authorize a second marriage. V. A vinculo matrimonii; Cruelty Divorce.
A PRENDRE, French, to take, to seize, in contracts, as profits a prendre. Ham. N. P. 184; or a right to take something out of the soil. 5 Ad. & Ell. 764; 1 N. & P. 172 it differs from a right of way,
which is simply an easement or interest which confers no interest in the land. 5 B. & C. 221.
A QUO, A Latin phrases which signifies from which; example, in the computation of time, the day a quo is not to be counted, but the day ad quem is always included. 13 Toull. n. 52 ; 2 Duv. n. 22. A court a quo, the court from which an appeal has been taken; a judge a quo is a judge of a court below. 6 Mart. Lo. R. 520; 1 Har. Cond. L. R. 501. See Ad quem.
A RENDRE, French, to render, to yield, contracts. Profits a rendre; under this term are comprehended rents and services. Ham N. P. 192.
A VINCULO MATRIMONII, from the bond of marriage. A marriage may be dissolved a vinculo, in many states, as in Pennsylvania, on the ground of canonical disabilities before marriage, as that one of the parties was legally married to a person who was then living; impotence, (q. v.,) and the like adultery cruelty and malicious desertion for two years or more. In New York a sentence of imprisonment for life is also a ground for a divorce a vinculo. When the marriage is dissolved a vinculo, the parties may marry again but when the cause is adultery, the guilty party cannot marry his or her paramour.
AB INITIO, from the beginning.
I want to script this so that the word (in capitols) is placed into one column and the definition in an another column,
I can then place this in to my database, by import..
Can someone help me out?
Last edited by externalaw; Apr 5th, 2009 at 9:10 am.
•
•
Join Date: Apr 2009
Posts: 13
Reputation:
Solved Threads: 0
Last edited by externalaw; Apr 5th, 2009 at 9:22 pm.
•
•
Join Date: Aug 2007
Posts: 165
Reputation:
Solved Threads: 18
•
•
•
•
Sorry yes, in a text file.
Then I can export my database to excel and cut and paste the two columns into there, and import it back into phpmyadmin, a total noob way of doing things I am sure!
Mike
Are all of the CAPITALS terminated with a comma? If so, the task is easier. If many or most are, manually edit the text file to make it 'conformant'.
Give me a little time; I'll work up something using awk() and sed().
N
•
•
Join Date: Aug 2007
Posts: 165
Reputation:
Solved Threads: 18
Try the following two files, an awk script and a sh script. Put them both in the same working directory.
It ain't perfect, and someone with a fresher brain will probably simplify this and make it about perfect. But the result (the example at the very end) is close to what you need.
lawdict.awk:
lawdict.sh:
Example lawdict.sql:
- Put your text into lawdict.txt and ensure it conforms to the one requirement: that all of the ALL CAPS TITLES end with a comma (,).
- Execute the command
sh lawdict.sh. - Edit lawdict.sql and change the last trailing comma to a semi-colon (;).
It ain't perfect, and someone with a fresher brain will probably simplify this and make it about perfect. But the result (the example at the very end) is close to what you need.
lawdict.awk:
Shell Scripting Syntax (Toggle Plain Text)
BEGIN { lineout = ""; printf("INSERT INTO law_dict_table VALUES\n");} { if ($0 ~ /^[A-Z ]*,/) { if (substr(lineout, length(lineout)-6) == "</p><p>") { lineout = substr(lineout, 1, length(lineout)-7); } printf("('%s'),\n", lineout); lineout = $0; } else { if ($0 ~ /^$/) { lineout = lineout "</p><p>"; } else { lineout = lineout $0; } } } END { printf("VALUES ('%s'),\n", lineout); }
lawdict.sh:
Shell Scripting Syntax (Toggle Plain Text)
#! /bin/sh ( sed -e "s/'/\'/g" -e 's/\\/\\\\/g' lawdict.txt \ | awk -f lawdict.awk \ | sed -e 's= </p>=</p>=g' -e "s/^\(('[A-Z ]*\),/\1','/" ) > lawdict.sql
Example lawdict.sql:
Shell Scripting Syntax (Toggle Plain Text)
INSERT INTO law_dict_table VALUES (''), ('A MENSA ET THORO',' from bed and board. A divorce a mensa et thoro, is rather a separation of the parties by act of law, than a dissolution of the marriage. It may be granted for the causes of extreme cruelty or desertion of the wife by the hushand. 2 Eccl. Rep. 208.</p><p>This kind of divorce does not affect the legitimacy of children, nor authorize a second marriage. V. A vinculo matrimonii; Cruelty Divorce.'), ('A PRENDRE',' French, to take, to seize, in contracts, as profits a prendre. Ham. N. P. 184; or a right to take something out of the soil. 5 Ad. & Ell. 764; 1 N. & P. 172 it differs from a right of way,</p><p>which is simply an easement or interest which confers no interest in the land. 5 B. & C. 221.'), ('A QUO',' A Latin phrases which signifies from which; example, in the computation of time, the day a quo is not to be counted, but the day ad quem is always included. 13 Toull. n. 52 ; 2 Duv. n. 22. A court a quo, the court from which an appeal has been taken; a judge a quo is a judge of a court below. 6 Mart. Lo. R. 520; 1 Har. Cond. L. R. 501. See Ad quem.'), ('A RENDRE',' French, to render, to yield, contracts. Profits a rendre; under this term are comprehended rents and services. Ham N. P. 192.'), ('A VINCULO MATRIMONII',' from the bond of marriage. A marriage may be dissolved a vinculo, in many states, as in Pennsylvania, on the ground of canonical disabilities before marriage, as that one of the parties was legally married to a person who was then living; impotence, (q. v.,) and the like adultery cruelty and malicious desertion for two years or more. In New York a sentence of imprisonment for life is also a ground for a divorce a vinculo. When the marriage is dissolved a vinculo, the parties may marry again but when the cause is adultery, the guilty party cannot marry his or her paramour.'), VALUES ('AB INITIO, from the beginning.');
•
•
Join Date: Aug 2007
Posts: 165
Reputation:
Solved Threads: 18
•
•
•
•
Hi,
I send you a PM with the source and database structure..
The script I posted, with a minor change, will probably correctly handle the majority of the entries. But proof reading will still be necessary to ensure the task was done correctly. Also, in skimming a little bit of the data, I noticed a few spots of grammatical nonsense; the data should receive a proper proof-reading anyway.
Give me a few days; I'll see what I can hack together.
![]() |
Similar Threads
- Did Hubby Put Spyware on My PC??! (Viruses, Spyware and other Nasties)
- I can't put my computer on standby? (Windows NT / 2000 / XP)
- Where I have to put my... (PHP)
- How do I put up an icon? (Geeks' Lounge)
- how do i put message boards on my site?? please help!! thanx (JavaScript / DHTML / AJAX)
- Manually Put Your Computer into Hibernation (Windows tips 'n' tweaks)
Other Threads in the Shell Scripting Forum
- Previous Thread: question on using awk/gawk
- Next Thread: beginner help
| Thread Tools | Search this Thread |






