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
02cbb32f
Commit
02cbb32f
authored
Jun 28, 2022
by
Haj Rezvan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete functions
parent
e63793e9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
17 deletions
+15
-17
QP.py
QP.py
+15
-17
No files found.
QP.py
View file @
02cbb32f
...
...
@@ -67,27 +67,27 @@ def __double_quotation(i: int, query: list, dictionary: dict, finish: bool, doc_
while
True
:
# Find end of "
selected
=
list
()
length
=
len
(
query
[
i
+
1
])
if
query
[
i
][
length
-
1
]
==
'"'
:
query
[
i
+
1
]
=
query
[
i
+
1
][
0
:
len
gth
-
1
]
if
query
[
i
+
1
][
len
(
query
[
i
+
1
])
-
1
]
==
'"'
:
query
[
i
+
1
]
=
query
[
i
+
1
][
0
:
len
(
query
[
i
+
1
])
-
1
]
finish
=
True
# Find docID
for
aP
in
range
(
0
,
len
(
dictionary
[
query
[
i
]])):
# document ID
doc
=
list
(
dictionary
[
query
[
i
]]
.
keys
())[
aP
]
# Number of document in dictionary.
if
dictionary
[
query
[
i
+
1
]]
.
keys
()
.
__contains__
(
doc
):
doc
=
list
(
dictionary
[
query
[
i
]]
)
.
__getitem__
(
aP
)
# Number of document in dictionary.
if
dictionary
[
query
[
i
+
1
]]
.
__contains__
(
doc
):
# Array of this word in the query.
presentPointer
=
dictionary
[
query
[
i
]][
doc
]
#
presentPointer = dictionary[query[i]][doc]
# Array of next word in query.
nextPointer
=
list
()
for
bP
in
range
(
0
,
len
(
dictionary
[
query
[
i
+
1
]]
[
doc
]
)):
# Iterate from end to begin.
nextPointer
.
append
(
dictionary
[
query
[
i
+
1
]]
[
doc
]
.
__getitem__
(
bP
)
-
1
)
for
bP
in
range
(
0
,
len
(
dictionary
[
query
[
i
+
1
]])):
# Iterate from end to begin.
nextPointer
.
append
(
dictionary
[
query
[
i
+
1
]]
.
__getitem__
(
bP
)
-
1
)
# Position of documents.
for
p
in
dictionary
[
query
[
i
]][
doc
]
:
if
nextPointer
.
__contains__
(
dictionary
[
query
[
i
]]
[
doc
]
.
__getitem__
(
p
)):
for
p
in
range
(
0
,
len
(
dictionary
[
query
[
i
]]))
:
if
nextPointer
.
__contains__
(
dictionary
[
query
[
i
]]
.
__getitem__
(
p
)):
selected
.
append
(
doc
)
break
# intersect of documents.
...
...
@@ -106,7 +106,7 @@ def __not(i: int, query: list, dictionary: dict, doc_id: list):
query
[
i
]
=
query
[
i
][
1
:
length
]
# length of phrase query.
if
dictionary
.
keys
()
.
__contains__
(
query
[
i
]):
for
term
in
range
(
0
,
file_numbers
):
if
not
dictionary
.
keys
()
.
__contains__
(
query
[
term
]
):
if
not
dictionary
[
query
[
i
]]
.
__contains__
(
term
):
selected
.
append
(
term
)
else
:
# Not in dictionary.
...
...
@@ -148,9 +148,11 @@ def __checker(query: str, dictionary: dict, size: int):
while
i
<
size
:
if
query
[
i
][
0
]
==
'"'
:
content
=
(
__double_quotation
(
i
,
query
,
dictionary
,
finish
,
content
))
lst_ctn
[
i
]
=
content
.
copy
()
elif
query
[
i
][
0
]
==
'!'
:
content
=
(
__not
(
i
,
query
,
dictionary
,
content
))
lst_ctn
[
i
]
=
content
.
copy
()
else
:
content
=
__simple_check
(
i
,
query
,
dictionary
,
content
)
lst_ctn
[
i
]
=
content
.
copy
()
...
...
@@ -175,7 +177,6 @@ def enter(it: str):
split
=
it
.
split
(
" "
)
size
=
len
(
split
)
rs
=
__checker
(
it
,
dictionary
,
size
)
out_list
=
list
()
intersect
=
[
set
()
for
_
in
range
(
size
)]
i
=
0
...
...
@@ -185,13 +186,10 @@ def enter(it: str):
i
=
i
+
1
break
for
ls
in
rs
:
for
item
in
ls
:
out_list
.
append
(
item
)
rs
=
set
.
intersection
(
*
intersect
)
rs
=
list
(
set
.
intersection
(
*
intersect
))
rs
.
sort
()
out_data
=
get_info
(
list
(
rs
)
)
out_data
=
get_info
(
rs
[
0
:
10
]
)
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