Skip to content

Commit

Permalink
Dockerized project
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish Rao authored and Ashish Rao committed Mar 3, 2023
1 parent 56d4be8 commit 7495b79
Show file tree
Hide file tree
Showing 27 changed files with 2,106 additions and 2,003 deletions.
Binary file modified .DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.10.8
ENV pythonunbuffered 1

WORKDIR /lira-docker
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
RUN python -m nltk.downloader punkt
CMD python manage.py runserver 0.0.0.0:80
Binary file modified Lira/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file modified Recommender/__pycache__/views.cpython-310.pyc
Binary file not shown.
52 changes: 34 additions & 18 deletions Recommender/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
digits = "([0-9])"

def split_into_sentences(text):
text = " " + text + " "
print("TEXT:",text)
text = " " + str(text) + " "
text = text.replace("\n"," ")
text = re.sub(prefixes,"\\1<prd>",text)
text = re.sub(websites,"<prd>\\1",text)
Expand Down Expand Up @@ -87,7 +88,7 @@ def get_similar_docs(cluster,casename):
if data1['Predicted_category'].iloc[i] == cluster and data1['File Name'].iloc[i] != casename:
d2 = model.dv[str(i)]
similarities.append(np.dot(matutils.unitvec(v1), matutils.unitvec(d2)))
files.append(data1['File Name'].iloc[i].split(r".")[0])
files.append(data1['File Name'].iloc[i])
d2v_df = pd.DataFrame({'filename':files,'similarities':similarities})
results = d2v_df.sort_values(by=['similarities'],ascending = False).head()
result = results.to_dict()
Expand Down Expand Up @@ -132,26 +133,23 @@ def search(request):
return render(request, 'search.html')

def abstract_summary(casename):
print(casename in set(summaries_data['File Name']))
texts = []
if casename in set(summaries_data['File Name']):
case_row = summaries_data[summaries_data['File Name'] == casename].head(1)
if not case_row['summary'].values[0] == '':
abstract = case_row['summary'].values[0]
return abstract

chosen_row = raw_data[raw_data['File Name'] == casename].head(1)
if chosen_row['text'].values:
article_text = chosen_row['text'].values[0]
texts = sent_tokenize(article_text)
else:
chosen_row = data1[data1['File Name'] == casename].head(1)
article_text = chosen_row['text'].values[0]
texts = split_into_sentences(article_text)

texts = split_into_sentences(article_text)
i = 0
steps = 40
summary_text = ''
print('here: ',texts)
while i < len(texts):
print(f"{round(100 * (i / len(texts)),2)}%")
if i+steps < len(texts):
Expand All @@ -164,8 +162,10 @@ def abstract_summary(casename):
time.sleep(20)
i += steps
summary_row = summaries_data[summaries_data['File Name'] == casename].head(1).index
summaries_data.at[summary_row,'summary'] = summary_text
summaries_data.to_csv(r'./data/summaries.csv')
if summary_text:
print(summary_row)
summaries_data.at[summary_row,'summary'] = summary_text
summaries_data.to_csv(r'./data/summaries.csv')
# article_text = re.sub(r'[[0-9]*]', ' ', article_text)
# article_text = re.sub(r'\s+', ' ', article_text)

Expand Down Expand Up @@ -213,11 +213,14 @@ def summary(request):
# summary_row = summary_file[summary_file['File Name'] == casename].head(1)
# summary = summary_row['summary'].values[0]
case_row = case_details[case_details['File Name'] == casename].head(1)

data_case_name = case_row['Case Name'].values[0]
involved = case_row['Involved Personell'].values[0]
date_decided = case_row['Date (Decided)'].values[0]
court = case_row['Court'].values[0]
if case_row['Case Name'].values:
data_case_name = case_row['Case Name'].values[0]
if case_row['Involved Personell'].values:
involved = case_row['Involved Personell'].values[0]
if case_row['Date (Decided)'].values:
date_decided = case_row['Date (Decided)'].values[0]
if case_row['Court'].values:
court = case_row['Court'].values[0]
category = case_row['category'].values[0]
similar_docs = get_similar_docs(category,casename)
if category == 62:
Expand All @@ -227,8 +230,21 @@ def summary(request):
else:
category = 'Environment'
abstract = abstract_summary(casename)
if math.isnan(court): court = ''
if math.isnan(date_decided): date_decided = ''
if math.isnan(involved): involved = ''
if math.isnan(data_case_name): data_case_name = ''
try:
if math.isnan(court): court = ''
except:
pass
try:
if math.isnan(date_decided): date_decided = ''
except:
pass
try:
if math.isnan(involved): involved = ''
except:
pass
try:
if math.isnan(data_case_name): data_case_name = ''
except:
pass

return render(request, 'summary.html',{'abstract_summary':abstract,'similar_docs':similar_docs,'data_case_name':data_case_name,'involved':involved,'date_decided':date_decided,'court':court,'category':category,'query':query})
57 changes: 36 additions & 21 deletions assets/admin/css/autocomplete.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ select.admin-autocomplete {

.select2-container--admin-autocomplete.select2-container--focus .select2-selection,
.select2-container--admin-autocomplete.select2-container--open .select2-selection {
border-color: #999;
border-color: var(--body-quiet-color);
min-height: 30px;
}

Expand All @@ -29,13 +29,13 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete .select2-selection--single {
background-color: #fff;
border: 1px solid #ccc;
background-color: var(--body-bg);
border: 1px solid var(--border-color);
border-radius: 4px;
}

.select2-container--admin-autocomplete .select2-selection--single .select2-selection__rendered {
color: #444;
color: var(--body-fg);
line-height: 30px;
}

Expand All @@ -46,7 +46,7 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete .select2-selection--single .select2-selection__placeholder {
color: #999;
color: var(--body-quiet-color);
}

.select2-container--admin-autocomplete .select2-selection--single .select2-selection__arrow {
Expand Down Expand Up @@ -80,7 +80,7 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete.select2-container--disabled .select2-selection--single {
background-color: #eee;
background-color: var(--darkened-bg);
cursor: default;
}

Expand All @@ -94,8 +94,8 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete .select2-selection--multiple {
background-color: white;
border: 1px solid #ccc;
background-color: var(--body-bg);
border: 1px solid var(--border-color);
border-radius: 4px;
cursor: text;
}
Expand All @@ -104,16 +104,18 @@ select.admin-autocomplete {
box-sizing: border-box;
list-style: none;
margin: 0;
padding: 0 5px;
padding: 0 10px 5px 5px;
width: 100%;
display: flex;
flex-wrap: wrap;
}

.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__rendered li {
list-style: none;
}

.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__placeholder {
color: #999;
color: var(--body-quiet-color);
margin-top: 5px;
float: left;
}
Expand All @@ -123,11 +125,13 @@ select.admin-autocomplete {
float: right;
font-weight: bold;
margin: 5px;
position: absolute;
right: 0;
}

.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__choice {
background-color: #e4e4e4;
border: 1px solid #ccc;
background-color: var(--darkened-bg);
border: 1px solid var(--border-color);
border-radius: 4px;
cursor: default;
float: left;
Expand All @@ -137,15 +141,15 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__choice__remove {
color: #999;
color: var(--body-quiet-color);
cursor: pointer;
display: inline-block;
font-weight: bold;
margin-right: 2px;
}

.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__choice__remove:hover {
color: #333;
color: var(--body-fg);
}

.select2-container--admin-autocomplete[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--admin-autocomplete[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--admin-autocomplete[dir="rtl"] .select2-selection--multiple .select2-search--inline {
Expand All @@ -163,12 +167,12 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete.select2-container--focus .select2-selection--multiple {
border: solid #999 1px;
border: solid var(--body-quiet-color) 1px;
outline: 0;
}

.select2-container--admin-autocomplete.select2-container--disabled .select2-selection--multiple {
background-color: #eee;
background-color: var(--darkened-bg);
cursor: default;
}

Expand All @@ -186,12 +190,20 @@ select.admin-autocomplete {
border-bottom-right-radius: 0;
}

.select2-container--admin-autocomplete .select2-search--dropdown {
background: var(--darkened-bg);
}

.select2-container--admin-autocomplete .select2-search--dropdown .select2-search__field {
border: 1px solid #ccc;
background: var(--body-bg);
color: var(--body-fg);
border: 1px solid var(--border-color);
border-radius: 4px;
}

.select2-container--admin-autocomplete .select2-search--inline .select2-search__field {
background: transparent;
color: var(--body-fg);
border: none;
outline: 0;
box-shadow: none;
Expand All @@ -201,18 +213,21 @@ select.admin-autocomplete {
.select2-container--admin-autocomplete .select2-results > .select2-results__options {
max-height: 200px;
overflow-y: auto;
color: var(--body-fg);
background: var(--body-bg);
}

.select2-container--admin-autocomplete .select2-results__option[role=group] {
padding: 0;
}

.select2-container--admin-autocomplete .select2-results__option[aria-disabled=true] {
color: #999;
color: var(--body-quiet-color);
}

.select2-container--admin-autocomplete .select2-results__option[aria-selected=true] {
background-color: #ddd;
background-color: var(--selected-bg);
color: var(--body-fg);
}

.select2-container--admin-autocomplete .select2-results__option .select2-results__option {
Expand Down Expand Up @@ -249,8 +264,8 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete .select2-results__option--highlighted[aria-selected] {
background-color: #79aec8;
color: white;
background-color: var(--primary);
color: var(--primary-fg);
}

.select2-container--admin-autocomplete .select2-results__group {
Expand Down
Loading

0 comments on commit 7495b79

Please sign in to comment.