You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/08/23 01:14:08 UTC
svn commit: r1376307 - in /lucene/cms/trunk/content/pylucene:
features.mdtext index.mdtext install.mdtext
Author: rmuir
Date: Wed Aug 22 23:14:08 2012
New Revision: 1376307
URL: http://svn.apache.org/viewvc?rev=1376307&view=rev
Log:
formatting part 2
Modified:
lucene/cms/trunk/content/pylucene/features.mdtext
lucene/cms/trunk/content/pylucene/index.mdtext
lucene/cms/trunk/content/pylucene/install.mdtext
Modified: lucene/cms/trunk/content/pylucene/features.mdtext
URL: http://svn.apache.org/viewvc/lucene/cms/trunk/content/pylucene/features.mdtext?rev=1376307&r1=1376306&r2=1376307&view=diff
==============================================================================
--- lucene/cms/trunk/content/pylucene/features.mdtext (original)
+++ lucene/cms/trunk/content/pylucene/features.mdtext Wed Aug 22 23:14:08 2012
@@ -1,6 +1,6 @@
<warning>
Before calling any PyLucene API that requires the Java VM, start it by
-calling _initVM(classpath, ...)_.
+calling <i>initVM(classpath, ...)</i>.
More about this function in <a href="jcc/features.html">here</a>.
</warning>
@@ -78,13 +78,13 @@ available from
Before PyLucene APIs can be used from a thread other than the main
thread that was not created by the Java Runtime, the
-_attachCurrentThread()_ method must be called on the
-_JCCEnv_ object returned by the _initVM()_
-or _getVMEnv()_ functions.
+<i>attachCurrentThread()</i> method must be called on the
+<i>JCCEnv</i> object returned by the <i>initVM()</i>
+or <i>getVMEnv()</i> functions.
-#Exception handling with lucene.JavaError
+##Exception handling with lucene.JavaError
Java exceptions are caught at the language barrier and reported to
Python by raising a JavaError instance whose args tuple contains the
@@ -94,7 +94,7 @@ actual Java Exception instance.
##Handling Java arrays
-Java arrays are returned to Python in a _JArray_
+Java arrays are returned to Python in a <i>JArray</i>
wrapper instance that implements the Python sequence protocol. It
is possible to change array elements but not to change the array
size.
@@ -107,25 +107,25 @@ first.<br/>
For example, accessing termDocs:
<code>
-termDocs = reader.termDocs(Term("isbn", isbn))
-docs = JArray('int')(1) # allocate an int[1] array
-freq = JArray('int')(1) # allocate an int[1] array
-if termDocs.read(docs, freq) == 1:
- bits.set(docs[0]) # access the array's first element
+termDocs = reader.termDocs(Term("isbn", isbn))<br/>
+docs = JArray('int')(1) # allocate an int[1] array<br/>
+freq = JArray('int')(1) # allocate an int[1] array<br/>
+if termDocs.read(docs, freq) == 1:<br/>
+ bits.set(docs[0]) # access the array's first element<br/>
</code>
-In addition to _int_, the _JArray_
-function accepts _object_, _string_,
-_bool_, _byte_, _char_,
-_double_, _float_, _long_
-and _short_ to create an array of the corresponding
-type. The _JArray('object')_ constructor takes a second
+In addition to <i>int</i>, the <i>JArray</i>
+function accepts <i>object</i>, <i>string</i>,
+<i>bool</i>, <i>byte</i>, <i>char</i>,
+<i>double</i>, <i>float</i>, <i>long</i>
+and <i>short</i> to create an array of the corresponding
+type. The <i>JArray('object')</i> constructor takes a second
argument denoting the class of the object elements. This argument
is optional and defaults to Object.
To convert a char array to a Python string use a
-_''.join(array)_ construct.
+<i>''.join(array)</i> construct.
Instead of an integer denoting the size of the desired Java array,
@@ -134,8 +134,8 @@ in to the array constructor.<br/>
For example:
<code>
-# creating a Java array of double from the [1.5, 2.5] list
-JArray('double')([1.5, 2.5])
+\# creating a Java array of double from the [1.5, 2.5] list<br/>
+JArray('double')([1.5, 2.5])<br/>
</code>
All methods that expect an array also accept a sequence of Python
@@ -182,37 +182,37 @@ iteration, the zero-based number of the
instance and the document instance itself.<br/>
The Java loop:
<code>
- for (int i = 0; i < hits.length(); i++) {
- Document doc = hits.doc(i);
- System.out.println(hits.score(i) + " : " + doc.get("title"));
- }
+ for (int i = 0; i < hits.length(); i++) {<br/>
+ Document doc = hits.doc(i);<br/>
+ System.out.println(hits.score(i) + " : " + doc.get("title"));<br/>
+ }<br/>
</code>
can be written in Python:
<code>
- for hit in hits:
- hit = Hit.cast_(hit)
- print hit.getScore(), ':', hit.getDocument['title']
+ for hit in hits:<br/>
+ hit = Hit.cast_(hit)<br/>
+ print hit.getScore(), ':', hit.getDocument['title']<br/>
</code>
if hit.iterator()'s next() method were declared to return
-_Hit_ instead of _Object_, the above
+<i>Hit</i> instead of <i>Object</i>, the above
cast_() call would not be unnecessary.<br/>
The same java loop can also be written:
<code>
- for i xrange(len(hits)):
- print hits.score(i), ':', hits[i]['title']
+ for i xrange(len(hits)):<br/>
+ print hits.score(i), ':', hits[i]['title']<br/>
</code>
- Hits instances partially implement the Python 'sequence'
protocol.<br/>
The Java expressions:
<code>
- hits.length()
- doc = hits.get(i)
+ hits.length();<br/>
+ doc = hits.get(i);<br/>
</code>
are better written in Python:
<code>
- len(hits)
- doc = hits[i]
+ len(hits)<br/>
+ doc = hits[i]<br/>
</code>
- Document instances have fields whose values can be accessed
@@ -229,17 +229,17 @@ is better written in Python:
- Document instances can be iterated over for their fields.<br/>
The Java loop:
<code>
- Enumeration fields = doc.getFields();
- while (fields.hasMoreElements()) {
- Field field = (Field) fields.nextElement();
- ...
- }
+ Enumeration fields = doc.getFields();<br/>
+ while (fields.hasMoreElements()) {<br/>
+ Field field = (Field) fields.nextElement();<br/>
+ ...<br/>
+ }<br/>
</code>
is better written in Python:
<code>
- for field in doc.getFields():
- field = Field.cast_(field)
- ...
+ for field in doc.getFields():<br/>
+ field = Field.cast_(field)<br/>
+ ...<br/>
</code>
Once JCC heeds Java 1.5 type parameters and once Java Lucene
makes use of them, such casting should become unncessary.
Modified: lucene/cms/trunk/content/pylucene/index.mdtext
URL: http://svn.apache.org/viewvc/lucene/cms/trunk/content/pylucene/index.mdtext?rev=1376307&r1=1376306&r2=1376307&view=diff
==============================================================================
--- lucene/cms/trunk/content/pylucene/index.mdtext (original)
+++ lucene/cms/trunk/content/pylucene/index.mdtext Wed Aug 22 23:14:08 2012
@@ -13,7 +13,7 @@ version of Java Lucene, version 3.6 as o
PyLucene is not a Lucene port but a Python wrapper around
Java Lucene. PyLucene embeds a Java VM with Lucene into a Python
process. The PyLucene Python extension, a Python module called
-**lucene** is machine-generated by JCC.
+<b>lucene</b> is machine-generated by JCC.
PyLucene is built with [JCC](jcc/index.html), a C++
Modified: lucene/cms/trunk/content/pylucene/install.mdtext
URL: http://svn.apache.org/viewvc/lucene/cms/trunk/content/pylucene/install.mdtext?rev=1376307&r1=1376306&r2=1376307&view=diff
==============================================================================
--- lucene/cms/trunk/content/pylucene/install.mdtext (original)
+++ lucene/cms/trunk/content/pylucene/install.mdtext Wed Aug 22 23:14:08 2012
@@ -22,15 +22,15 @@ instructions</a> for more information.
##For the Impatient Ones
-- _pushd jcc_
-- <edit _setup.py_ to match your environment>
-- _python setup.py build_
-- _sudo python setup.py install_
-- _popd_
-- <edit _Makefile_ to match your environment>
-- _make_
-- _sudo make install_
-- _make test_ (look for failures)
+- <b>pushd jcc</b>
+- <i><edit _setup.py_ to match your environment></i>
+- <b>python setup.py build</b>
+- <b>sudo python setup.py install</b>
+- <b>popd</b>
+- <i><edit _Makefile_ to match your environment></i>
+- <b>make</b>
+- <b>sudo make install</b>
+- <b>make test</b> (look for failures)
##For the Rest of Us
@@ -41,8 +41,8 @@ JCC's <a href="jcc/install.html">install
instructions</a> for building and installing it.
Once JCC is built and installed, PyLucene is built
-via _make_ which invokes JCC. See PyLucene's
-_Makefile_ for configuration instructions.
+via <i>make</i> which invokes JCC. See PyLucene's
+<i>Makefile</i> for configuration instructions.
There are limits to both how many files can fit on the command
line and how large a C++ file the C++ compiler can handle.
@@ -66,13 +66,13 @@ tuned to workaround various limits, for
##Notes for Solaris
PyLucene's Makefile is a GNU Makefile. Be sure to
-use _gmake_ instead of plain _make_.
+use <i>gmake</i> instead of plain <i>make</i>.
Just as when building JCC, Python's distutils must be nudged a bit to
invoke the correct compiler. Sun Studio's C compiler is
-called _cc_ while its C++ compiler is
-called _CC_.<br/>
+called <i>cc</i> while its C++ compiler is
+called <i>CC</i>.<br/>
To build PyLucene, use the following shell command to ensure that