#!/usr/bin/perl
####!/oradata1/perl5/bin/perl
###use Oraperl;
require "cgi-lib.cgi";
require "homer-lib.cgi";
#\
# This was originally coded to present grammatical information in
# table form. When we switched to list form, I left the table code in;
# just create a way for the user to set this to 0.
#/
$list_format = 1;
&write_state;
print "Content-type: text/html\n\n";
print "
\n", $ServiceTitle, "\n";
print '';
print "\n";
print "";
#print "Display language = $in{'display_lang'}";
($level1_id,$level2_id,$line_id) = split(/\./, $in{'loc'});
$word_id = $in{'word_id'};
if ($level1_id && $level2_id && $line_id && $word_id)
{
## ok, we have all the pieces we need
}
else
{
&show_footer;
exit;
}
$lda = &ora_login($system_id, $netid, $pwd) || &oracle_error($ora_errstr);
#\
# This first cursor lets us get the traditional canonical reference which is
# tricky because the number of levels is different for Hesiod from the rest
# of the corpus.
#/
$sql = "SELECT DISTINCT work.sgmlid, work.level2_id
FROM work
WHERE work.level1_id = $level1_id
AND (work.level2_id is NULL OR work.level2_id = $level2_id)";
$csr = &ora_open($lda,$sql) || &oracle_error($ora_errstr);
($text_abbrv, $in_hesiod) = &ora_fetch($csr);
&ora_close($csr) || &oracle_error($ora_errstr);
if ($in_hesiod)
{
$trad_loc = "$text_abbrv.$line_id";
}
else
{
$trad_loc = "$text_abbrv.$level2_id.$line_id";
}
#\
# This second cursor actually fetches the morphological information.
#/
# version using inflection is commented out
#$sql = "SELECT morph_base.word_form, morph_base.lemma,
#morph_base.word_type, word_state.tense, word_state.mood, word_state.voice,
#word_state.case, word_state.gender, word_state.person, word_state.word_state_number,
#inflection.augment, inflection.inflection
#FROM morph_base, word_state, inflection, loc_morph
#WHERE inflection.inflection_id = morph_base.inflection_id
# and morph_base.word_state_id = word_state.word_state_id
# and morph_base.morph_id = loc_morph.morph_id
# and loc_morph.level1_id=$level1_id
# and loc_morph.level2_id=$level2_id
# and loc_morph.line_id=$line_id
# and loc_morph.word_id=$word_id";
#$sql = "SELECT morph_base.word_form, morph_base.lemma,
#morph_base.word_type, word_state.tense, word_state.mood, word_state.voice,
#word_state.case, word_state.gender, word_state.person, word_state.word_state_number
#FROM morph_base, word_state, loc_morph
#WHERE morph_base.word_state_id = word_state.word_state_id
# and morph_base.morph_id = loc_morph.morph_id
# and loc_morph.level1_id=$level1_id
# and loc_morph.level2_id=$level2_id
# and loc_morph.line_id=$line_id
# and loc_morph.word_id=$word_id";
$sql = "SELECT morph_base.word_form, morph_base.xlit_word_form, morph_base.morph_id,lemma.lemma, lemma.xlit_lemma, lemma.lemma_id ,
lemma.word_type, word_state.tense, word_state.mood, word_state.voice,
word_state.case, word_state.gender, word_state.person, word_state.word_state_number
FROM morph_base, word_state, loc_morph , lemma
WHERE morph_base.word_state_id = word_state.word_state_id
and morph_base.morph_id = loc_morph.morph_id
and loc_morph.level1_id=$level1_id
and loc_morph.level2_id=$level2_id
and loc_morph.line_id=$line_id
and loc_morph.word_id=$word_id
and lemma.lemma_id = morph_base.lemma_id";
# print $sql;
$csr = &ora_open($lda,$sql) || &oracle_error($ora_errstr);
($word_form, $xlit_word_form, $morph_id, $lemma, $xlit_lemma, $lemma_id,
$word_type, $tense, $mood, $voice,
$case, $gender, $person, $number) = &ora_fetch($csr);
&ora_close($csr) || &oracle_error($ora_errstr);
#\
# This cursor gets the basic frequency information by text (level1_id actually).
#/
$sql = "SELECT lemma_freq.level1_id, lemma_freq.count, lemma_freq.freq10k, lemma_freq.ratio
FROM lemma_freq where lemma_freq.lemma_id=$lemma_id";
$sql = "SELECT * FROM lemma WHERE lemma_id = $lemma_id";
$csr = &ora_open($lda,$sql) || &oracle_error($ora_errstr);
@lemma_record = &ora_fetch($csr);
$lemma_record[8] = &dec_round($lemma_record[8]);
$lemma_record[9] = &dec_round($lemma_record[9]);
$lemma_record[11] = &dec_round($lemma_record[11]);
$lemma_record[12] = &dec_round($lemma_record[12]);
$lemma_record[14] = &dec_round($lemma_record[14]);
$lemma_record[15] = &dec_round($lemma_record[15]);
$lemma_record[17] = &dec_round($lemma_record[17]);
$lemma_record[18] = &dec_round($lemma_record[18]);
$lemma_record[20] = &dec_round($lemma_record[20]);
$lemma_record[21] = &dec_round($lemma_record[21]);
&ora_close($csr) || &oracle_error($ora_errstr);
$freq_table = "";
# Check Iliad count
if($lemma_record[7]) {$freq_table .= "
| Iliad | $lemma_record[7] | $lemma_record[9] | $lemma_record[8] |
\n";}
if($lemma_record[10]) {$freq_table .= "| Odyssey | $lemma_record[10] | $lemma_record[12] | $lemma_record[11] |
\n";}
if($lemma_record[13]) {$freq_table .= "| Hesiod | $lemma_record[13] | $lemma_record[15] | N/A |
\n";}
if($lemma_record[16]) {$freq_table .= "| Four Hymns | $lemma_record[16] | $lemma_record[18] | $lemma_record[17] |
\n";}
if($lemma_record[19]) {$freq_table .= "| Later Hymns | $lemma_record[19] | $lemma_record[21] | N/A |
\n";}
$freq_table .= "| Corpus Total | $lemma_record[6] | N/A | N/A |
\n";
&ora_logoff($lda) || &oracle_error($ora_errstr);
$link_word_form = $word_form;
$link_word_form =~ s/\=/%3d/g;
$link_word_form =~ s/\+/%2b/g;
$link_lemma = $lemma;
$link_lemma =~ s/\=/%3d/g;
$link_lemma =~ s/\+/%2b/g;
#$word_url = "";
#$lemma_url = "";
#$lsj_url = "";
if($in{'display_lang'} eq 'lang_grk')
{
$lemma_url ="show_concord.cgi?searchType=lemma&lemma_id=$lemma_id&search_term=$lemma&lang_in=$in{'display_lang'}&display_lang=$in{'display_lang'}&";
$lemma_url =~ s/\s+/+/g;
$lemma_link = "";
$word_url ="show_concord.cgi?searchType=morph&morph_id=$morph_id&search_term=$word_form&lang_in=$in{'display_lang'}&display_lang=$in{'display_lang'}&";
$word_url =~ s/\s+/+/g;
$word_link = "";
} else
{
$link_word_form = $xlit_word_form;
$link_word_form =~ s/\=/%3d/g;
$link_word_form =~ s/\+/%2b/g;
$link_word_form =~ s/&/%26/g;
$link_word_form =~ s/;/%3b/g;
$link_lemma = $xlit_lemma;
$link_lemma =~ s/\=/%3d/g;
$link_lemma =~ s/\+/%2b/g;
$link_lemma =~ s/&/%26/g;
$link_lemma =~ s/;/%3b/g;
$lemma_url ="show_concord.cgi?searchType=lemma&lemma_id=$lemma_id&search_term=$link_lemma&lang_in=$in{'display_lang'}&display_lang=$in{'display_lang'}&";
$lemma_url =~ s/\s+/+/g;
$lemma_link = "";
$word_url ="show_concord.cgi?searchType=morph&morph_id=$morph_id&search_term=$link_word_form&lang_in=$in{'display_lang'}&display_lang=$in{'display_lang'}&";
$word_url =~ s/\s+/+/g;
$word_link = "";
}
#$word_url = "";
#$lemma_url = "";
#$lsj_url = "";
$lsj_url = "";
if ($state_array{'layout'} =~ /vert/i
|| $state_array{'layout'} =~ /tab/ )
{
# vertical frames or columns
print '';
print "
";
print "Grammar ($trad_loc, word $word_id)";
print "\n";
print "| Word form | ";
print "Lemma $lsj_url (LSJ) | ";
if ($list_format)
{
print "Description | \n";
}
else
{
print "Part of speech | ";
####print "Word type | ";
if ($tense) {print "Tense | ";}
if ($mood) {print "Mood | ";}
if ($voice) {print "Voice | ";}
if ($gender) {print "Gender | ";}
if ($case) {print "Case | ";}
if ($person) {print "Person | ";}
if ($number) {print "Number | ";}
#### if ($augment) {print "Augment | ";}
####if ($inflection) {print "Inflection | ";}
}
print " \n";
if($in{'display_lang'} eq 'lang_grk')
{
print "| ";
print $word_link;
$word_form = &fix_beta_for_display($word_form);
print "$word_form | ";
print "";
print $lemma_link;
$lemma = &fix_beta_for_display($lemma);
print "$lemma | ";
} else
{
print " | ";
print $word_link;
print "$xlit_word_form | ";
print "";
print $lemma_link;
print "$xlit_lemma | ";
}
if ($list_format)
{
&build_description;
print "$description | ";
}
else
{
#### print "$part_of_speech | ";
print "$word_type | ";
if ($tense) {print "$tense | ";}
if ($mood) {print "$mood | ";}
if ($voice) {print "$voice | ";}
if ($gender) {print "$gender | ";}
if ($case) {print "$case | ";}
if ($person) {print "$person | ";}
if ($number) {print "$number | ";}
#### if ($augment) {print "$augment | ";}
####if ($inflection) {print "$inflection | ";}
}
print " \n";
}
else
{
# horizontal frames or interlinear
print '';
print " Grammar ($trad_loc, word $word_id)";
print " \n";
if($in{'display_lang'} eq 'lang_grk')
{
print "| Word form | ";
print $word_link;
$word_form = &fix_beta_for_display($word_form);
print "$word_form | \n";
print "| Lemma $lsj_url (LSJ) | ";
print $lemma_link;
$lemma = &fix_beta_for_display($lemma);
print "$lemma | \n";
} else
{
print "| Word form | ";
print $word_link;
print "$xlit_word_form | \n";
print "| Lemma $lsj_url (LSJ) | ";
print $lemma_link;
print "$xlit_lemma | \n";
}
if ($list_format)
{
print "| Description | \n";
&build_description;
print $description;
print " | \n";
}
else
{
####print "| Part of speech | $part_of_speech | \n";
print "| Word type | $word_type | \n";
if ($tense) {print "| Tense | $tense | \n";}
if ($mood) {print "| Mood | $mood | \n";}
if ($voice) {print "| Voice | $voice | \n";}
if ($gender) {print "| Gender | $gender | \n";}
if ($case) {print "| Case | $case | \n";}
if ($person) {print "| Person | $person | \n";}
if ($number) {print "| Number | $number | \n";}
#### if ($augment) {print "| Augment | $augment | \n";}
####if ($inflection) {print "| Inflection | $inflection | \n";}
}
}
print " \n";
if ($state_array{'layout'} =~ /vert/i
|| $state_array{'layout'} =~ /tab/ )
{
print " ";
}
#print " Lemma occurs in:";
print " Lemma Frequency ";
print " \n";
print "| Title | Count | N. Freq. | Sp. Freq. | \n";
print $freq_table;
print " \n";
print "Lemma frequency gives counts and frequencies per 10,000 lines of narrative or speech. 'Four Hymns' refers to Demeter, Apollo, Hermes, and Aphrodite Hymns. 'Later Hymns' refers to the other Homeric Hymns. Narrative and spoken frequencies are not separated for Hesiod or the Later Hymns.";
if ($state_array{'layout'} =~ /vert/i
|| $state_array{'layout'} =~ /tab/ )
{
print " | \n";
}
print '';
&show_footer;
exit;
sub build_description
{
####$description = "$part_of_speech";
$description = "$word_type";
if ($tense) {$description .= ", $tense";}
if ($mood) {$description .= ", $mood";}
if ($voice) {$description .= ", $voice";}
if ($gender) {$description .= ", $gender";}
if ($case) {$description .= ", $case";}
if ($person) {$description .= ", $person";}
if ($number) {$description .= ", $number";}
#### if ($augment) {$description .= ", $augment";}
####if ($inflection) {$description .= ", $inflection";}
}
sub dec_round {
my($inval) = @_;
my($outval);
if($inval =~ /^(\d+)\.(\d)([0-9])$/)
{
$int = $1;
$ten = $2;
$hund = $3;
if($hund >= 5)
{
if($ten == 9)
{
$int++;
$ten = '0';
} else
{
$ten++;
}
}
$outval = $int . '.' . $ten;
} else
{
$outval = $inval;
}
}
|