cigoic opened a new issue, #642:
URL: https://github.com/apache/lucenenet/issues/642

   Hi,
   
   I am going through the Lucene 4 Cookbook's example. Not sure how to revise 
the Java version's codes to C# as shown below. 
   
   original code : Line 55, 56
   revised code: Line 57, 58
   
   ![ζˆͺεœ– 2022-07-17 δΈ‹εˆ4 15 
18](https://user-images.githubusercontent.com/2939228/179390479-d94915e7-cec7-4af3-9a59-434b219012a9.jpg)
   
   Any suggestion? Thanks.
   
   ```csharp
   StringReader reader = new StringReader("Lucene is mainly used for 
information retrieval and you can read more about it at lucene.apache.org.");
   StandardAnalyzer wa = new StandardAnalyzer(luceneVersion);
   TokenStream ts = null;
   
   try
   {
       ts = wa.GetTokenStream("field", reader);
       OffsetAttribute offsetAtt = ts.addAttribute(OffsetAttribute.class);
       CharTermAttribute termAtt = ts.addAttribute(CharTermAttribute.class);
       //var offsetAtt = ts.AddAttributeImpl(typeof(OffsetAttribute)) as 
OffsetAttribute;
       //CharTermAttribute termAtt = ts.AddAttribute<CharTermAttribute>();
       ts.Reset();
   
       while (ts.IncrementToken())
       {
           String token = termAtt.ToString();
           Console.WriteLine("[" + token + "]");
           Console.WriteLine("Token starting offset: " + offsetAtt.StartOffset);
           Console.WriteLine(" Token ending offset: " + offsetAtt.EndOffset);
           Console.WriteLine();
       }
       ts.End();
   }
   ```
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to