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
d3bb5264
Commit
d3bb5264
authored
May 15, 2022
by
Haj Rezvan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Subtract operator and write logs in other thread.
parent
0580e7f7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
QP.py
QP.py
+21
-6
No files found.
QP.py
View file @
d3bb5264
import
json
import
threading
def
subtract
(
a
,
b
):
return
[
*
(
item
for
item
in
a
if
item
not
in
b
)]
def
union_two
(
a
,
b
):
...
...
@@ -39,7 +44,6 @@ def normalize_list(lst):
def
union
(
inp
):
n
=
len
(
inp
)
vl
=
None
vl
=
normalize_list
(
inp
)
while
n
>=
2
:
if
n
==
2
:
...
...
@@ -93,12 +97,13 @@ def get_info(inp):
def
write_logs
(
string
):
file
=
open
(
f
"./logs/log.txt"
,
"a"
,
encoding
=
"utf-8"
)
file
.
write
(
string
)
file
.
write
(
string
+
"
\n
"
)
file
.
close
()
def
enter
(
it
):
write_logs
(
it
)
t1
=
threading
.
Thread
(
target
=
write_logs
,
args
=
(
it
,))
t1
.
start
()
spl
=
list
(
it
.
split
(
" "
))
file
=
open
(
"./index/ii.json"
,
"r"
,
encoding
=
"utf-8"
)
index
=
json
.
load
(
file
)
...
...
@@ -111,22 +116,32 @@ def enter(it):
ld
=
dict
()
for
i
in
range
(
len
(
rs
)):
ld
[
rs
[
i
]]
=
index
.
get
(
rs
[
i
])
print
(
ld
[
rs
[
i
]])
ld_copy
=
ld
.
copy
()
opt
=
list
()
if
len
(
rs
)
>
1
:
flag
=
operations
(
spl
)
while
len
(
flag
)
>
0
:
if
"&"
in
flag
:
_and
=
spl
.
index
(
"AND"
)
opt
.
append
(
intersect
(
ld
[
spl
[
_and
+
1
]],
ld
[
spl
[
_and
-
1
]]))
nxt_word
=
spl
[
_and
+
1
]
prv_word
=
spl
[
_and
-
1
]
opt
.
extend
(
intersect
(
ld
[
nxt_word
],
ld
[
prv_word
]))
spl
.
pop
(
_and
)
ld
.
pop
(
nxt_word
)
ld
.
pop
(
prv_word
)
ld
[
"opt"
]
=
opt
flag
=
operations
(
spl
)
elif
"!"
in
flag
:
_not
=
spl
.
index
(
"NOT"
)
nxt_word
=
spl
[
_not
+
1
]
prv_word
=
spl
[
_not
-
1
]
opt
=
subtract
(
ld
[
prv_word
],
ld
[
nxt_word
])
print
(
opt
)
spl
.
pop
(
_not
)
flag
=
operations
(
spl
)
pass
out_data
=
get_info
(
ld
)
t1
.
join
()
return
out_data
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