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
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
40 deletions
+41
-40
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
+13
-10
views.py
SearchEngine/InvertedIndexSimulator/views.py
+27
-7
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
...
@@ -12,31 +12,9 @@ from Sastrawi.Stemmer.StemmerFactory import StemmerFactory
from
itertools
import
count
from
itertools
import
count
import
collections
import
collections
import
math
import
math
from
xml.etree.ElementTree
import
ElementTree
import
pandas
as
pd
from
django.shortcuts
import
render
import
xml.etree.ElementTree
as
et
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###################
##############Remove Punctuation, URL and Tokenize###################
def
remove_punc_tokenize
(
sentence
):
def
remove_punc_tokenize
(
sentence
):
tokens
=
[]
tokens
=
[]
...
@@ -227,7 +205,7 @@ def main(query):
...
@@ -227,7 +205,7 @@ def main(query):
return
hasil
return
hasil
def
detail
(
nomor
):
def
detail
(
nomor
):
tree
=
ElementTree
()
tree
=
et
()
tree
.
parse
(
"apps/data/dataset_STBI.xml"
)
tree
.
parse
(
"apps/data/dataset_STBI.xml"
)
all_doc_no
=
[]
all_doc_no
=
[]
...
...
SearchEngine/InvertedIndexSimulator/templates/apps/dataframe.html
View file @
2d3e3a1a
...
@@ -17,18 +17,21 @@
...
@@ -17,18 +17,21 @@
<center><h1>
Dataset
</h1><br>
<center><h1>
Dataset
</h1><br>
<table
style=
"width:100%"
>
<table
style=
"width:100%"
>
<tr>
<tr>
{% for data in DataFrame %}
<th>
DOCNO
</th>
<th>
{{ data }}
</th>
<th>
SONG
</th>
{% endfor %}
<th>
ARTIST
</th>
<th>
LYRICS
</th>
</tr>
{% for i, row in DataFrame.iterrows
%}
{% for l in LYRICS
%}
<tr>
<tr>
{% for value in data %}
<td>
{{ i }}
</td>
<td>
{{ value }}
</td>
<td>
{{ j }}
</td>
{% endfor %}
<td>
{{ k }}
</td>
<td>
{{ l }}
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
</tr>
</table>
</table>
</center>
</center>
</article>
</article>
...
@@ -36,9 +39,9 @@
...
@@ -36,9 +39,9 @@
</main>
</main>
<footer>
<
!-- <
footer>
<p>© STBI-2020-03</p>
<p>© STBI-2020-03</p>
</footer>
</footer>
-->
</body>
</body>
...
...
SearchEngine/InvertedIndexSimulator/views.py
View file @
2d3e3a1a
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
InvertedIndexSimulator.inverted
import
main
from
InvertedIndexSimulator.inverted
import
main
# Create your views here.
import
pandas
as
pd
# def index(request):
import
xml.etree.ElementTree
as
et
# return HttpResponse("Hello, world. You're at the polls index.")
def
home
(
request
):
def
home
(
request
):
return
render
(
request
,
'apps/home.html'
)
return
render
(
request
,
'apps/home.html'
)
def
dataframe
(
request
):
def
dataframe
(
request
):
import
pandas
as
pd
import
xml.etree.ElementTree
as
et
parse_data
=
et
.
parse
(
"InvertedIndexSimulator/data/dataset_STBI.xml"
)
parse_data
=
et
.
parse
(
"InvertedIndexSimulator/data/dataset_STBI.xml"
)
data
=
parse_data
.
getroot
()
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
):
def
preprocessing
(
request
):
return
render
(
request
,
'apps/preprocessing.html'
)
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