Archive for the ‘Tagyu’ Category

Post

TagyuLib – Tagyu .NET Client Library

In Tagyu, Tech/Hacks on March 25, 2006 by Sid

I have finished writing a .NET client library for Tagyu's REST Web-Service. Tagyu is a hosted service that uses human intelligence to suggest tags and categories relevant to a block of text.

TagyuLib (that’s my creative name for the .NET API) supports everything that the REST API of Tagyu allows you to do as of now. So it supports both classification queries and related-tags queries. It also allows you to pass your username/password to Tagyu through HTTP basic authentication scheme. If you're wondering what am I talking about here, you should really be reading Tagyu REST web service documentation first.

I have created a project at GotDotNet CodeGallery to share the source code of TagyuLib and it would be great to see people participate.

I hope some people would find TagyuLib useful and I would love to hear from them. But right now it is 2:15 AM and I need to get some sleep.

Update on March 25, 2006

Here is the class diagram and some sample code to get you started.

Class Diagram

(Click image to enlarge)

Sample Code

Determining tags and category

You need to instantiate a new TagyuService object and simply call its GetClassification method passing-in your text. GetClassification will return you a ClassificationSuggestion object and you can loop through the items in its Tags property to do whatever you want. You can also get the category for your text from the Category property of the ClassificationSuggestion object that you got back.

string inputText = Console.ReadLine();

TagyuService ts = new TagyuService();  

ClassificationSuggestion s = ts.GetClassification(inputText);  

Console.WriteLine("Suggested Tags are: ");  

foreach (Tag tg in s.Tags) {
    Console.WriteLine(tg.Value);
}  

Console.WriteLine("Suggested Category is: {0}", s.Category);

Determing related tagsThat's equally simple. All you need to do is instantiate a new TagyuService object and call its GetRelatedTags method passing in the tag for which you wish to see related tags. GetRelatedTags returns a RelatedSuggestion object and you can loop through the items in its Tags property.

Console.WriteLine("Enter a Tag");

string inputTag = Console.ReadLine();

TagyuService ts = new TagyuService();

RelatedSuggestion r = ts.GetRelatedTags(inputTag);

Console.WriteLine("Related tags are: ");

foreach (Tag tg in r.Tags) {
      Console.WriteLine(tg.Value);
}

Using your Tagyu username and password

As of now, unregistered users can make one request per minute from a single IP address to Tagyu and requests beyond this limit result in an error. So if this bothers you, you should create an account at Tagyu. You can pass your username and password to Tagyu through TagyuLib simply by setting these properties on the TagyuService object before invoking GetClassification and GetRelatedTags methods. Here's how:

string inputText = Console.ReadLine();

TagyuService ts = new TagyuService();
ts.Username = "[YOUR-USERNAME]";
ts.Password = "[YOUR-PASSWORD]";  

ClassificationSuggestion s = ts.GetClassification(inputText);    

Console.WriteLine("Suggested Tags are: ");    

foreach (Tag tg in s.Tags) {
    Console.WriteLine(tg.Value);
}    

Console.WriteLine("Suggested Category is: {0}", s.Category);

Download

This way please!

Requirements

Bugs/Issues/Feedback

I'd love to hear from people who've used TagyuLib. Please share your feedback, issues and any bugs you encounter here.

Contributing

Join the project and get started.

Changelog

  • March 25, 2006
    • Initial version
  • April 02, 2006
    • Merged SuggestedTag and RelatedTag classes into one.
    • Renamed Suggestions to ClassificationSuggestion.
    • Renamed Related to RelatedSuggestion.
    • Added an overload for GetRelatedTags that takes a Tag object as argument.

Post

Tagyu::Search v0.03

In Tagyu, Tech/Hacks on December 9, 2005 by Sid

I have incorporated support for two new features in my Tagyu::Search module and learnt a lot about HTTP in the process.

1. Support for HTTP Basic Authentication

With this in place, it is now possible for Perl code using my module to break the one request per IP barrier imposed on anonymous users by Tagyu. So register yourself at Tagyu right now!

This is what you need to do in your code:

# Instantiate a new Tagyu::Search object.
my $tagyu = Tagyu::Search->new(
 username => "[YOUR-USERNAME]",
 password => "[YOUR-PASSWORD]"
);

# Invoke the SuggesTags method on the Tagyu::Search object.
my @tags = $tagyu->SuggestTags("[YOUR-TEXT]");

However anonymous searches through Tagyu::Search package are still supported.

2. Introduced two new methods SuggestTagsText and SuggestTagsURL.

SuggestTagsText encodes all the special characters like '=', '+', '&', etc. before passing on the text to the Tagyu Web Service, while SuggestTagsURL considers its argument as a URL and uses the Tagyu Web Service to suggest tags for the text at the specified URL.

Download Tagyu-Search-0.03 and let me know how it works for you. As always, feedback is welcome!

Post

Tagyu Perl API version 0.02

In Tagyu, Tech/Hacks on November 22, 2005 by Sid

I have incorporated support in the SuggestTags method of my Tagyu::Search Perl module to allow specifying options to modify its behavior when it contacts Tagyu.com servers. Thanks to Nathan McFarl for his comment.

So download Tagyu::Search v0.02 and do let me know how it works for you!

Post

Tagyu Perl API

In Tagyu, Tech/Hacks on October 19, 2005 by Sid

Introduction

Tagyu is a service that can suggest you tags relevant to your content. They have a REST interface available so I quickly rolled up a simple Perl wrapper over it.

Simple to use

Using Tagyu Web Service from Perl is now very simple and all you need to do is:

use Tagyu::Search;

my @tags = Tagyu::Search->SuggestTags("[PUT YOUR TEXT HERE]");

SuggestTags method returns an array of strings containing the tags received from Tagyu for the specified text using its REST API.

Passing options

You can also specify options to the SuggestTags method of Tagyu::Search module as key-value pairs to modify its behavior when it dispatches requests to the Tagyu.com servers. Here's an example that sets the timeout parameter.

my @tags = Tagyu::Search->SuggestTags("[PUT YOUR TEXT HERE]",
   (timeout => 600)
);

Tagyu::Search uses LWP::UserAgent behind the scenes. So for details of all supported options and their default values, please check the documentation of LWP::UserAgent's constructor.

Supports HTTP Basic Authentication

Tagyu imposes a limit of one request per minute from a single IP address and requests beyond this limit result in an error. However registered users have a soft cap of 1000 requests per day. Tagyu::Search package allows you to pass your username/password to Tagyu in the following manner:

# Instantiate a new Tagyu::Search object.
my $tagyu = Tagyu::Search->new(
 username => "[YOUR-USERNAME]",
 password => "[YOUR-PASSWORD]"
);

# Invoke the SuggestTags method on the Tagyu::Search object.
my @tags = $tagyu->SuggestTags("[YOUR-TEXT]");

You can register at Tagyu here.

Downloads

Need Ideas?

For some ideas on what you can do with Tagyu::Search, have a look here.

Comments and suggestions are welcome

Before posting my module to CPAN I have sent an RFC for my Perl module on comp.lang.perl.modules USENET group. So download the latest relase of Tagyu::Search and give it a try. Please share your feedback! Thanks.