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
169047b5
Commit
169047b5
authored
Jun 06, 2002
by
Casey Duncan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished lexicon query screen.
Completed Zope integration.
parent
7473eda8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
lib/python/Products/ZCTextIndex/ZCTextIndex.py
lib/python/Products/ZCTextIndex/ZCTextIndex.py
+22
-2
lib/python/Products/ZCTextIndex/dtml/queryLexicon.dtml
lib/python/Products/ZCTextIndex/dtml/queryLexicon.dtml
+1
-1
No files found.
lib/python/Products/ZCTextIndex/ZCTextIndex.py
View file @
169047b5
...
...
@@ -37,6 +37,9 @@ from Products.ZCTextIndex.CosineIndex import CosineIndex
from
Products.ZCTextIndex.OkapiIndex
import
OkapiIndex
index_types
=
{
'Okapi BM25 Rank'
:
OkapiIndex
,
'Cosine Measure'
:
CosineIndex
}
IndexMgmtPerm
=
'Manage ZCatalogIndex Entries'
IndexSearchPerm
=
'Search ZCatalogIndex'
class
ZCTextIndex
(
Persistent
,
Acquisition
.
Implicit
,
SimpleItem
):
"""Persistent TextIndex"""
...
...
@@ -52,6 +55,9 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
)
query_options
=
[
'query'
]
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
IndexMgmtPerm
)
## Constructor ##
...
...
@@ -82,6 +88,8 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
## External methods not in the Pluggable Index API ##
security
.
declareProtected
(
'query'
,
IndexSearchPerm
)
def
query
(
self
,
query
,
nbest
=
10
):
"""Return pair (mapping from docids to scores, num results).
...
...
@@ -195,6 +203,11 @@ def manage_addLexicon(self, id, title='', elements=[], REQUEST=None):
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
,
update_menu
=
1
)
# I am borrowing the existing vocabulary permissions for now to avoid
# adding new permissions. This may change when old style Vocabs go away
LexiconQueryPerm
=
'Query Vocabulary'
LexiconMgmtPerm
=
'Manage Vocabulary'
class
PLexicon
(
Lexicon
,
Acquisition
.
Implicit
,
SimpleItem
):
"""Lexicon for ZCTextIndex"""
...
...
@@ -203,6 +216,9 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
manage_options
=
({
'label'
:
'Overview'
,
'action'
:
'manage_main'
},
{
'label'
:
'Query'
,
'action'
:
'queryLexicon'
},
)
+
SimpleItem
.
manage_options
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
LexiconQueryPerm
)
def
__init__
(
self
,
id
,
title
=
''
,
*
pipeline
):
self
.
id
=
str
(
id
)
...
...
@@ -217,6 +233,8 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
_queryLexicon
=
DTMLFile
(
'dtml/queryLexicon'
,
globals
())
security
.
declareProtected
(
LexiconQueryPerm
,
'queryLexicon'
)
def
queryLexicon
(
self
,
REQUEST
,
words
=
None
,
page
=
0
,
rows
=
20
,
cols
=
4
):
"""Lexicon browser/query user interface
"""
...
...
@@ -229,7 +247,7 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
words
=
self
.
words
()
word_count
=
len
(
words
)
rows
=
max
(
min
(
rows
,
500
),
1
)
rows
=
max
(
min
(
rows
,
500
),
1
)
cols
=
max
(
min
(
cols
,
12
),
1
)
page_count
=
word_count
/
(
rows
*
cols
)
+
\
(
word_count
%
(
rows
*
cols
)
>
0
)
...
...
@@ -256,8 +274,10 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
end_word
=
end
,
word_count
=
word_count
,
page_count
=
page_count
,
page_range
=
xrange
(
page_count
),
page_columns
=
columns
)
security
.
declareProtected
(
LexiconMgmtPerm
,
'manage_main'
)
manage_main
=
DTMLFile
(
'dtml/manageLexicon'
,
globals
())
InitializeClass
(
PLexicon
)
lib/python/Products/ZCTextIndex/dtml/queryLexicon.dtml
View file @
169047b5
...
...
@@ -34,7 +34,7 @@
<td align="right"><span class="form-label">
Page:
<select name="page:int" onchange="this.form.submit()">
<dtml-in
expr="_.range(page_count)
" prefix="page">
<dtml-in
name="page_range
" prefix="page">
<option value="&dtml-page_item;"
<dtml-if expr="page == page_item">
selected
...
...
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