Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
How-to Guide
SAP NetWeaver ‘04
How To… enable semantic search/search for synonyms in TREX Version 1.00 – May 2005
Applicable Releases:
SAP NetWeaver ’04
© Copyright 2004 SAP AG. All rights reserved.
No part of this publication may be reproduced or
transmitted in any form or for any purpose without the
express permission of SAP AG. The information
contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its
distributors contain proprietary software components of
other software vendors.
Microsoft, Windows, Outlook, and PowerPoint
are
registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, OS/2, Parallel
Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400,
iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent
Miner, WebSphere, Netfinity, Tivoli, and Informix are
trademarks or registered trademarks of IBM Corporation
in the United States and/or other countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered
trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame,
WinFrame, VideoFrame, and MultiWin are trademarks
or registered trademarks of Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or
registered trademarks of W3C®, World Wide Web
Consortium, Massachusetts Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems,
Inc., used under license for technology invented and
implemented by Netscape.
MaxDB is a trademark of MySQL AB, Sweden.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, and other
SAP products and services mentioned herein as well as
their respective logos are trademarks or registered
trademarks of SAP AG in Germany and in several other
countries all over the world. All other product and
service names mentioned are the trademarks of their
respective companies. Data
contained in this document serves informational
purposes only. National product specifications may vary.
These materials are subject to change without notice.
These materials are provided by SAP AG and its affiliated
companies ("SAP Group") for informational purposes
only, without representation or warranty of any
kind, and SAP Group shall not be liable for errors or
omissions with respect to the materials. The only
warranties for SAP Group products and services are those
that are set forth in the express warranty statements
accompanying such products and services, if any.
Nothing herein should be construed as constituting an
additional warranty.
These materials are provided “as is” without a warranty
of any kind, either express or implied, including but not
limited to, the implied warranties of merchantability,
fitness for a particular purpose, or non-infringement.
SAP shall not be liable for damages of any kind including
without limitation direct, special, indirect, or
consequential damages that may result from the use of
these materials.
SAP does not warrant the accuracy or completeness of
the information, text, graphics, links or other items
contained within these materials. SAP has no control
over the information that you may access through the
use of hot links contained in these materials and does not
endorse your use of third party web pages nor provide
any warranty whatsoever relating to third party web
pages.
SAP NetWeaver “How-to” Guides are intended to
simplify the product implementation. While specific
product features and procedures typically are explained
in a practical business context, it is not implied that those
features and procedures are the only approach in solving
a specific business problem using SAP NetWeaver. Should
you wish to receive additional information, clarification
or support, please refer to SAP Consulting.
Any software coding and/or code lines / strings (“Code”)
included in this documentation are only examples and
are not intended to be used in a productive system
environment. The Code is only intended better explain
and visualize the syntax and phrasing rules of certain
coding. SAP does not warrant the correctness and
completeness of the Code given herein, and SAP shall
not be liable for errors or damages caused by the usage of
the Code, except if such damages were caused by SAP
intentionally or grossly negligent.
- 1 -
1111 ScenarioScenarioScenarioScenario
Many customers would like to have a semantic search that allows to search not only for a term itself but also for
synonyms. For example, if you search for ‘aspirin’, you would like to obtain a search result that also contains all
documents dealing with ‘acetylsalicylic acid’.
This behavior can be configured in TREX, and your search result in KMC can be enriched by the synonym search.
This guide describes this configuration in TREX.
Please note: There is no KMC iView that supports this scenario additionally with dedicated navigation. This means
that you cannot choose from KMC which synonyms should be taken into account.
2222 IntroductionIntroductionIntroductionIntroduction
The additional functionality of using synonyms as search terms in TREX is realized using topic maps. These topic
maps are generated by an administrator and cannot be changed dynamically. Instead they have to be generated
again each time you change them. TREX provides a python script to achieve this. Topic maps can be used within a
specific index or for a TREX installation in general. TREX provides this function in a python extension that has to be
activated and configured.
- 2 -
3333 The StepThe StepThe StepThe Step----ByByByBy----Step Solution Step Solution Step Solution Step Solution
The following procedure contains 2 main steps:
• Creating a topic map
• Making the Python extension provided by TREX use it
Prerequisite: You have installed TREX with python support (ActivePython is part of the standard installation)
3.13.13.13.1 Create Create Create Create a ta ta ta topicopicopicopic m m m mapapapap
1. Create a directory for your scenario.
<TREX_DIR>\topicmaps\example\
2. In the directory
<TREX_DIR>\topicmaps\example\ ,create the
file example.txt. The content is a list of
synonyms separated by semicolons.
- 3 -
3. Create a topic map file from example.txt. This
step is necessary each time you change
example.txt.
Go to the directory <TREX_DIR>and open a
command prompt. Always execute
TREXSettings first to set the environment
variables dynamically.
Enter the following command:
\extensions\xtm\txt2xtm.py --input=
<TREX_DIR>\topicmaps\example\example.txt
--
output=<TREX_DIR>\topicmaps\example\exa
mple.xtm
This creates the file example.xtm in your
directory.
Now create example.db from this file, using the
following command:
<TREX_DIR>\extensions\xtm\xtm2db.py
<TREX_DIR>\topicmaps\example\example.xt
m
<TREX_DIR>\topicmaps\example\example.db
- 4 -
4. Create the file topicmap.ini in your directory.
Create the following content in the file:
[topicmap_general]
tmcfile=example.db
stripZeroweight=1
AssocDefaultweight=1.0
RoleDefaultweight=1.0
# associations for semantic search: default is
synonyms
[semanticsearch_assocs]
at-synset=1
# association synonym with role synonym
[semanticsearch_at-synset]
rt-synonym=1
5. Modify the file
<TREX_DIR>\TREXTopicmaps.ini by entering
the new topic map:
[topicmap_example]
Directory = topicmap/example
6. Activate the TREX extensions: Edit the file
<TREX_DIR>\\TREXExtensions.ini. Go to the
section [extensionhandlers] and uncomment
trexxpy.
- 5 -
7. Modify <TREX_DIR>\extensions.py by
changing the following sections:
• Topic Map extension
• Semantic Search
Changes you have to carry out are marked in
bold in the screenshots:
8. Restart TREX Indexserver
If you have started TREX as a Windows service,
restart the service. You can also start and stop
TREX servers individually. See the
documentation at http://help.sap.com
Knowledge Management – Administration
Guide – Technical Operation in Detail –
Starting and Stopping TREX.
- 6 -
3.23.23.23.2 Test your semantic search exampleTest your semantic search exampleTest your semantic search exampleTest your semantic search example This test scenario is based on python scripts. If you would like to test using KMC, it will also work. The steps are
listed in a generic way, followed by a description of the python scripts you might use.
1. Create documents containing in the body or
title the terms that you have used in your topic
map.
Store them in a directory on your TREX server,
for example,
test_semantic_search
2. Create an index.
Open a command prompt in <TREX_DIR>
and use the python script createIndex.py
<index>:
CreateIndex.py semantic_test
3. Index the documents you have prepared for
testing.
Remain in <TREX_DIR> and use
indexDirectory.py –directory=<directory>
<index>:
IndexDirectory.py --
directory=C:\usr\sap\trex_03\test_semantic_sea
rch semantic_test
- 7 -
4. Search for a term that you have used in your
topic map.
Use search.py –query=<searchterm> <index>
Search.py –query=cocktail semantic_test
The search results also contain documents
containing appetizer, since it was given as a
synonym in example.db
If problems occur, check
<TREX_DIR>\trace\PythonExtensions.log.
- 8 -
4444 AppendixAppendixAppendixAppendix
If you want to activate the semantic search only for a certain index, copy it to the index directory
<TREX_DIR>\index\semantic_test
www.sdn.sap.com/irj/sdn/howtoguides