Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
I
inary
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
1
Konular (issue)
1
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
inary
Commits
db25bf75
Kaydet (Commit)
db25bf75
authored
Ara 08, 2005
tarafından
Eray Özkural
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
* fix: forgotten txn stuff
üst
2a1ebc29
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
33 deletions
+42
-33
packagedb.py
pisi/packagedb.py
+2
-2
__init__.py
pisi/search/__init__.py
+6
-6
invertedindex.py
pisi/search/invertedindex.py
+34
-25
No files found.
pisi/packagedb.py
Dosyayı görüntüle @
db25bf75
...
...
@@ -85,10 +85,10 @@ class PackageDB(object):
# index summary and description
for
(
lang
,
doc
)
in
package_info
.
summary
.
iteritems
():
if
lang
in
[
'en'
,
'tr'
]:
pisi
.
search
.
add_doc
(
'summary'
,
lang
,
package_info
.
name
,
doc
)
pisi
.
search
.
add_doc
(
'summary'
,
lang
,
package_info
.
name
,
doc
,
txn
)
for
(
lang
,
doc
)
in
package_info
.
description
.
iteritems
():
if
lang
in
[
'en'
,
'tr'
]:
pisi
.
search
.
add_doc
(
'description'
,
lang
,
package_info
.
name
,
doc
)
pisi
.
search
.
add_doc
(
'description'
,
lang
,
package_info
.
name
,
doc
,
txn
)
self
.
d
.
txn_proc
(
proc
,
txn
)
...
...
pisi/search/__init__.py
Dosyayı görüntüle @
db25bf75
...
...
@@ -47,14 +47,14 @@ def finalize():
ctx
.
invidx
[
id
][
lang
]
.
close
()
ctx
.
invidx
=
{}
def
add_doc
(
id
,
lang
,
docid
,
str
):
def
add_doc
(
id
,
lang
,
docid
,
str
,
txn
=
None
):
terms
=
preprocess
(
lang
,
str
)
ctx
.
invidx
[
id
][
lang
]
.
add_doc
(
docid
,
terms
)
ctx
.
invidx
[
id
][
lang
]
.
add_doc
(
docid
,
terms
,
txn
)
def
remove_doc
(
id
,
lang
,
docid
,
str
):
ctx
.
invidx
[
id
][
lang
]
.
remove_doc
(
docid
)
def
remove_doc
(
id
,
lang
,
docid
,
str
,
txn
=
None
):
ctx
.
invidx
[
id
][
lang
]
.
remove_doc
(
docid
,
txn
)
def
query
(
id
,
lang
,
terms
):
def
query
(
id
,
lang
,
terms
,
txn
=
None
):
import
preprocess
as
p
terms
=
map
(
lambda
x
:
p
.
lower
(
lang
,
x
),
terms
)
return
ctx
.
invidx
[
id
][
lang
]
.
query
(
terms
)
return
ctx
.
invidx
[
id
][
lang
]
.
query
(
terms
,
txn
)
pisi/search/invertedindex.py
Dosyayı görüntüle @
db25bf75
...
...
@@ -15,7 +15,6 @@ import types
import
pisi.lockeddbshelve
as
shelve
class
InvertedIndex
(
object
):
"""a database of term -> set of documents"""
...
...
@@ -25,36 +24,46 @@ class InvertedIndex(object):
def
close
(
self
):
self
.
d
.
close
()
def
has_term
(
self
,
term
):
return
self
.
d
.
has_key
(
shelve
.
LockedDBShelf
.
encodekey
(
term
))
def
has_term
(
self
,
term
,
txn
=
None
):
return
self
.
d
.
has_key
(
shelve
.
LockedDBShelf
.
encodekey
(
term
)
,
txn
)
def
get_term
(
self
,
term
):
def
get_term
(
self
,
term
,
txn
=
None
):
"""get set of doc ids given term"""
term
=
shelve
.
LockedDBShelf
.
encodekey
(
term
)
if
not
self
.
has_term
(
term
):
self
.
d
[
term
]
=
set
()
return
self
.
d
[
term
]
def
proc
(
txn
):
if
not
self
.
has_term
(
term
,
txn
):
self
.
d
.
put
(
term
,
set
(),
txn
)
return
self
.
d
.
get
(
term
,
txn
)
return
self
.
d
.
txn_proc
(
proc
,
txn
)
def
query
(
self
,
terms
):
docs
=
[
self
.
get_term
(
x
)
for
x
in
terms
]
return
reduce
(
lambda
x
,
y
:
x
.
union
(
y
),
docs
)
def
query
(
self
,
terms
,
txn
=
None
):
def
proc
(
txn
):
docs
=
[
self
.
get_term
(
x
,
txn
)
for
x
in
terms
]
return
reduce
(
lambda
x
,
y
:
x
.
union
(
y
),
docs
)
return
self
.
d
.
txn_proc
(
proc
,
txn
)
def
list_terms
(
self
):
def
list_terms
(
self
,
txn
=
None
):
list
=
[]
for
term
in
self
.
d
.
iterkeys
():
list
.
append
(
term
)
return
list
def
f
(
txn
):
for
term
in
self
.
d
.
iterkeys
(
txn
):
list
.
append
(
term
)
return
list
return
self
.
d
.
txn_proc
(
f
,
txn
)
def
add_doc
(
self
,
doc
,
terms
):
for
term_i
in
terms
:
term_i
=
shelve
.
LockedDBShelf
.
encodekey
(
term_i
)
term_i_docs
=
self
.
get_term
(
term_i
)
term_i_docs
.
add
(
doc
)
self
.
d
[
term_i
]
=
term_i_docs
# update
def
add_doc
(
self
,
doc
,
terms
,
txn
=
None
):
def
f
(
txn
):
for
term_i
in
terms
:
term_i
=
shelve
.
LockedDBShelf
.
encodekey
(
term_i
)
term_i_docs
=
self
.
get_term
(
term_i
,
txn
)
term_i_docs
.
add
(
doc
)
self
.
d
.
put
(
term_i
,
term_i_docs
,
txn
)
# update
return
self
.
d
.
txn_proc
(
f
,
txn
)
def
remove_doc
(
self
,
doc
,
terms
):
for
term_i
in
terms
:
term_i
=
shelve
.
LockedDBShelf
.
encodekey
(
term_i
)
term_i_docs
=
self
.
get_term
(
term_i
)
term_i_docs
.
remove
(
doc
)
self
.
d
[
term_i
]
=
term_i_docs
# update
def
f
(
txn
):
for
term_i
in
terms
:
term_i
=
shelve
.
LockedDBShelf
.
encodekey
(
term_i
)
term_i_docs
=
self
.
get_term
(
term_i
)
term_i_docs
.
remove
(
doc
)
self
.
d
.
put
(
term_i
,
term_i_docs
,
txn
)
# update
return
self
.
d
.
txn_proc
(
f
,
txn
)
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