Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
Farse news IR project
Project
Project
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
9831029
Farse news IR project
Commits
88bb2e3d
Commit
88bb2e3d
authored
May 23, 2022
by
Haj Rezvan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimized the functions.
parent
d2249df1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
32 deletions
+23
-32
split_document.py
split_document.py
+23
-32
No files found.
split_document.py
View file @
88bb2e3d
...
...
@@ -13,51 +13,42 @@ def file_open():
__processor
(
file
)
def
__writer
(
doc_id
,
title
,
content
,
url
):
def
__writer
(
doc_id
,
title
,
content
,
url
,
tags
,
date
,
category
):
file
=
open
(
f
"docs/{doc_id}.json"
,
"w"
)
dictionary
=
{
"doc_id"
:
doc_id
,
"title"
:
title
,
"content"
:
content
,
"url"
:
url
"tags"
:
tags
,
"date"
:
date
,
"url"
:
url
,
"category"
:
category
}
json
.
dump
(
dictionary
,
file
)
def
__object_clear
(
lst
):
lst
.
clear
()
def
__processor
(
file
):
data
=
json
.
load
(
file
)
for
i
in
tqdm
(
range
(
14000
),
desc
=
"Splatted: "
):
def
__retrieval
(
data
,
i
,
tag
):
try
:
obj_cnt
=
''
lst
=
list
()
try
:
for
characters
in
data
[
f
"{i}"
][
"title"
]:
for
characters
in
data
[
f
"{i}"
][
tag
]:
lst
.
append
(
characters
)
obj_cnt
=
''
.
join
(
lst
)
return
obj_cnt
except
Exception
as
ignore
:
print
(
f
"We have a Exception!! {ignore.with_traceback}"
)
title
=
obj_cnt
__object_clear
(
lst
)
for
characters
in
data
[
f
"{i}"
][
"content"
]:
lst
.
append
(
characters
)
obj_cnt
=
''
.
join
(
lst
)
content
=
obj_cnt
__object_clear
(
lst
)
for
characters
in
data
[
f
"{i}"
][
"url"
]:
lst
.
append
(
characters
)
obj_cnt
=
''
.
join
(
lst
)
url
=
obj_cnt
__object_clear
(
lst
)
def
__processor
(
file
):
data
=
json
.
load
(
file
)
__writer
(
i
,
title
,
content
,
url
)
except
Exception
as
ignore
:
pass
for
i
in
tqdm
(
range
(
14000
),
desc
=
"Splatted: "
):
title
=
__retrieval
(
data
,
i
,
"title"
)
content
=
__retrieval
(
data
,
i
,
"content"
)
url
=
__retrieval
(
data
,
i
,
"url"
)
tags
=
__retrieval
(
data
,
i
,
"tags"
)
date
=
__retrieval
(
data
,
i
,
"date"
)
category
=
__retrieval
(
data
,
i
,
"category"
)
__writer
(
i
,
title
,
content
,
url
,
tags
,
date
,
category
)
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