Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SearchEngine
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rosa Delima Mendrofa
SearchEngine
Commits
2d3e3a1a
Commit
2d3e3a1a
authored
May 07, 2020
by
Yolanda Nainggolan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storing multiple dictionary for displaying dataframe
parent
b93842e7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
44 deletions
+45
-44
models.cpython-37.pyc
.../InvertedIndexSimulator/__pycache__/models.cpython-37.pyc
+0
-0
views.cpython-37.pyc
...e/InvertedIndexSimulator/__pycache__/views.cpython-37.pyc
+0
-0
main.cpython-37.pyc
...edIndexSimulator/inverted/__pycache__/main.cpython-37.pyc
+0
-0
main.py
SearchEngine/InvertedIndexSimulator/inverted/main.py
+1
-23
dataframe.html
...gine/InvertedIndexSimulator/templates/apps/dataframe.html
+16
-13
views.py
SearchEngine/InvertedIndexSimulator/views.py
+28
-8
No files found.
SearchEngine/InvertedIndexSimulator/__pycache__/models.cpython-37.pyc
View file @
2d3e3a1a
No preview for this file type
SearchEngine/InvertedIndexSimulator/__pycache__/views.cpython-37.pyc
View file @
2d3e3a1a
No preview for this file type
SearchEngine/InvertedIndexSimulator/inverted/__pycache__/main.cpython-37.pyc
View file @
2d3e3a1a
No preview for this file type
SearchEngine/InvertedIndexSimulator/inverted/main.py
View file @
2d3e3a1a
...
...
@@ -12,31 +12,9 @@ from Sastrawi.Stemmer.StemmerFactory import StemmerFactory
from
itertools
import
count
import
collections
import
math
from
xml.etree.ElementTree
import
ElementTree
import
pandas
as
pd
from
django.shortcuts
import
render
import
xml.etree.ElementTree
as
et
def
data_view
(
data
):
df_cols
=
[
"DOCNO"
,
"SONG"
,
"ARTIST"
,
"LYRICS"
]
rows
=
[]
for
node
in
data
:
s_docno
=
node
.
find
(
"DOCNO"
)
.
text
if
node
is
not
None
else
None
s_song
=
node
.
find
(
"SONG"
)
.
text
if
node
is
not
None
else
None
s_artist
=
node
.
find
(
"ARTIST"
)
.
text
if
node
is
not
None
else
None
s_lyrics
=
node
.
find
(
"LYRICS"
)
.
text
if
node
is
not
None
else
None
rows
.
append
({
"DOCNO"
:
s_docno
,
"SONG"
:
s_song
,
"ARTIST"
:
s_artist
,
"LYRICS"
:
s_lyrics
})
DataFrame
=
pd
.
DataFrame
(
rows
,
columns
=
df_cols
)
return
render
(
data
,
'apps/dataframe.html'
,
{
'DataFrame'
:
DataFrame
})
##############Remove Punctuation, URL and Tokenize###################
def
remove_punc_tokenize
(
sentence
):
tokens
=
[]
...
...
@@ -227,7 +205,7 @@ def main(query):
return
hasil
def
detail
(
nomor
):
tree
=
ElementTree
()
tree
=
et
()
tree
.
parse
(
"apps/data/dataset_STBI.xml"
)
all_doc_no
=
[]
...
...
SearchEngine/InvertedIndexSimulator/templates/apps/dataframe.html
View file @
2d3e3a1a
...
...
@@ -17,18 +17,21 @@
<center><h1>
Dataset
</h1><br>
<table
style=
"width:100%"
>
<tr>
{% for data in DataFrame %}
<th>
{{ data }}
</th>
{% endfor %}
{% for i, row in DataFrame.iterrows %}
<tr>
{% for value in data %}
<td>
{{ value }}
</td>
{% endfor %}
</tr>
{% endfor %}
<th>
DOCNO
</th>
<th>
SONG
</th>
<th>
ARTIST
</th>
<th>
LYRICS
</th>
</tr>
{% for l in LYRICS %}
<tr>
<td>
{{ i }}
</td>
<td>
{{ j }}
</td>
<td>
{{ k }}
</td>
<td>
{{ l }}
</td>
</tr>
{% endfor %}
</table>
</center>
</article>
...
...
@@ -36,9 +39,9 @@
</main>
<footer>
<
!-- <
footer>
<p>© STBI-2020-03</p>
</footer>
</footer>
-->
</body>
...
...
SearchEngine/InvertedIndexSimulator/views.py
View file @
2d3e3a1a
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
InvertedIndexSimulator.inverted
import
main
# Create your views here.
# def index(request):
# return HttpResponse("Hello, world. You're at the polls index.")
import
pandas
as
pd
import
xml.etree.ElementTree
as
et
def
home
(
request
):
return
render
(
request
,
'apps/home.html'
)
def
dataframe
(
request
):
import
pandas
as
pd
import
xml.etree.ElementTree
as
et
parse_data
=
et
.
parse
(
"InvertedIndexSimulator/data/dataset_STBI.xml"
)
data
=
parse_data
.
getroot
()
content
=
main
.
data_view
(
data
)
return
render
(
request
,
'apps/dataframe.html'
,
content
)
df_cols
=
[
"DOCNO"
,
"SONG"
,
"ARTIST"
,
"LYRICS"
]
rows
=
[]
for
node
in
data
:
s_docno
=
node
.
find
(
"DOCNO"
)
.
text
if
node
is
not
None
else
None
s_song
=
node
.
find
(
"SONG"
)
.
text
if
node
is
not
None
else
None
s_artist
=
node
.
find
(
"ARTIST"
)
.
text
if
node
is
not
None
else
None
s_lyrics
=
node
.
find
(
"LYRICS"
)
.
text
if
node
is
not
None
else
None
rows
.
append
({
"DOCNO"
:
s_docno
,
"SONG"
:
s_song
,
"ARTIST"
:
s_artist
,
"LYRICS"
:
s_lyrics
})
DataFrame
=
pd
.
DataFrame
(
rows
,
columns
=
df_cols
)
dictionary
=
DataFrame
.
set_index
(
'DOCNO'
)
.
T
.
to_dict
(
'list'
)
nilai
=
list
(
dictionary
.
values
())
nomornya
=
list
(
dictionary
.
keys
())
lagunya
=
[
sublist
[
0
]
for
sublist
in
nilai
]
artisnya
=
[
sublist
[
1
]
for
sublist
in
nilai
]
liriknya
=
[
sublist
[
2
]
for
sublist
in
nilai
]
context
=
{
"DOCNO"
:
nomornya
,
"SONG"
:
lagunya
,
"ARTIST"
:
artisnya
,
"LYRICS"
:
liriknya
}
return
render
(
request
,
'apps/dataframe.html'
,
context
)
def
preprocessing
(
request
):
return
render
(
request
,
'apps/preprocessing.html'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment