These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Using fuzzy logic to identify related questions
PostPosted: Fri Aug 21, 2009 7:53 pm 
Newbie

Joined: Fri Aug 21, 2009 7:48 pm
Posts: 1
I am creating an application where users type in a question, and then I want the database to use a sort of fuzzy logic to examine the words in the question and indentify the most closely matched previously asked questions. Is there any set of open source code that will help me get started with this? Or is there a better way to do this?


Top
 Profile  
 
 Post subject: Re: Using fuzzy logic to identify related questions
PostPosted: Sat Aug 22, 2009 3:33 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
You can do pretty powerful queries and fuzzy logic using the Criteria API and using the 'like' abilities for matching at the beginning, end, or anywhere in a given word or field.

Here's a nice little tutorial on using the Hibernate Criteria API:

http://www.hiberbook.com/HiberBookWeb/learn.jsp?tutorial=09howtousethecriteriaapi


It's not plain english, but this query below using the criteria API to find a User match that has an id greater than (gt) 2, less than (ld) 8, has a notNull email address, and a String match at the end of a field on '.com' It's all highly readable by a Java professional, and can allow you or the end user to really control the types of matches you get.


Code:
Session session = HibernateUtil.beginTransaction();
  Criterion c1 = Restrictions.gt("id", (long)2);
  Criterion c2 = Restrictions.lt("id", (long)8);
  Criterion c3 = Restrictions.isNotNull("emailAddress");
  User user = new User();
  user.setEmailAddress(".com");
  Example c4 = Example.create(user);
  c4.enableLike(MatchMode.END);
  c4.ignoreCase();
  Criteria criteria = session.createCriteria(User.class);
  criteria.add(c1);
  criteria.add(c2);
  criteria.add(c3);
  criteria.add(c4);
  List results = criteria.list();
  HibernateUtil.commitTransaction();
  for (int i = 0; i<results.size(); i++) {
    System.out.println(results.get(i).toString());
  }

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.