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:34:20 UTC
svn commit: r1376317 - /lucene/cms/trunk/content/pylucene/features.mdtext
Author: rmuir
Date: Wed Aug 22 23:34:19 2012
New Revision: 1376317
URL: http://svn.apache.org/viewvc?rev=1376317&view=rev
Log:
fix this whitespace this way. if this doesnt work, evil unicode characters are coming next
Modified:
lucene/cms/trunk/content/pylucene/features.mdtext
Modified: lucene/cms/trunk/content/pylucene/features.mdtext
URL: http://svn.apache.org/viewvc/lucene/cms/trunk/content/pylucene/features.mdtext?rev=1376317&r1=1376316&r2=1376317&view=diff
==============================================================================
--- lucene/cms/trunk/content/pylucene/features.mdtext (original)
+++ lucene/cms/trunk/content/pylucene/features.mdtext Wed Aug 22 23:34:19 2012
@@ -107,11 +107,11 @@ 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 <i>int</i>, the <i>JArray</i>
@@ -182,64 +182,64 @@ 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++) {<br/>
- Document doc = hits.doc(i);<br/>
- System.out.println(hits.score(i) + " : " + doc.get("title"));<br/>
- }<br/>
+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:<br/>
- hit = Hit.cast_(hit)<br/>
- print hit.getScore(), ':', hit.getDocument['title']<br/>
- </code>
+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
<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)):<br/>
- print hits.score(i), ':', hits[i]['title']<br/>
+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();<br/>
- doc = hits.get(i);<br/>
+hits.length();<br/>
+doc = hits.get(i);<br/>
</code>
are better written in Python:
<code>
- len(hits)<br/>
- doc = hits[i]<br/>
+len(hits)<br/>
+doc = hits[i]<br/>
</code>
- Document instances have fields whose values can be accessed
through the mapping protocol.<br/>
The Java expression:
<code>
- doc.get("title")
+doc.get("title")
</code>
is better written in Python:
<code>
- doc['title']
+doc['title']
</code>
- Document instances can be iterated over for their fields.<br/>
The Java loop:
<code>
- Enumeration fields = doc.getFields();<br/>
- while (fields.hasMoreElements()) {<br/>
- Field field = (Field) fields.nextElement();<br/>
- ...<br/>
- }<br/>
+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():<br/>
- field = Field.cast_(field)<br/>
- ...<br/>
+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.