You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/08/30 19:28:48 UTC

[15/19] lucy git commit: Make Lucy::Analysis::Token public

Make Lucy::Analysis::Token public


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/e3d1047f
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/e3d1047f
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/e3d1047f

Branch: refs/heads/master
Commit: e3d1047fd399a2fb79995d37b26bc2817e27719e
Parents: 0e31a39
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Aug 25 12:07:28 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Aug 25 12:45:53 2015 +0200

----------------------------------------------------------------------
 core/Lucy/Analysis/Token.cfh                 | 33 +++++++-----
 perl/buildlib/Lucy/Build/Binding/Analysis.pm | 63 +++++++++++++++++++++++
 2 files changed, 84 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/e3d1047f/core/Lucy/Analysis/Token.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/Token.cfh b/core/Lucy/Analysis/Token.cfh
index b57f185..81e187a 100644
--- a/core/Lucy/Analysis/Token.cfh
+++ b/core/Lucy/Analysis/Token.cfh
@@ -38,8 +38,7 @@ parcel Lucy;
  * `boost` is a per-token weight.  Use this when you want to assign
  * more or less importance to a particular token, as you might for emboldened
  * text within an HTML document, for example.  (Note: The field this token
- * belongs to must be spec'd to use a posting of type
- * [](cfish:RichPosting).)
+ * belongs to must be spec'd to use a posting of type RichPosting.)
  *
  * `pos_inc` is the POSition INCrement, measured in Tokens.  This
  * attribute, which defaults to 1, is a an advanced tool for manipulating
@@ -49,7 +48,7 @@ parcel Lucy;
  * will end up assigned to positions 0, 1, and 1001 -- and will no longer
  * produce a phrase match for the query `"three blind mice"`.
  */
-class Lucy::Analysis::Token inherits Clownfish::Obj {
+public class Lucy::Analysis::Token inherits Clownfish::Obj {
 
     char     *text;
     size_t    len;
@@ -59,11 +58,21 @@ class Lucy::Analysis::Token inherits Clownfish::Obj {
     int32_t   pos_inc;
     int32_t   pos;
 
-    inert incremented Token*
+    public inert incremented Token*
     new(const char *text, size_t len, uint32_t start_offset,
         uint32_t end_offset, float boost = 1.0, int32_t pos_inc = 1);
 
-    inert Token*
+    /**
+     * @param text A UTF-8 string.
+     * @param len Size of the string in bytes.
+     * @param start_offset Start offset into the original document in Unicode
+     * code points.
+     * @param start_offset End offset into the original document in Unicode
+     * code points.
+     * @param boost Per-token weight.
+     * @param pos_inc Position increment for phrase matching.
+     */
+    public inert Token*
     init(Token *self, const char *text, size_t len,
          uint32_t start_offset, uint32_t end_offset,
          float boost = 1.0, int32_t pos_inc = 1);
@@ -73,16 +82,16 @@ class Lucy::Analysis::Token inherits Clownfish::Obj {
     inert int
     compare(const void *va, const void *vb);
 
-    uint32_t
+    public uint32_t
     Get_Start_Offset(Token *self);
 
-    uint32_t
+    public uint32_t
     Get_End_Offset(Token *self);
 
-    float
+    public float
     Get_Boost(Token *self);
 
-    int32_t
+    public int32_t
     Get_Pos_Inc(Token *self);
 
     /** Accessor for pos.  Only valid after position increments for an array
@@ -91,13 +100,13 @@ class Lucy::Analysis::Token inherits Clownfish::Obj {
     int32_t
     Get_Pos(Token *self);
 
-    char*
+    public char*
     Get_Text(Token *self);
 
-    size_t
+    public size_t
     Get_Len(Token *self);
 
-    void
+    public void
     Set_Text(Token *self, char *text, size_t len);
 
     public void

http://git-wip-us.apache.org/repos/asf/lucy/blob/e3d1047f/perl/buildlib/Lucy/Build/Binding/Analysis.pm
----------------------------------------------------------------------
diff --git a/perl/buildlib/Lucy/Build/Binding/Analysis.pm b/perl/buildlib/Lucy/Build/Binding/Analysis.pm
index dad9b11..22f101f 100644
--- a/perl/buildlib/Lucy/Build/Binding/Analysis.pm
+++ b/perl/buildlib/Lucy/Build/Binding/Analysis.pm
@@ -349,6 +349,68 @@ sub bind_token {
         Get_Text
     ); 
 
+    my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
+    my $synopsis = <<'END_SYNOPSIS';
+        my $token = Lucy::Analysis::Token->new(
+            text         => 'blind',
+            start_offset => 8,
+            end_offset   => 13,
+        );
+
+        $token->set_text('mice');
+END_SYNOPSIS
+    my $constructor_pod = <<'END_CONSTRUCTOR_POD';
+=head2 new( I<[labeled params]> )
+
+    my $token = Lucy::Analysis::Token->new(
+        text         => $text,          # required
+        start_offset => $start_offset,  # required
+        end_offset   => $end_offset,    # required
+        boost        => 1.0,            # optional
+        pos_inc      => 1,              # optional
+    );
+
+=over
+
+=item *
+
+B<text> - A string.
+
+=item *
+
+B<start_offset> - Start offset into the original document in Unicode
+code points.
+
+=item *
+
+B<start_offset> - End offset into the original document in Unicode
+code points.
+
+=item *
+
+B<boost> - Per-token weight.
+
+=item *
+
+B<pos_inc> - Position increment for phrase matching.
+
+=back
+END_CONSTRUCTOR_POD
+    my $get_text_pod = <<'END_GET_TEXT_POD';
+=head2 get_text()
+
+Get the token's text.
+END_GET_TEXT_POD
+    my $set_text_pod = <<'END_SET_TEXT_POD';
+=head2 set_text(text)
+
+Set the token's text.
+END_SET_TEXT_POD
+    $pod_spec->set_synopsis($synopsis);
+    $pod_spec->add_constructor( alias => 'new', pod => $constructor_pod );
+    $pod_spec->add_method( alias => 'Get_Text', pod => $get_text_pod);
+    $pod_spec->add_method( alias => 'Set_Text', pod => $set_text_pod);
+
     my $xs = <<'END_XS';
 MODULE = Lucy    PACKAGE = Lucy::Analysis::Token
 
@@ -411,6 +473,7 @@ END_XS
         parcel     => "Lucy",
         class_name => "Lucy::Analysis::Token",
     );
+    $binding->set_pod_spec($pod_spec);
     $binding->append_xs($xs);
     $binding->exclude_method($_) for @hand_rolled;
     $binding->exclude_constructor;