Skip to content

Commit

Permalink
Merge pull request #72 from KELLIA/dev
Browse files Browse the repository at this point in the history
Dev - V2.0.0
  • Loading branch information
amir-zeldes authored Jun 21, 2019
2 parents 85ae041 + 47e9ba4 commit 463a01d
Show file tree
Hide file tree
Showing 9 changed files with 252 additions and 64 deletions.
83 changes: 78 additions & 5 deletions css/coptic_dictionary.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ body{
}

.anti{font-family: antinoouRegular, sans-serif;}
#orths td{font-family: antinoouRegular, sans-serif;}
#orths td{font-family: antinoouRegular, sans-serif; vertical-align: top;}
#results td{font-family: antinoouRegular, sans-serif;}
#senses td{font-family: antinoouRegular, sans-serif;}
.entrylist td{font-family: antinoouRegular, sans-serif;}
Expand Down Expand Up @@ -102,7 +102,7 @@ ol{margin: 0px !important}
.icon-annis:before {
content: "\e608";
font-family: 'annistools';
color: #6d2020;
color: #AE2124;
}


Expand Down Expand Up @@ -141,9 +141,9 @@ ol{margin: 0px !important}
border: 1px solid gray;
}

.freq_icon{color: #6d2020;
.freq_icon{color: #AE2124;
position: relative;
top: -3px;
top: 6px;
}


Expand Down Expand Up @@ -323,6 +323,8 @@ padding:2px
}

.annis_link {
vertical-align:top;
text-align:right;
color:#9e6a43;
}

Expand All @@ -331,4 +333,75 @@ padding:2px
}

.orth_table_header > th{font-family: antinoouRegular; padding-left:5px}
.dialect{text-align:center}
.dialect{text-align:center}
.btn-page{margin:10px}

th.annis_link, th.tla_orth_id{color:#333}
table a i.freq-icon{color:#AE2124;}

td.colloc{text-align:left}


.fa-rotate-45 {
top:11px;
font-size:73%;
text-align:left;
color:#AE2124 !important;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}

.fa-rotate-315 {
top:-9px;
font-size:73%;
text-align:left;
color:#AE2124 !important;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}

.scriptorium_logo{height:16px;
width:16px;
top: -2px;
position: relative;
}

.tla_no_header{
color:#41494e;
}

.col-lg-12 > .page-header{margin-bottom: 0px !important; margin-top: 0px !important}
.col-lg-12 > .page-header > h2 {margin-top: 0px !important}

.single_sense{margin-left:24px}

.webservice_example_table{ border-collapse: collapse;
background: #fff;
border-radius: 10px;
/*overflow: hidden;*/
width: 100%;
margin: 0 auto;
/*position: relative;*/
}

.webservice_example_table tr th{background: #36304a;}

.webservice_example_table th{
font-size: 18px;
color: #fff;
line-height: 1.2;
font-weight: unset;}

.webservice_example_table td { padding: 5px !important;word-break: break-all;vertical-align:top;}

.webservice_example_table tr:nth-child(even) {
background-color: #f5f5f5;
}

.webservice_code{width:75% !important}
54 changes: 36 additions & 18 deletions entry.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,31 @@ def second_orth(orthstring):
if second_orth is not None:
if second_orth.group(2) != first:
return second_orth.group(2) + dots
return "--"
return "–"

def sense_list(sense_string):
senses = sense_string.split("|||")
sense_html = "<ol>"
if len(senses) > 1:
sense_html = "<ol>"
opener = "<li>"
closer = ""
else:
sense_html = ""
opener = '<div class="single_sense">'
closer = "</div>"
for sense in senses:
definition = re.search(r'~~~(.*);;;', sense)
if definition is not None:
sense_html += "<li>" + definition.group(1).encode("utf8") + "</li>"
sense_html += "</ol>"
sense_html += opener + definition.group(1).encode("utf8") + closer
if len(senses) > 1:
sense_html += "</ol>"
return sense_html

def process_orthstring(orthstring, orefstring, cursor, cs_pos=None):
forms = orthstring.split("|||")
orefs = orefstring.split("|||")
orth_html = '<table id="orths">'
orth_html += '<tr class="orth_table_header"><th>Form</th><th>Dial.</th><th class="tla_orth_id">TLA form ID</th><th class="tla_orth_id">POS </th><th colspan="3" class="annis_link">ANNIS</th></tr>'
orth_html += '<tr class="orth_table_header"><th>Form</th><th>Dial.</th><th class="tla_orth_id">Form ID</th><th class="tla_orth_id">POS </th><th colspan="3" class="annis_link">Attestation</th></tr>'

for i, form in enumerate(forms):
parts = form.split("\n")
Expand All @@ -82,7 +90,7 @@ def process_orthstring(orthstring, orefstring, cursor, cs_pos=None):
geo_string.encode("utf8") + '</td><td class="tla_orth_id">' + \
form_id.encode("utf8") + '</td><td class="morphology">' + \
gramstring.encode("utf8") + '</td><td class="annis_link"><a href="' + annis_query + \
'" target="_new"><i class="fa icon-annis" title="Search in ANNIS"></i></a></td>'
'" target="_new"><img src="img/scriptorium.png" class="scriptorium_logo" title="Search in Coptic Scriptorium"></a></td>'
freq_data = get_freqs(distinct_orth)
freq_info = """ <td><div class="expandable">
<a class="dict_tooltip" href="">
Expand All @@ -96,9 +104,12 @@ def process_orthstring(orthstring, orefstring, cursor, cs_pos=None):

colloc_data = get_collocs(distinct_orth,cursor)
if len(colloc_data) > 0:
colloc_info = """ <td><div class="expandable">
colloc_info = """ <td class="colloc"><div class="expandable">
<a class="dict_tooltip" href="">
<i class="fa fa-comment-o freq_icon">&nbsp;</i>
<b class="fa-stack freq-icon">
<i class="fa fa-share-alt fa-stack-1x fa-rotate-315"></i>
<i class="fa fa-share-alt fa-stack-1x fa-rotate-45"></i>
</b>
<span><b>Top collocations in ANNIS: (5 word window)</b><br/><table class="colloc_tab">
<tr><th>&nbsp;</th><th>Word</th><th>Co-occurrences</th><th>Association (MI3)</th></tr>"""
for r, row in enumerate(colloc_data):
Expand Down Expand Up @@ -147,7 +158,12 @@ def process_sense(de, en, fr):
ref_bibl = gloss_bibl(ref_bibl)

engstr = "(En) " if (de_parts is not None or fr_parts is not None) else ""
sense_html += '<tr><td class="entry_num">' + sense_parts.group(1).encode("utf8") + '.</td><td class="sense_lang">'+engstr+'</td><td class="trans">' + en_definition.encode("utf8") + '</td></tr>'
if len(en_senses) > 1:
counter = sense_parts.group(1).encode("utf8") + ".&nbsp;".encode("utf8")
else:
counter = ""
engstr = "(En)"
sense_html += '<tr><td class="entry_num">' + counter + '</td><td class="sense_lang">'+engstr+'</td><td class="trans">' + en_definition.encode("utf8") + '</td></tr>'
if fr_parts is not None:
sense_html += '<tr><td></td><td class="sense_lang">(Fr) </td><td class="trans">' + fr_definition.encode("utf8") + '</td></tr>'
if de_parts is not None:
Expand Down Expand Up @@ -191,7 +207,7 @@ def related(related_entries):


def get_freqs(item):
item = item.replace("-","")#.replace("⸗".encode("utf8"),"")
item = item.replace("-","").replace("⸗".decode("utf8"),"")
output = "<ul>\n"
if platform.system() == 'Linux':
con = lite.connect('alpha_kyima_rc1.db')
Expand All @@ -211,7 +227,7 @@ def get_freqs(item):
output += "<li>Word form frequency per 10,000: "+str(freq)+" (# "+str(rank)+")</li>\n"
else:
output += "<li>Not found as word form in ANNIS</li>\n"
sql = "SELECT lemma_freq, lemma_rank FROM lemmas WHERE word = ?;"
sql = "SELECT lemma_freq, lemma_rank FROM lemmas WHERE lemma = ?;"
cur.execute(sql, (item,))
res = cur.fetchone()
if res is not None:
Expand All @@ -224,7 +240,8 @@ def get_freqs(item):


def get_collocs(word, cursor):
thresh = 15
word = word.replace("-","")
thresh = 10
sql = "SELECT * from collocates WHERE lemma=? and not collocate in ('ⲡ','ⲛ','ⲧ','ⲟⲩ') and assoc > ? ORDER BY assoc DESC LIMIT 20"
rows = cursor.execute(sql,(word,thresh)).fetchall()
return rows
Expand Down Expand Up @@ -275,7 +292,7 @@ def gloss_bibl(ref_bibl):
def extract_lemma(db_name_field):
try:
lemma = db_name_field.split("|||")[0].split("\n")[1].split("~")[0]
lemma = '<span style="font-family: antinoouRegular, sans-serif">' + lemma + '</span>'
lemma = '<span style="font-family: antinoouRegular, sans-serif; font-size: larger">' + lemma + '</span>'
except:
lemma = ""
return lemma
Expand Down Expand Up @@ -353,7 +370,7 @@ if __name__ == "__main__":
entry_page += '<div class="tag">\n\tScriptorium tag: ' + tag + "\n</div>\n"

# from sense info
entry_page += '<div class="sense_info"><b style="font-family: antinoouRegular">Senses:</b><br/>'
entry_page += '<div class="sense_info">'
entry_page += process_sense(this_entry[4], this_entry[5], this_entry[6])
entry_page += '</div>'

Expand All @@ -370,14 +387,15 @@ if __name__ == "__main__":

lemma = extract_lemma(this_entry[2])

xml_id_string = 'TLA lemma no. ' + entry_xml_id +" ("+lemma+")" if entry_xml_id != "" else ""

entry_page += '<div id="citation_info_box">Please cite as: '+xml_id_string.encode("utf8")+', in: <i>Coptic Dictionary Online</i>, ed. by the Koptische/Coptic Electronic Language and Literature International Alliance (KELLIA), http://www.coptic-dictionary.org/entry.cgi?tla='+entry_xml_id.encode("utf8")+' (accessed yyyy-mm-dd).</div>'
xml_id_string = '<span class="tla_no_header">TLA lemma no. ' + entry_xml_id +"</span><br/>" + lemma if entry_xml_id != "" else ""
citation_id_string = 'TLA lemma no. ' + entry_xml_id +" ("+lemma+")" if entry_xml_id != "" else ""

entry_page += '<div id="citation_info_box">Please cite as: '+citation_id_string.encode("utf8")+', in: <i>Coptic Dictionary Online</i>, ed. by the Koptische/Coptic Electronic Language and Literature International Alliance (KELLIA), http://www.coptic-dictionary.org/entry.cgi?tla='+entry_xml_id.encode("utf8")+' (accessed yyyy-mm-dd).</div>'

wrapped = wrap(entry_page)

# adding TLA lemma no. to title and citation info
wrapped = re.sub(r"(Entry detail[^<>]*</h2>)",r"Entry "+xml_id_string.encode("utf8") +"</h2>\n",wrapped)
wrapped = re.sub(r"(Entry detail[^<>]*</h2>)",xml_id_string.encode("utf8") +"</h2>\n",wrapped)

# add Greek form disclaimer if needed:
if len(grk_id) > 0:
Expand Down
Binary file added img/scriptorium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 463a01d

Please sign in to comment.