life is a rum go guv’nor, and that’s the truth

Solving aggregation problems

In Folksemantic, we run into the following problems:

  • Duplicate entries. Search and recommendation results that list multiple entries for the same resource.
  • Catalog pages. Search and recommendation results that link to catalog pages for resources (people would rather go directly to the resource, but the metadata providers want people to go to their catalog entry for the resource).
  • Dead links. Results that link to resources that no longer exist.
  • Urls without metadata. When someone shares a resource or inserts the recommender widget in a page for which we don’t have metadata, we need to be able to generate metadata.

Duplicate entries show up because:

  • Two feeds specify entries with the same permalink.
  • The same feed gets added twice (maybe different formats for the same feed, eg. RSS, Atom)
  • Multiple catalogs provide metadata for the same resource.

Dealing With Duplicate Feeds

Problem: In folksemantic a user can enter the url of their blog and we will detect the feeds from the page and add them. We use the feeds to generate personal recommendations. The problem is, a blog typically has 3 or more feeds all of which contain the same content, just provided in different formats (e.g. RSS, Atom etc). So we really don’t want all of the feeds to be generated.

Solution 1: One approach to solving this is to try to detect the duplicate feed the first time we harvest it, don’t add its entries to the index, and then flag the feed as “duplicate” so that we don’t harvest it again. Store in the feed the id of the feed it duplicates. One potential problem with this is that if someone registers a feed that has just the entries tagged a certain way (e.g. all of the entries tagged apple on the gizmodo feed), then if the main feed is already registered, all of the entries on the filtered feeds duplicate the entries in the main feed, so the entries are duplicate, but the feed is not. If we want to use the feed as a basis for making recommendations to the user, we don’t want to use the main feed.

Solution 2: Another approach to the problem is to just add the feed, and harvest it, but then flag the entries as duplicates. Our thought about doing this is to store in each entry a list all of the feeds that the entry belongs to. We need to verify that this won’t slow down our Lucene queries.

It seems that Solution 2 may be best and make it up to the app to avoid adding duplicate feeds (like the 4 feeds for the same blog that Folksemantic does).

Dealing with Catalog Entries

A number of NSDL and other projects such as OER Commons  have created large catalogs of online resources. Sometimes their metadata is harvested directly from the resource websites. Sometimes they enhance that metadata with new information. Sometimes they create metadata for resources that don’t provide their own metadata. The catalog websites often provide services such as rating, discussion, and other valuable services and so they want people to come to their websites and use them. While, these services are nice, when people are searching for resources, they likely want to look at the resource first and make their own judgement if that is possible, and then read more about it if they are interested. I think this is because the cost of looking at an online resource is minimal (as compared to buying something or attending a course, for example). So the catalog issue leads to two problems:

Problem: When people see search results, they likely want to go directly to the resource instead of to a catalog page.

Solution: When a catalog page is the only entry for a resource, that entry is flagged “primary”. As soon as we create an entry that goes directly to the resource, we flag that new entry primary, and the catalog entry as not primary; we also store the id of the catalog entry in the list of duplicate entries that we store in the new entry. When searching, by default return only primary entries unless the application explicitly requests all entries. Return a flag indicating that an entry has catalog entries. Provide an API for requesting catalog entries for a specific entry.

Problem: In most cases, catalog metadata does not provide the url of the resource it is cataloging.

Solution: Initially flag the entry as “primary” so it will show up in search results. Later, asynchronously crawl the catalog pages to find the url of the catalogued resource. Once the direct url is known, create a new entry for the resource and store the id of the catalog entry in the list of “related entries” that we store for the new entry. Flag the catalog entry as not primary and the new entry as primary. Copy the metadata from the catalog entry into the new entry. Use the resource domain as the key for the feed to add the new entry to. If the feed does not already exist, create one for it.

Problem: If there are multiple entries (catalog etc for a resource), which metadata should we use to calculate the recommendation for the resource?

Solution: Options might be: (a) the metadata provided by the resource, (b) metadata generated by a crawl of the resource – I think this is bad because frequently metadata is more descriptive than the page itself, (c) the first catalog entry found for the resource, (d) the largest set of metadata for the resource. My thought it to always use the largest set of metadata for the resource unless there is no catalog entries (like in the case of where we crawl a website), in which case we must use the metadata generated by the crawl. In order to facilitate this approach, we: (1) for entries, we store whether or not the metadata came from that resource itself or not, (2) whenever we detect a new catalog entry for a resource that already has an entry, we look to see if the metadata in the existing entry was copied from a catalog entry; if it was, compare the size of the metadata from the two entries and update the metadata with the new catalog entry metadata if it is larger. For the purpose of calculating recommendations it might make sense to use all of the metadata from all of the sources.

Problem: When a website requests recommendations for a url, normally we want to return non-catalog entries, but when a catalog requests recommendations for one of its urls, they likely want their own catalog entries back if they exist.

Solution: When generating recommendations, for recommended entries that have catalog entries, check those and recommend those catalog entries instead.

Detecting and Handling Feed Entry Deletions

Problem: OAI has a way to tell you that an entry has been deleted, but RSS does not. How can you detect when an entry has been deleted, and what should you do when it is deleted?

Solution: My thought is that this is just part of what our dead link handler does. It finds entries with dead links and flags them deleted or actually deletes them. When we re-index we remove items from the index that have been flagged deleted.

Dealing with Dead Links

Problem: Many times the resources in our indexes get taken down or moved without notification (the source of the metadata doesn’t get updated or it doesn’t get updated for a while). What should we do in that situation?

Solution: We will write a bot that will flag entries dead. Once entries are dead they won’t show up in search or recommendation results. Should they still be used as the basis for recommendations? Probably not. Maybe we create another process that looks for the new location of the dead entries?

Generating Metadata for a URL

Problem: When someone adds an entry but doesn’t provide metadata, we need to be able to generate metadata for the entry. We also need to know which feed to put it into.

Solution: The application should give us a feed id, or a display_url along with the entry URL. If it does not send a feed ID, we will look for feed using the host portion of the entry permalink. If one does not exist, it will create one and specify the host the display url for the feed, that way future entries for that feed will always go into that feed.

  • An item is bookmarked or shared into the system but we don’t have metadata for it.

Configuring Apache and Tomcat to serve my java web application through port 80

Default Tomcat installations run on port 8080 so you get urls like:

http://mydomain.com:8080/lms/index.jsp

Some firewalls block port 8080 so I wanted my site to be available on port 80 so that it uses urls like:

http://mydomain.com/lms/index.jsp.

One option was to modify the Tomcat configuration to listen on port 80. However, I already have Apache installed and listening on port 80 (to serve other content) so I couldn’t that. Instead I configured Apache to route requests for my web application to Tomcat. I’ve been through this process a number of times before, and it never seems to go smoothly, so I document it here. I am running Apache 2.2 and Tomcat 6 on 32 bit Ubuntu Linux.

Overview

The steps are:

  1. Download the Apache jk connector module (mod_jk.so).
  2. Create Apache module configuration files for the jk connector (jk.load and jk.conf) and enable the module.
  3. Create a worker.properties file to configure the Tomcat worker for the connector.
  4. Define an AJP connector in your Tomcat configuration file (server.xml)
  5. Assign urls to Tomcat in your Apache virtual hosts file.

Download the Apache jk connector module (mod_jk.so)

Apache uses the jk connector module to talk to Tomcat. I downloaded it from a subdirectory of http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/. I wasn’t sure which OS I was running and whether or not I was running a 32 bit version (i586 directory) or a 64 bit version (x86_64). To find this out, I ran:

file /usr/bin/file
/usr/bin/file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
So I downloaded: http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.28/i586/mod_jk-1.2.28-httpd-2.2.X.so

I chose that version because I am running Apache 2.2. There are different versions for different versions of Apache.

I put the file in my Apache modules directory (/usr/lib/apache2/modules/) and renamed it to mod_jk.so.

Create Apache module configuration files for the jk connector (jk.load and jk.conf) and enable the module

In order to get Apache to load and configure the jk connector module, I created jk.load and jk.conf files (in /etc/apache2/mods-available/) and then enabled them. jk.load just tells Apache where to find the module:

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

jk.conf ties everything together by configuring the jk connector module:

# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/apache2/workers.properties

# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile     /var/log/apache2/mod_jk.shm

# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile     /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel    info

# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

For more information about the Apache jk connector module configuration, see the Tomcat Connector – Apache Webserver HowTo.

Initially I set the JkLogLevel to debug, so I could see any error messages, but then changed it to info once I had everything working.

After creating the files, I enabled the module using:

sudo a2enmod jk

That creates symlinks to the jk.load and jk.conf files in the mods-enabled directory where my Apache is configured to look for modules to load.

Define an AJP connector in your Tomcat configuration file (server.xml)

AJP is an efficient protocol that Apache and Tomcat can be configured to use to talk to each other. I set up an AJP connector in my Tomcat configuration file (/etc/tomcat6/server.xml). The default configuration file has the connector defined but commented out, so I uncommented it:

<!– Define an AJP 1.3 Connector on port 8009 –>
<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

For details see the Tomcat AJP Connector documentation.

Create a worker.properties file to configure the Tomcat ajp worker for the connector

“A Tomcat worker is a Tomcat instance that is waiting to execute servlets or any other content on behalf of some web server”.

Note: this quote from the documentation is a bit curious, because, nowhere in the Tomcat configuration files do I tell Tomcat about the worker. I think that the worker is actually a process that the jk connector spawns.

I configured a worker to listen to Apache requests by creating a worker.properties file in the same directory as the Apache configuration file (/etc/apache2/workers.properties).

# Define 1 real worker using ajp13
worker.list=worker1

# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

The jk connector knows how to talk to this worker, because the file name is specified in the Apache jk connector configuration file (/etc/apache2/mods-available/jk.conf). For more information see the Tomcat Connector Quick Start or the Tomcat Connector Reference Guide.

Assign urls to Tomcat in your Apache virtual hosts file

After I configured a Tomcat worker to listen to AJP requests and configured Apache to use the jk connector module to talk to that worker, the last thing that was needed was to configure my web site’s virtual host (/etc/apache2/sites-available/default) to route urls to Tomcat:

<VirtualHost *:80>
...
        JkMount /lms/* worker1
...
</VirtualHost>

Note that worker1 is the name I gave to the worker I set up in the workers.properties file. Note that by using a * mask, I routed all requests (including static files) through Tomcat. Alternatively I could have configured only jsp requests to be routed to Tomcat, using:

<VirtualHost *:80>
...
        JkMount /lms/*.jsp worker1
...
</VirtualHost>
I would then have needed added Directory configurations to the virtual host telling Apache where to serve the static files from.

Restart Tomcat and Apache

Of course, after I had done all of this, I had to restart Tomcat and Apache:
sudo /etc/init.d/tomcat6 restart
sudo /etc/init.d/apache2 restart

Lifecycle

To the best of my understanding, the relevant lifecycle is:

  1. When Tomcat starts up, it begins listening for AJP requests on port 8009 (because the connector is defined in /etc/tomcat6/server.xml).
  2. When Apache starts up, it loads the jk connector module (because it is defined in /etc/apache2/mods-enabled/jk.load).
  3. When Apache loads the jk connector, its configuration file (/etc/apache2/mods-enabled/jk.conf) tells it to send requests to the specified Tomcat worker and to use shared memory to do that.
  4. It is not clear to me whether or not the Tomcat worker gets spawned when Apache starts up or on each request. I don’t see how it could get spawned when Tomcat starts up since Tomcat has no way of knowing about it.
  5. Apache receives a request for a url that is mapped to Tomcat (in the virtual host file – /etc/apache2/sites-enabled/default).
  6. Apache uses the jk connector module (mod_jk.so) to generate a request to send to Tomcat via a Tomcat worker.
  7. The Tomcat worker communicates with Tomcat using the protocol (AJP) and port (8009) defined in the workers configuration file (/etc/apache2/workers.properties).
  8. Tomcat processes the request and returns the response back through the worker and connector to Apache which returns it to the client.

Kind of complicated, huh? And of course, this is just my best guess.

Questions and problems

The questions / problems I ran into this time I went through this process were:
  • Not knowing which version of the JK connector to download
  • Forgetting I needed to configure the AJP connector in the Tomcat configuration file
  • Initially I routed only requests for JSP pages to Tomcat and so my stylesheets and images did not show up

GeoGebra NA 2010

I’m presenting at the First GeoGebra North America Conference this morning

Using Technology to Teach Mathematics

Today I am presenting Using Technology Effectively to Teach Mathematics at the Utah Association of Math Teacher Educators annual meeting being held at Utah State University.

Wide Field Infrared Survey Explorer (WISE)

I was excited to see yesterday that images from the Wide Field Infrared Survey Explorer (WISE) are being made public. Amazing images. Here is my new computer desktop image that I stare at in wonder.

For more info and cool images check out the WISE project website.

Some of Technology for WISE was developed at Space Dynamics Laboratory here in Cache Valley where some of my neighbors work. Another fun connection for me is that the rocket that carried WISE into orbit was launched from Vandenberg Air Force base where my Dad was serving when I was born.

NLVM team receives Utah Governor’s Medal for Science and Technology

Recently our National Library of Virtual Manipulatives team (Bob Heal, Larry Cannon, Jim Dorward, and myself) was awarded the Utah Governor’s Medal for Science and Technology.

Here is some press that covered the award:

Here are some previous articles about the team as well:

Web crawling on a budget

Justin and I submitted proposals to the Digital Media and Learning Competition. I was amazed to see the breadth of the 100 pages of submissions. There are a lot of good ideas there. Not being sure that the submissions will always be kept public, I wanted to archive them for later reference. Here was the ruby script I came up with:

(1..100).each {|page| system("curl -o #{page}.html
   http://dmlcompetition.net/pligg/index.php?page=#{page}")}

Ruby rocks!

How to unlock your droid when your kids try to guess the pattern too many times

My daughter’s friends got a hold of my droid and thought it would be fun to try to guess the password pattern. After enough times, it locked up my droid and asked me to login with my gmail account credentials. Problem is, that didn’t work. It is a known bug. After a few minutes of Googling, I found:

http://code.google.com/p/android/issues/detail?id=4784 (comment 35)

1) create a new gmail account on the computer.
2) call your cell phone with a different phone.
3) answer your cell phone then hit the back button and it will take you to the home
screen.
4) turn on wifi so it can do data and voice at the same time (remember that the phone
is still connected)
5) go to Settings -> Location & Security and disable lock pattern (you’ll need to
enter to correct pattern previously set)
6) go to Settings -> Accounts & Sync and click “Add Account” and add your newly
created Gmail account.
7) hang up the phone.
8) turn the phone back on, at the lockout screen, enter your new Gmail account info
and it should let you back in
9) once the phone is unlocked, you can go in setting and remove the newly added Gmail
account and keep the old one.

Google giveth, and Google taketh away, and then Google giveth again.

Presenting personal recommendations

Generating personal recommendations is one thing, presenting them to the user in a way that they find them useful is something else. Here are our plans for folksemantic.com:

  • Personal recommendations page – For each user, provide a personal recommendations page. Visually separate recommendations that they have already clicked on.
  • Personal recommendations tool – Include a personal recommendations button on our folksemantic bar that when clicked on will display their recommendations in the right panel. Linking to the recommendations from that panel will refresh the content in the iframe (not do a full page refresh).
  • Personal recommendations action link – Include a link to the user’s recommendations page on their dashboard.
  • Inject recommendations into activity feeds – Whenever we generate new personal recommendations, inject them into a user’s activity feed that is displayed on their dashboard.
  • Email personal recommendations – Email personal recommendations to users as often as they would like (controllable in their account settings).

A personal recommendation algorithm

We’re in the process of building out personal recommendations for folksemantic.com. The basis for the recommendations is user attention metadata. The data we use includes:

  • Identity feeds – RSS feeds that users register that represent their interests. For example, their blog or their delicious account.
  • Clicks – The articles that the user clicks on.
  • Shares – The articles that the user shares to others.
  • Comments – Articles that the user comments on.
  • Time on page – Amount of time that a user spends on an article before moving on.
  • Searches – Searches the user executes.

Recommendation Assumptions

Some of our assumptions are:

  • Semantic relatedness – The more semantically similar an article is to articles that a user has paid attention to, the more interesting to the user.
  • Attention types – Different types of attention should be given different weights. For example, following a link to an article should not give it as much weight as writing the article.
  • Attention details – The particulars of a given type of attention might make it more important than another attention of the same type. For example, if a person shares an article with 100 people, it might be reasonable to infer that it is more important than an article that they share with one person.
  • Entry recency – The more recently an article has been added to the system, the more interesting to the user (they probably haven’t seen it before).
  • Attention recency – The more recently a user has showed attention to an article, the more weight that should be given to it.
  • Attention frequency – The more frequently a user has showed attention to an article, the more weight that should be given to it.

Stating these assumptions reminds me of the difference between relevance and certainty. So while an item that a user clicks on may be more relevant than an blog article they have written, it is harder to be certain of that. Our approach is to give the click less weight than the article.

Recommendation Score

Right now, we score articles using the formula:

(relevance)(attention type)(attention details)(attention recency)(article recency)

For all articles that a user has paid attention to, we score the 20 “related articles” using this algorithm; rank the scores and cache the top 20 (that the user hasn’t already clicked on) to recommend to the user. There are obvious weaknesses to this approach, but we are going to start there and see where to go next.

Possible Extensions / Improvements

We are considering: