/[sdx]/demos/quran/search.xsp
ViewVC logotype

Contents of /demos/quran/search.xsp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Sun Oct 12 08:40:43 2003 UTC (20 years, 7 months ago) by brihaye
Branch: MAIN
Changes since 1.4: +8 -6 lines
Repackaged arabic analyzer

1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!--
3 Copyright (C) 2003, Pierrick Brihaye
4 pierrick.brihaye@wanadoo.fr
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the
18 Free Software Foundation, Inc.
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 or connect to:
21 http://www.fsf.org/copyleft/gpl.html
22 -->
23 <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:sdx="http://www.culture.gouv.fr/ns/sdx/sdx">
24 <xsp:structure>
25 <xsp:include>gpl.pierrick.brihaye.aramorph.AraMorph</xsp:include>
26 <xsp:include>fr.gouv.culture.sdx.documentbase.LuceneDocumentBase</xsp:include>
27 <xsp:include>fr.gouv.culture.sdx.search.lucene.analysis.Analyzer</xsp:include>
28 <xsp:include>fr.gouv.culture.sdx.search.lucene.analysis.Analyzer_en</xsp:include>
29 <xsp:include>fr.gouv.culture.sdx.utils.lucene.LuceneTools</xsp:include>
30 </xsp:structure>
31 <sdx:page>
32 <menu/>
33 <xsp:logic>
34 AraMorph araMorph = new AraMorph();
35 String queryType = request.getParameter("type");
36 String queryText = request.getParameter("query");
37 if ("arabic".equals(queryType) &amp;&amp; queryText != null &amp;&amp; !"".equals(queryText)) {
38 //arabize a query in the Buckwalter transliteration
39 //TODO : field names are arabized as well :-(
40 queryText = araMorph.arabizeWord(queryText);
41 <viewresults>
42 <sdx:executeSimpleQuery base="ar" hilite="true" queryString="queryText" docs="true"/>
43 <xsp:logic>
44 Hashtable terms = new Hashtable();
45 LuceneTools.getTerms(sdx_query.getLuceneQuery(), terms, true);
46 Iterator it = terms.values().iterator();
47 while (it.hasNext()) {
48 <stem>
49 <xsp:logic>
50 String stem = (String)it.next();
51 stem = araMorph.arabizeWord(stem);
52 Boolean hasSolutions = new Boolean(araMorph.analyzeToken(stem));
53 <xsp:attribute name="hasSolutions">
54 <xsp:expr>hasSolutions.toString()</xsp:expr>
55 </xsp:attribute>
56 </xsp:logic>
57 <xsp:content>
58 <xsp:expr>stem</xsp:expr>
59 </xsp:content>
60 </stem>
61 }
62 </xsp:logic>
63 </viewresults>
64 }
65 if ("english".equals(queryType) &amp;&amp; queryText != null &amp;&amp; !"".equals(queryText)) {
66 <!-- let's change the Analyzer for english DB : it is different from the one used when indexing -->
67 LuceneDocumentBase db = (LuceneDocumentBase)sdx_application.getDocumentBase("en");
68 LuceneIndex index = (LuceneIndex)db.getIndex();
69 Hashtable terms;
70 Iterator it;
71 fr.gouv.culture.sdx.search.lucene.Field df = index.getDefaultField();
72 Analyzer oldAnalyzer = df.getAnalyzer();
73 Analyzer_en analyzer = new Analyzer_en();
74 df.setAnalyzer((Analyzer)analyzer);
75 <sdx:executeSimpleQuery base="en" queryString="queryText" hilite="true"/>
76 //terms = new Hashtable();
77 //LuceneTools.getTerms(sdx_query.getLuceneQuery(), terms, true);
78 //it = terms.values().iterator();
79 //while (it.hasNext()) {
80 <!-- <token><xsp:expr>(String)it.next()</xsp:expr></token> -->
81 //}
82 //Get the query id
83 String qid = sdx_qid;
84 //Restore old analyzer
85 df.setAnalyzer(oldAnalyzer);
86 <viewresults>
87 <xsp:logic>
88 <sdx:executeSimpleQuery base="en" hilite="true" qidString="qid" docs="true"/>
89 terms = new Hashtable();
90 LuceneTools.getTerms(sdx_query.getLuceneQuery(), terms, true);
91 it = terms.values().iterator();
92 while (it.hasNext()) {
93 <token>
94 <xsp:expr>(String)it.next()</xsp:expr>
95 </token>
96 }
97 </xsp:logic>
98 </viewresults>
99 }
100 </xsp:logic>
101 </sdx:page>
102 </xsp:page>

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26