Somms.NWURFL API (English)

31 de agosto de 2007

What is?

Somms.NWURFL is an API for WURFL library developed in .NET using C# 2.0. It is focused in abstraction of data access, and WURFL evolution: Somms.NWURFL provides a collection of interfaces to be implemented for data access layer, and core functions for searching devices by UserAgent strings.

What’s new?

Concept & Search Algorithm

WURFL is more than just an XML file, WURFL is the data stored in it. Regardless of how WURFL is stored, in memory like a hashtable, a database or an XML file, you will have the same data with a similar structure. The way managing this data is also similar, and can be abstracted. So here is where Somms.NWURFL have the point. It tries to unify different APIs, each one using its own search algorithm, and get one common logic for search algorithm bassed in WURFL evolution.

Download

You can download Somms.NWURFL from Sourceforge.

It includes two data access libraries, one for XML file using Margl.Wurfl, and other one for MySQL reading data stored with Tera-WURFL. See Test projects for usage info.

Basic Description

The core of Somms.NWURFL are two interfaces, IWurflDevice and IWurflProvider, implemented respectively by WurflDevice class and WurflProvider class.

WurflDevice

This class is a dictionary with device data. It is returned by search functions of WurflProvider.

WurflProvider

This abstract class has all main functions. Manages the cache, and has the main algorithm structure for search by UserAgent:

  1. Search in cache. If no result,continue.
  2. Search exact match in WURFL. If no result,continue.
  3. Search strippingUserAgent. If no result,continue.
  4. Extract possible info from UserAgent, and return a generic device with no id filled with this ingo . If no result, return null.

It also has abstract functions for data access.

Improved Stripping Search Algorithm

The StrippingManagerClass provides functionallity for searching a device stripping UserAgent. It tries to avoid false positives, and to find a match consuming as less resources as possible.

This is the algorithm:

  1. Split UserAgent in “tokens” (string splitted by spaces and slashes).
  2. Remove last token and search in WURFL with regex ^tmpUA.* (being tmpUA the partial UAgent)
  3. If we have ONLY ONE result, return it as success.
  4. If we have more than one
    1. Search if one of them is an exact match for tmpUA. If so, return it as success.
    2. We are going to get back to previous UAgent (with last removed token), and strip character by character
      1. Remove last character and search in WURFL with regex ^tmpUA.* (being tmpUA the partial UAgent)
        1. If we have ONLY ONE result, return it as success.
        2. If we have more than one it is impossible to give an accurate result. Return null as failure.
        3. If we have no result, remove next character
  5. If we have no result, remove next token

It first tries to find a result stripping by tokens. This is faster than character stripping. If it finds more than one result it does a subsearch from last no-success UserAgent string, trying to get an accurate result with character stripping. It only will return a success response if have only one device.

Heuristic Search Algorithm

It is under development, since I have never needed it because search stripping algorithm is very good :D . This algorithm is only used when a device is not in WURFL. At the moment, in this case report UAgent and UAProf to WURFL crew if possible.

Future

To be done:

  • Complete heuristic search algorithm.
  • Integration with ASP.NET browserCaps library.

Examples

This are fragments of a real log file:
[code]
[Start]======================================================================
2007-09-03 09:44:52,140 [3856] WARN Marg.Wurfl.WurflIndex - Device with user_agent='Nokia6288/2.0 (05.92) Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link/6.3.1.15.0' not found
2007-09-03 09:44:52,140 [3856] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find something by tokens
2007-09-03 09:44:52,140 [3856] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :Nokia6288/2.0 (05.92) Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link/6.3.1.15.0
2007-09-03 09:44:52,140 [3856] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :Nokia6288/2.0 (05.92) Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link
2007-09-03 09:44:52,140 [3856] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :Nokia6288/2.0 (05.92) Profile/MIDP-2.0 Configuration/CLDC-1.1
2007-09-03 09:44:52,156 [3856] INFO Somms.NWURFL.Framework.Search.StrippingManager - Success with UAgent Nokia6288/2.0 (05.92) Profile/MIDP-2.0 Configuration/CLDC-1.1.* : Nokia6288/2.0 (05.92) Profile/MIDP-2.0 Configuration/CLDC-1.1
[End]========================================================================
[Start]======================================================================
2007-09-03 09:48:06,671 [3284] WARN Marg.Wurfl.WurflIndex - Device with user_agent='Nokia6234/2.0 (04.52) Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link/6.3.1.15.0' not found
2007-09-03 09:48:06,671 [3284] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find something by tokens
2007-09-03 09:48:06,671 [3284] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :Nokia6234/2.0 (04.52) Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link/6.3.1.15.0
2007-09-03 09:48:06,671 [3284] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :Nokia6234/2.0 (04.52) Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link
2007-09-03 09:48:06,687 [3284] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :Nokia6234/2.0 (04.52) Profile/MIDP-2.0 Configuration/CLDC-1.1
2007-09-03 09:48:06,687 [3284] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :Nokia6234/2.0 (04.52) Profile/MIDP-2.0 Configuration
2007-09-03 09:48:06,687 [3284] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :Nokia6234/2.0 (04.52) Profile/MIDP-2.0
2007-09-03 09:48:06,687 [3284] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :Nokia6234/2.0 (04.52) Profile
2007-09-03 09:48:06,687 [3284] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :Nokia6234/2.0 (04.52)
2007-09-03 09:48:06,703 [3284] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :Nokia6234/2.0
2007-09-03 09:48:06,703 [3284] INFO Somms.NWURFL.Framework.Search.StrippingManager - Success with UAgent Nokia6234/2.0.* : Nokia6234/2.0 (03.50) Profile/MIDP-2.0 Configuration/CLDC-1.1
[End]========================================================================

[Start]======================================================================
2007-09-03 10:40:37,906 [1596] WARN Marg.Wurfl.WurflIndex - Device with user_agent='NokiaN70-1/5.0638.3.0.1 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link/6.3.1.15.0' not found
2007-09-03 10:40:37,906 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find something by tokens
2007-09-03 10:40:37,906 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0.1 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link/6.3.1.15.0
2007-09-03 10:40:37,921 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0.1 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link
2007-09-03 10:40:37,921 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0.1 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1
2007-09-03 10:40:37,921 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0.1 Series60/2.8 Profile/MIDP-2.0 Configuration
2007-09-03 10:40:37,921 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0.1 Series60/2.8 Profile/MIDP-2.0
2007-09-03 10:40:37,921 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0.1 Series60/2.8 Profile
2007-09-03 10:40:37,937 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0.1 Series60/2.8
2007-09-03 10:40:37,937 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0.1 Series60
2007-09-03 10:40:37,937 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0.1
2007-09-03 10:40:37,937 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1
2007-09-03 10:40:37,953 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - More than one result found, let's do a finest search
2007-09-03 10:40:37,953 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0.1
2007-09-03 10:40:37,953 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0.
2007-09-03 10:40:37,953 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.0
2007-09-03 10:40:37,953 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3.
2007-09-03 10:40:37,968 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.3
2007-09-03 10:40:37,968 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638.
2007-09-03 10:40:37,968 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0638
2007-09-03 10:40:37,968 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.063
2007-09-03 10:40:37,968 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.06
2007-09-03 10:40:37,984 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.0
2007-09-03 10:40:37,984 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5.
2007-09-03 10:40:37,984 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/5
2007-09-03 10:40:37,984 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find partial UAgent :NokiaN70-1/
2007-09-03 10:40:37,984 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - We have found an exact match with stripped UAgent
2007-09-03 10:40:37,984 [1596] INFO Somms.NWURFL.Framework.Search.StrippingManager - Success with UAgent NokiaN70-1/ : NokiaN70-1/
[End]========================================================================
[/code]


  • qrcode link

Ir al sitio para móviles