Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
7c39422d
Commit
7c39422d
authored
Jan 02, 2001
by
Christopher Petrilli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merging in changes from petrilli-Catalog_quickfix-branch to fix a bunch
of lingering bugs in things.
parent
a679893c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
126 additions
and
34 deletions
+126
-34
lib/python/SearchIndex/UnIndex.py
lib/python/SearchIndex/UnIndex.py
+5
-8
lib/python/SearchIndex/UnKeywordIndex.py
lib/python/SearchIndex/UnKeywordIndex.py
+108
-10
lib/python/SearchIndex/UnTextIndex.py
lib/python/SearchIndex/UnTextIndex.py
+13
-16
No files found.
lib/python/SearchIndex/UnIndex.py
View file @
7c39422d
...
...
@@ -85,7 +85,7 @@
"""Simple column indices"""
__version__
=
'$Revision: 1.1
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
6
$'
[
11
:
-
2
]
from
Globals
import
Persistent
...
...
@@ -97,9 +97,7 @@ import operator
from
Missing
import
MV
import
string
,
pdb
from
zLOG
import
LOG
,
ERROR
ListType
=
type
([])
StringType
=
type
(
's'
)
from
types
import
*
def
nonEmpty
(
s
):
...
...
@@ -200,9 +198,6 @@ class UnIndex(Persistent, Implicit):
k
=
unindex
.
get
(
i
,
None
)
if
k
is
None
:
LOG
(
'UnIndex'
,
ERROR
,
(
'unindex_object couldn
\
'
t unindex '
'document %s. This should not happen.'
%
str
(
i
)))
return
None
set
=
index
.
get
(
k
,
None
)
if
set
is
not
None
:
...
...
@@ -251,7 +246,9 @@ class UnIndex(Persistent, Implicit):
elif
has_key
(
id
):
keys
=
request
[
id
]
else
:
return
None
if
type
(
keys
)
is
not
ListType
:
keys
=
[
keys
]
if
type
(
keys
)
is
not
ListType
and
not
TupleType
:
keys
=
[
keys
]
index
=
self
.
_index
r
=
None
anyTrue
=
0
...
...
lib/python/SearchIndex/UnKeywordIndex.py
View file @
7c39422d
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
from
UnIndex
import
UnIndex
,
MV
,
intSet
from
types
import
ListType
,
TupleType
from
zLOG
import
LOG
,
ERROR
from
types
import
*
class
UnKeywordIndex
(
UnIndex
):
...
...
@@ -14,7 +99,12 @@ class UnKeywordIndex(UnIndex):
"""
def
index_object
(
self
,
i
,
obj
,
threshold
=
None
):
""" index an object 'obj' with integer id 'i'"""
""" index an object 'obj' with integer id 'i'
Ideally, we've been passed a sequence of some sort that we
can iterate over. If however, we haven't, we should do something
useful with the results. In the case of a string, this means
indexing the entire string as a keyword."""
# Before we do anything, unindex the object we've been handed, as
# we can't depend on the user to do the right thing.
...
...
@@ -30,14 +120,22 @@ class UnKeywordIndex(UnIndex):
if
callable
(
kws
):
kws
=
kws
()
except
:
kws
=
[
MV
]
# index each item in the sequence
for
kw
in
kws
:
set
=
index
.
get
(
kw
)
if
set
is
None
:
index
[
kw
]
=
set
=
intSet
()
set
.
insert
(
i
)
return
0
# Check to see if we've been handed a string and if so, tuplize it
if
type
(
kws
)
is
StringType
:
kws
=
tuple
(
kws
)
# index each item in the sequence. This also catches things that are
# not sequences.
try
:
for
kw
in
kws
:
set
=
index
.
get
(
kw
)
if
set
is
None
:
index
[
kw
]
=
set
=
intSet
()
set
.
insert
(
i
)
except
TypeError
:
return
0
unindex
[
i
]
=
kws
...
...
lib/python/SearchIndex/UnTextIndex.py
View file @
7c39422d
...
...
@@ -92,7 +92,7 @@ is no longer known.
"""
__version__
=
'$Revision: 1.
29
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
30
$'
[
11
:
-
2
]
from
Globals
import
Persistent
...
...
@@ -108,7 +108,7 @@ from Splitter import Splitter
from
string
import
strip
import
string
,
regex
,
regsub
,
ts_regex
from
zLOG
import
LOG
,
ERROR
from
types
import
*
from
Lexicon
import
Lexicon
,
stop_word_dict
from
ResultList
import
ResultList
...
...
@@ -191,7 +191,7 @@ class UnTextIndex(Persistent, Implicit):
Zope. I don't think indexes were ever intended to participate
in this way, but I don't see too much of a problem with it.
"""
if
type
(
vocab_id
)
is
not
type
(
""
)
:
if
type
(
vocab_id
)
is
not
StringType
:
vocab
=
vocab_id
else
:
vocab
=
getattr
(
self
,
vocab_id
)
...
...
@@ -212,8 +212,7 @@ class UnTextIndex(Persistent, Implicit):
self
.
_unindex
=
IOBTree
()
def
index_object
(
self
,
i
,
obj
,
threshold
=
None
,
tupleType
=
type
(()),
dictType
=
type
({}),
strType
=
type
(
""
),
callable
=
callable
):
def
index_object
(
self
,
i
,
obj
,
threshold
=
None
):
""" Index an object:
...
...
@@ -286,14 +285,14 @@ class UnTextIndex(Persistent, Implicit):
r
=
get
(
word_id
)
if
r
is
not
None
:
r
=
index
[
word_id
]
if
type
(
r
)
is
t
upleType
:
if
type
(
r
)
is
T
upleType
:
r
=
{
r
[
0
]:
r
[
1
]}
r
[
i
]
=
score
index
[
word_id
]
=
r
unindex
[
i
].
append
(
word_id
)
elif
type
(
r
)
is
d
ictType
:
elif
type
(
r
)
is
D
ictType
:
if
len
(
r
)
>
4
:
b
=
IIBucket
()
for
k
,
v
in
r
.
items
():
b
[
k
]
=
v
...
...
@@ -320,7 +319,7 @@ class UnTextIndex(Persistent, Implicit):
## return the number of words you indexed
return
times
def
unindex_object
(
self
,
i
,
tt
=
type
(())
):
def
unindex_object
(
self
,
i
):
""" carefully unindex document with integer id 'i' from the text
index and do not fail if it does not exist """
index
=
self
.
_index
...
...
@@ -329,7 +328,7 @@ class UnTextIndex(Persistent, Implicit):
if
val
is
not
None
:
for
n
in
val
:
v
=
index
.
get
(
n
,
None
)
if
type
(
v
)
is
tt
:
if
type
(
v
)
is
TupleType
:
del
index
[
n
]
elif
v
is
not
None
:
try
:
...
...
@@ -364,7 +363,7 @@ class UnTextIndex(Persistent, Implicit):
return
r
def
_apply_index
(
self
,
request
,
cid
=
''
,
ListType
=
[]
):
def
_apply_index
(
self
,
request
,
cid
=
''
):
""" Apply the index to query parameters given in the argument,
request
...
...
@@ -386,7 +385,7 @@ class UnTextIndex(Persistent, Implicit):
else
:
return
None
if
type
(
keys
)
is
type
(
''
)
:
if
type
(
keys
)
is
StringType
:
if
not
keys
or
not
strip
(
keys
):
return
None
keys
=
[
keys
]
...
...
@@ -483,7 +482,7 @@ class UnTextIndex(Persistent, Implicit):
return
self
.
evaluate
(
q
)
def
get_operands
(
self
,
q
,
i
,
ListType
=
type
([]),
StringType
=
type
(
''
)
):
def
get_operands
(
self
,
q
,
i
):
'''Evaluate and return the left and right operands for an operator'''
try
:
left
=
q
[
i
-
1
]
...
...
@@ -501,7 +500,7 @@ class UnTextIndex(Persistent, Implicit):
return
(
left
,
right
)
def
evaluate
(
self
,
q
,
ListType
=
type
([])
):
def
evaluate
(
self
,
q
):
'''Evaluate a parsed query'''
## import pdb
## pdb.set_trace()
...
...
@@ -573,9 +572,7 @@ def parse(s):
return
l
def
parse2
(
q
,
default_operator
,
operator_dict
=
{
AndNot
:
AndNot
,
And
:
And
,
Or
:
Or
,
Near
:
Near
},
ListType
=
type
([]),
):
operator_dict
=
{
AndNot
:
AndNot
,
And
:
And
,
Or
:
Or
,
Near
:
Near
}):
'''Find operators and operands'''
i
=
0
isop
=
operator_dict
.
has_key
...
...
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