<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ian Mercer &#187; Ian Mercer</title>
	<atom:link href="http://blog.abodit.com/author/ian/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.abodit.com</link>
	<description>Living in the World&#039;s Smartest House</description>
	<lastBuildDate>Sat, 07 Jan 2012 19:50:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>A simple state machine in C#</title>
		<link>http://blog.abodit.com/2012/01/a-simple-state-machine-in-c/</link>
		<comments>http://blog.abodit.com/2012/01/a-simple-state-machine-in-c/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 08:31:35 +0000</pubDate>
		<dc:creator>Ian Mercer</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.abodit.com/?p=1673</guid>
		<description><![CDATA[Within the Abodit Natural Language engine there is often a need to track the state of various elements of a conversation. For example, is the user logged in or not, have they verified their email address, what instructional text have we offered them so far, &#8230; To make this easier I decided to add a <a href="http://blog.abodit.com/2012/01/a-simple-state-machine-in-c/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Within the Abodit Natural Language engine there is often a need to track the state of various elements of a conversation.  For example, is the user logged in or not, have they verified their email address, what instructional text have we offered them so far, &#8230;</p>
<p>To make this easier I decided to add a simple state machine class to the Abodit utilities provided with my NLP Engine.  There are, of course, a plethora of existing state machines on the web.  Some of them are based on older .NET technology lacking use of generics and functional programming techniques.  Others go overboard with fluent-style interfaces when a simple inheritance-based approach from an abstract base class would actually be simpler, less code, and more powerful.  Most of them I didn&#8217;t discover until after I&#8217;d built this one.  In any case, it&#8217;s always a good learning exercise to try to build something from scratch, so here goes &#8230;</p>
<p>First let&#8217;s take a look at the result.  Here&#8217;s how you can define a state machine that derives from this new StateMachine class:</p>
<pre class="brush: csharp; title: ; notranslate">
      public class LoginOutStatemachine : StateMachine&lt;LoginOutStatemachine&gt;
    {
        public static void ReportEnter(LoginOutStatemachine m, Event e, State state)
        {
            Console.WriteLine(m.User + &quot; entered state &quot; + state + &quot; via &quot; + e);
        }

        public static void ReportLeave(LoginOutStatemachine m, State state, Event e)
        {
            Console.WriteLine(m.User + &quot; left state &quot; + state + &quot; via &quot; + e);
        }

        public static State Initial = new State(&quot;Initial&quot;, ReportEnter, ReportLeave);
        public static State LoggedIn = new State(&quot;Logged In&quot;, ReportEnter, ReportLeave);
        public static State LoggedOut = new State(&quot;Logged Out&quot;, ReportEnter, ReportLeave);
        public static State Deleted = new State(&quot;Deleted&quot;, ReportEnter, ReportLeave);

        private static Event eLogsIn = new Event(&quot;Logs In&quot;);
        private static Event eLogsOut = new Event(&quot;Logs Out&quot;);
        private static Event eDeletesAccount = new Event(&quot;Account Deleted&quot;);

        static LoginOutStatemachine()
        {
            Initial
                    .When(eLogsIn, (m, s, e) =&gt; { Console.WriteLine(&quot;Logging in &quot; + m.User); return LoggedIn; })
                    .When(eDeletesAccount, (m, s, e) =&gt; { Console.WriteLine(&quot;Deleting account &quot; + m.User); return Deleted; });
            LoggedIn
                    .When(eLogsOut, (m, s, e) =&gt; { Console.WriteLine(&quot;Logging out &quot; + m.User); return LoggedOut; })
                    .When(eDeletesAccount, (m, s, e) =&gt; { Console.WriteLine(&quot;Account deleted &quot; + m.User); return Deleted; });
            LoggedOut
                    .When(eLogsIn, (m, s, e) =&gt; { Console.WriteLine(&quot;Logging in &quot; + m.User); return LoggedIn; })
                    .When(eDeletesAccount, (m, s, e) =&gt; { Console.WriteLine(&quot;Account deleted &quot; + m.User); return Deleted; });
        }

        public User User { get; private set; }

        public LoginOutStatemachine(State initial, User user)
            : base(initial)
        {
            this.User = user;
        }

        // Expose the events as public methods

        public void LogsIn()
        {
            this.EventHappens(eLogsIn);
        }

        public void LogsOut()
        {
            this.EventHappens(eLogsOut);
        }

        public void DeletesAccount()
        {
            this.EventHappens(eDeletesAccount);
        }
    }
</pre>
<p>As you can see, you define the <i>states</i> and the <i>events</i> for the state machine using static definitions.  (Events trigger state changes and associated actions).  Typically I&#8217;ll make the States public but the events private and instead provide method calls for each event that is allowed.</p>
<p>Each state can also have an Action that fires on entering the state and an action that fires on leaving the state and each action is provided with all of the parameters it might need (the state machine instance, the state it is going to or from, and the event that caused the transition to happen).  In this case all of these entry and exit events are linked to the same method that simply reports what happened.</p>
<p>To define what happens when an given event is received by the state machine you create the static constructor as shown and then, using a fluent interface you define for each initial state, the transition to a new state by calling the <i>When</i> method passing it the event and the action to take when that event happens from the initial state specified.  At the end of the method you must return the new state:</p>
<pre class="brush: csharp; title: ; notranslate">
Initial
  .When(eLogsIn, (m, s, e) =&gt; { Console.WriteLine(&quot;Logging in &quot; + m.User); return LoggedIn; })
  .When(eDeletesAccount, (m, s, e) =&gt; { Console.WriteLine(&quot;Deleting account &quot; + m.User); return Deleted; });
</pre>
<p>The (m, s, e) parameters give you the state machine itself, the state you are coming from and the event that has been received.  By passing your method all of these values I make it easy for you to access any properties of the state machine itself (e.g. a User object) and also allow you to write a single method that handles more than one event type or more than one initial state but which can still be parameterized by those values.</p>
<p>The other minor trick is that the StateMachine class is a generic in the state machine class itself.  A small trick that allows access to `T` as the type of the inherited state machine class and thus to any additional properties you define there.</p>
<p>Note how your state machine class can have properties like `User` which allows the transition code to access any additional data it needs.  You create an instance of the state machine for each user (all the heavy lifting is done in the static definition so the state machine remains a light-weight object).</p>
<p>In the case of the NLP engine you can pass an `IListener` in to the state machine constructor also so that you can `Say` messages back to the user.  Since the state machine is such a light-weight object you can afford to create it for each message interaction with the user and the information you need to persist is just the current state (which I will soon make into a string lookup).</p>
<p>If you want to use the actual state machine in any of your own projects (gratis), here&#8217;s the current code:</p>
<pre class="brush: csharp; title: ; notranslate">
    /// &lt;summary&gt;
    /// A state machine allows you to track state and to take actions when states change
    /// This state machine provides a fluent interface for defining states and transitions
    /// &lt;/summary&gt;
    /// &lt;remarks&gt;
    /// Nasty generic of self so we can refer to the inheriting class in here
    /// &lt;/remarks&gt;
    [Serializable]
    [DebuggerDisplay(&quot;Current State = {CurrentState.Name}&quot;)]
    public abstract class StateMachine&lt;T&gt; where T:StateMachine&lt;T&gt;
    {
        public State CurrentState { get; set; }

        public StateMachine(State initial)
        {
            this.CurrentState = initial;
        }

        /// &lt;summary&gt;
        /// An event has happened, transition to next state
        /// &lt;/summary&gt;
        public void EventHappens(Event @event)
        {
            this.CurrentState = this.CurrentState.OnEvent((T)this, @event);
        }

        /// &lt;summary&gt;
        /// An event that causes the state machine to transition to a new state
        /// &lt;/summary&gt;
        /// &lt;remarks&gt;
        /// Defined as a nested class so that this state machine's events can only be used with it
        /// &lt;/remarks&gt;
        [DebuggerDisplay(&quot;Event = {Name}&quot;)]
        public class Event
        {
            public string Name { get; private set; }
            public Event(string name)
            {
                this.Name = name;
            }
            public override string ToString()
            {
                return &quot;~&quot; + this.Name + &quot;~&quot;;
            }
        }

        /// &lt;summary&gt;
        /// A state that the state machine can be in
        /// &lt;/summary&gt;
        /// &lt;remarks&gt;
        /// Defined as a nested class so that this state machine's states can only be used with it
        /// &lt;/remarks&gt;
        [DebuggerDisplay(&quot;State = {Name}&quot;)]
        public class State
        {
            /// &lt;summary&gt;
            /// The Name of this state
            /// &lt;/summary&gt;
            public string Name { get; private set; }

            public Action&lt;T, State, Event&gt; ExitAction { get; private set; }
            public Action&lt;T, Event, State&gt; EntryAction { get; private set; }

            private readonly IDictionary&lt;Event, Func&lt;T, State, Event, State&gt;&gt; transitions = new Dictionary&lt;Event, Func&lt;T, State, Event, State&gt;&gt;();

            /// &lt;summary&gt;
            /// Create a new State with a name and an optional entry and exit action
            /// &lt;/summary&gt;
            public State(string name, Action&lt;T, Event, State&gt; entryAction = null, Action&lt;T, State, Event&gt; exitAction = null)
            {
                this.Name = name;
                this.EntryAction = entryAction;
                this.ExitAction = exitAction;
            }

            public State When(Event @event, Func&lt;T, State, Event, State&gt; action)
            {
                transitions.Add(@event, action);
                return this;
            }

            public State OnEvent(T parent, Event @event)
            {
                Func&lt;T, State, Event, State&gt; transition = null;
                if (transitions.TryGetValue(@event, out transition))
                {
                    State newState = transition(parent, this, @event);
                    if (newState != this)
                    {
                        // Entry and exit actions only fire when CHANGING state
                        if (this.ExitAction != null) this.ExitAction(parent, this, @event);
                        if (newState.EntryAction != null) newState.EntryAction(parent, @event, newState);
                    }
                    return newState;
                }
                else
                    return this;        // did not change state
            }

            public override string ToString()
            {
                return &quot;*&quot; + this.Name + &quot;*&quot;;
            }
        }
    }
}
</pre>
<p>For further reading on State Machines I recommend this <a href="http://en.wikipedia.org/wiki/UML_state_machine">Wikipedia Article</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.abodit.com/2012/01/a-simple-state-machine-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Dates and Times in Natural Language</title>
		<link>http://blog.abodit.com/2011/12/understanding-dates-and-times-in-natural-language/</link>
		<comments>http://blog.abodit.com/2011/12/understanding-dates-and-times-in-natural-language/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 08:54:08 +0000</pubDate>
		<dc:creator>Ian Mercer</dc:creator>
				<category><![CDATA[My News]]></category>
		<category><![CDATA[Natural Language Processing]]></category>
		<category><![CDATA[NLP]]></category>

		<guid isPermaLink="false">http://blog.abodit.com/?p=1666</guid>
		<description><![CDATA[One of the more challenging aspects of understanding natural language is dealing with date and time expressions. There are many different ways a user could refer to a specific date and time. They might say &#8220;Next Tuesday at 4pm&#8221;, they might give a specific date in any of several different forms, they might refer to <a href="http://blog.abodit.com/2011/12/understanding-dates-and-times-in-natural-language/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>One of the more challenging aspects of understanding natural language is dealing with date and time expressions.  There are many different ways a user could refer to a specific date and time.  They might say &#8220;Next Tuesday at 4pm&#8221;, they might give a specific date in any of several different forms, they might refer to other time ranges &#8220;First Tuesday in January 2012 at 4pm&#8221; etc.</p>
<p>Whilst my natural language engine can&#8217;t understand every possible date time expression (e.g. the second Wednesday after the first Friday in May 2010) it does handle a huge variety.</p>
<p>Clearly the .NET provided DateTime class is wholly inadequate to express the kinds of date/time expressions your users might enter.  To deal with that I&#8217;ve created my own classes that represent items like a specific <strong>Time</strong> of day, a <strong>DateTimeRange</strong>, a <strong>DateTimeRangeCollection</strong>, &#8230;</p>
<p><strong>TemporalSets</strong> are the most general result of parsing a datetime expression since they can represent any date time expression.  Broadly they split into two categories: finite and infinite expressions.  &#8220;Tuesday at 5pm&#8221; is an infinite time expression.  &#8220;Tuesday at 5pm January 2012&#8243; is a finite time expression.  Sometimes you will want to accept an infinite expression and interpret it as a future or past finite occurrence.  For that I have a MergePreferPast and MergePreferFuture method that operate on a <strong>TemporalSetCollection</strong>.  The demonstration code on <a href="http://nlp.abodit.com/home/download">BitBucket </a>shows this in action.</p>
<p><strong>TemporalSets</strong> also have unique capabilities around both providing query expressions (for database searches) and generative expressions (for adding dates to a calendar).</p>
<p>If you&#8217;d like to try out the latest date / time expression parsing code in my <a href="http://nlp.abodit.com">Natural Language Engine</a> you can visit the <a href="http://nlp.abodit.com/home/demo">demo</a> and try typing &#8220;define&#8221; followed by a date / time expression. </p>
<p>If you find any expressions that ought to work, please feel free to email or Tweet them to me.</p>
<p>Here&#8217;s a sample session:</p>
<pre class="brush: plain; title: ; notranslate">
define june 23rd 2010
Absolute:[DATETIMERANGE 6/23/2010 at 12:00 AM to 6/23/2010 at 11:59 PM]

define January 19th
Future:[Thursday 1/19/2012], [Saturday 1/19/2013], [Sunday 1/19/2014], [Monday 1/19/2015], [Tuesday 1/19/2016], [Thursday 1/19/2017], [Friday 1/19/2018], [Saturday 1/19/2019], [Sunday 1/19/2020], [Tuesday 1/19/2021]
Past: [Wednesday 1/19/2011] ...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.abodit.com/2011/12/understanding-dates-and-times-in-natural-language/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integrating Wordnet with Natural Language Processing (NLP)</title>
		<link>http://blog.abodit.com/2011/11/integrating-wordnet-with-natural-language-processing-nlp/</link>
		<comments>http://blog.abodit.com/2011/11/integrating-wordnet-with-natural-language-processing-nlp/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 23:03:12 +0000</pubDate>
		<dc:creator>Ian Mercer</dc:creator>
				<category><![CDATA[Natural Language Processing]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[NLP]]></category>
		<category><![CDATA[Wordnet]]></category>

		<guid isPermaLink="false">http://blog.abodit.com/?p=1650</guid>
		<description><![CDATA[I&#8217;ve been working to get a release of my NLP Engine out the door but wanted to boost the built in dictionary / thesaurus before release. So this weekend I integrated Wordnet into the engine. Wordnet is available in RDF as a series of triples. As well as all the word definitions grouped into synonym <a href="http://blog.abodit.com/2011/11/integrating-wordnet-with-natural-language-processing-nlp/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working to get a release of my NLP Engine out the door but wanted to boost the built in dictionary / thesaurus before release.  So this weekend I integrated Wordnet into the engine.  Wordnet is available in RDF as a series of triples.  As well as all the word definitions grouped into synonym sets (synsets) it also includes relationships like class relationships &#8216;<a href="http://en.wikipedia.org/wiki/Hyponymy">hyponym</a>&#8216; or &#8216;isa&#8217; and part relationships &#8216;<a href="http://en.wikipedia.org/wiki/Meronym">meronym</a>&#8216; or &#8216;<a href="http://en.wikipedia.org/wiki/Holonymy">holonym</a>&#8216;.</p>
<p>By building a simple in-memory graph of all these relationships my engine can now use them to infer interface types on objects.  To define an interface corresponding to a Wordnet synset like a mammal (wn30:synset-mammal-noun-1) you simply define an interface in the namespace &#8216;Noun&#8217; having a name of &#8216;mammal1&#8242;.  Through the type inheritance specified in the Wordnet file all mammals now inherit that interface automatically and you can write natural language rules that ask for a mammal and they will get any type of mammal defined in Wordnet.</p>
<p>For example:</p>
<p><a href="http://blog.abodit.com/wp-content/uploads/2011/11/DefineAardvark.png"><img src="http://blog.abodit.com/wp-content/uploads/2011/11/DefineAardvark.png" alt="Wordnet integration with Natural Language Engine" title="Wordnet integration with Natural Language Engine" width="623" height="206" class="alignright size-full wp-image-1651" /></a>  </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.abodit.com/2011/11/integrating-wordnet-with-natural-language-processing-nlp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MongoDB substring search with a difference</title>
		<link>http://blog.abodit.com/2011/11/mongodb-substring-search-with-a-difference/</link>
		<comments>http://blog.abodit.com/2011/11/mongodb-substring-search-with-a-difference/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 19:22:50 +0000</pubDate>
		<dc:creator>Ian Mercer</dc:creator>
				<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://blog.abodit.com/?p=1643</guid>
		<description><![CDATA[It&#8217;s quite common to want to search a database for a key that starts with a given string. In SQL you have LIKE and in MongoDB you have regular expressions: But what if you want to do the inverse of this? i.e. to search the database for the keys that are themselves substrings of the <a href="http://blog.abodit.com/2011/11/mongodb-substring-search-with-a-difference/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s quite common to want to search a database for a key that starts with a given string.  In SQL you have LIKE and in MongoDB you have regular expressions:</p>
<pre class="brush: jscript; title: ; notranslate">
db.customers.find( { name : { $regex : '^acme', $options: 'i' } } );
</pre>
<p>But what if you want to do the inverse of this? i.e. to search the database for the keys that are themselves substrings of the search string?  For example, suppose you are trying to parse a block of text and you want to find phrases in the database that match the start of the current block of text.  In SQL you would be dead in the water but with MongoDB you can create a RegEx that matches either the first word, or the first two words, or the first three words, &#8230; and so on.</p>
<p>We can construct a regular expression to do this, it might look something like: <strong>^word1($| word2($| word3$))</strong></p>
<p>Here&#8217;s a C# method that can create the necessary regular expression:</p>
<pre class="brush: csharp; title: ; notranslate">
        /// &lt;summary&gt;
        /// This generates a regular expression that matches as much of the given phrase as it can from a string
        /// i.e. a reverse prefix search where you want the database to supply the prefix and match it against your query
        /// useful for matching 'as much as possible from a given input'
        /// &lt;/summary&gt;
        private string generatePrefixRegex(string phrase, bool atStart)
        {
            string[] bits = phrase.Split(' ');
            string result = bits[0];

            // At the start of a sentence, if the first character is upper cased, we should also be looking for a lowercased verson of it
            if (atStart &amp;&amp; char.IsUpper(result[0]))
            {
                result = string.Format(&quot;(%0|%1)%2&quot;, char.ToLowerInvariant(result[0]), char.ToUpperInvariant(result[0]), result.Substring(1));
            }

            // Each additional word - either we end the string before it or we must include it

            foreach (var bit in bits.Skip(1))
            {
                result = result + &quot;($| &quot; + Regex.Escape(bit);
            }

            result = result + &quot;$&quot;;                      // last word must end string

            foreach (var bit in bits.Skip(1))
            {
                result = result + &quot;)&quot;;                 // close the expression
            }
            return &quot;^&quot; + result;                        // Must start at the start of a Name
        }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.abodit.com/2011/11/mongodb-substring-search-with-a-difference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A traffic service that answers &#8220;which way should I go?&#8221;</title>
		<link>http://blog.abodit.com/2011/10/a-traffic-service-that-answers-which-way-should-i-go/</link>
		<comments>http://blog.abodit.com/2011/10/a-traffic-service-that-answers-which-way-should-i-go/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 06:22:28 +0000</pubDate>
		<dc:creator>Ian Mercer</dc:creator>
				<category><![CDATA[Home Automation]]></category>
		<category><![CDATA[My News]]></category>
		<category><![CDATA[Smartest House]]></category>
		<category><![CDATA[smart home]]></category>

		<guid isPermaLink="false">http://blog.abodit.com/?p=1632</guid>
		<description><![CDATA[Most traffic reports (on the radio or in text message alerts) are fairly useless. Like weather reports they contain lots of irrelevant information that could be eliminated with just a bit of extra context. In fact, most of the information they deliver is completely irrelevant to you as an individual located in one spot and <a href="http://blog.abodit.com/2011/10/a-traffic-service-that-answers-which-way-should-i-go/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.abodit.com/wp-content/uploads/2011/10/TrafficWhichWay.png" alt="Which way should I go?  Traffic" title="Which way should I go?  Traffic" width="980" height="421" class="alignleft size-full wp-image-1633" /></p>
<p>Most traffic reports (on the radio or in text message alerts) are fairly useless.  Like <a href="http://blog.abodit.com/2010/07/weather-forecasting-for-home-automation/">weather reports</a> they contain lots of irrelevant information that could be eliminated with just a bit of extra context.  In fact, most of the information they deliver is completely irrelevant to you as an individual located in one spot and hoping to get to another spot.  Furthermore they aren&#8217;t actionable &#8211; telling me the traffic is slow on SR-520 and on I-90 isn&#8217;t interesting unless you can tell me which is the best way to go given where I am now and where I want to be.</p>
<p>So this weekend I added a new feature to the home automation that uses the WSDOT&#8217;s excellent traffic feed API to calculate a traffic report just for me.  Recently I&#8217;ve started driving from the north end of Bellevue to the south end of Sammamish during rush hour.  There are two very different paths I can take: SR-520 or I-405 to I-90.  If either route has a problem I should take the other.  So now I get an XMPP (chat) message from 4PM to 6PM whenever the optimal path changes from one route to the other.  It&#8217;s the absolute minimum information I need and it&#8217;s 100% actionable.</p>
<p>For the moment the calculation is fairly simple, I simply maintain a list of the FlowDataID values along each route and then calculate a total &#8216;slowness&#8217; factor based on the sum of those segments.  If one way is much better than the other it generates an alert.  If it goes back to being roughly equal the alert is cleared.</p>
<p>Since the calculation is purely relative (route A vs route B) it&#8217;s also fairly immune to day-of-week / school-holidays and other factors that have a significant impact on traffic but no impact on the only actionable decision I need to consider.</p>
<p>One other interesting point from the graph is just how spiked the traffic is on SR-520 compared to I-90.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.abodit.com/2011/10/a-traffic-service-that-answers-which-way-should-i-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Closing down seokeywordsearch.com</title>
		<link>http://blog.abodit.com/2011/09/closing-down-seokeywordsearch-com/</link>
		<comments>http://blog.abodit.com/2011/09/closing-down-seokeywordsearch-com/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 18:43:49 +0000</pubDate>
		<dc:creator>Ian Mercer</dc:creator>
				<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://blog.abodit.com/?p=1625</guid>
		<description><![CDATA[I&#8217;ve decided to shut down my experimental SEO keyword graphing tool to focus on other activities. Sorry if you came here looking for it but it is no more. I wish I could suggest a good alternative to you but AFAIK there still isn&#8217;t a tool that can take a keyword, expand it and then <a href="http://blog.abodit.com/2011/09/closing-down-seokeywordsearch-com/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided to shut down my experimental SEO keyword graphing tool to focus on other activities.  Sorry if you came here looking for it but it is no more.  I wish I could suggest a good alternative to you but AFAIK there still isn&#8217;t a tool that can take a keyword, expand it and then produce a graph showing you all the related terms and how you should think about planning your web site pages.</p>
<p>If anyone wants to buy the domain seokeywordsearch.com let me know before I let it go as it will probably get snapped up by some domain squatter.</p>
<p>If you want to build you own I suggest you look into some of the force-directed layout algorithms out there including <a href="http://mbostock.github.com/d3/ex/force.html">D3</a>, a javascript library. </p>
<p><a href="http://blog.abodit.com/wp-content/uploads/2011/09/Keyworddiagram.png"><img src="http://blog.abodit.com/wp-content/uploads/2011/09/Keyworddiagram-1024x565.png" alt="SEO Keyword Diagram" title="SEO Keyword Diagram" width="1024" height="565" class="alignright size-large wp-image-1626" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.abodit.com/2011/09/closing-down-seokeywordsearch-com/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Programming a smart home with a fluent, domain-specific language</title>
		<link>http://blog.abodit.com/2011/09/programming-a-smart-home-with-a-fluent-domain-specific-language/</link>
		<comments>http://blog.abodit.com/2011/09/programming-a-smart-home-with-a-fluent-domain-specific-language/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 17:30:09 +0000</pubDate>
		<dc:creator>Ian Mercer</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Home Automation]]></category>
		<category><![CDATA[Smartest House]]></category>

		<guid isPermaLink="false">http://blog.abodit.com/?p=1619</guid>
		<description><![CDATA[In response to a question I received recently, here is an example of the fluent extensions to C# that my home automation system uses to define how it should behave. In effect this is a domain specific language for modeling home automation behavior as a finite state machine. Note how you can use either a <a href="http://blog.abodit.com/2011/09/programming-a-smart-home-with-a-fluent-domain-specific-language/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>In response to a question I received recently, here is an example of the fluent extensions to C# that my home automation system uses to define how it should behave.   In effect this is a domain specific language for modeling home automation behavior as a finite state machine.  Note how you can use either a purely declarative sequence or you can use procedural code within a Do() block.  </p>
<pre class="brush: csharp; title: ; notranslate">
            Living.FloorSensor
                .Then(Entrance.HallBeam, 30)
                .Provided(Time.Bedtime)
                .ProvidedNot(Home.DinnerGuests)
                .PulseStretch(10 * 60)      // don't announce it too often - every 10 minutes
                .Do(&quot;Garage doors warning&quot;, () =&gt;
            {
                if (Garage.GarageDoors.AreAnyOpen)
                {
                    FirstFloor.Kitchen.AllMediaZones.AnnounceString(&quot;Excuse me, I think you may want to close the garage doors.&quot;);
                }
            });
</pre>
<p>In many ways this is similar to the Reactive Framework from Microsoft except my work on this predates the availability of Reactive Framework and unlike the Reactive Framework my &#8216;sequential logic blocks&#8217; include persistence logic so the entire state can be saved to disk (as it is every second).  This is important because some transitions in the state machine might be several hours or even days long and you need to be able to restart the system and carry on exactly where you left off.</p>
<p>One key benefit of the declarative approach over the procedural approach is that the declarative approach can explain itself.  So, the log entry for a light going on can show that the light was turned on because &#8216;it was dark&#8217; and &#8216;we had visitors&#8217; and &#8216;someone came into the room&#8217;.  Compared to traditional home automation systems where you either have no logging at all or you have a log of what happened, this kind of logging is invaluable for figuring out what went wrong when the logic gets complicated.  So in this example I should have moved the test for <i>Garage.GarageDoors.AreAnyOpen</i> out to a <b>Provided</b> clause which would allow it to be part of the reverse-chain logic explanation.</p>
<p>Partial results can be captured at any point in these logic chains and then reused in other chains because each partial result is itself a Sensor device that implements the full fluent interface. </p>
<p>Ultimately I plan to hook the logging for what happened back up to the NLP engine which will allow users to ask the home &#8216;Why did you put the driveway light on last night around 9pm?&#8217; and ultimately I plan to allow the logic itself to be defined using natural language.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.abodit.com/2011/09/programming-a-smart-home-with-a-fluent-domain-specific-language/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&#8220;Remember Everything&#8221; &#8230; a long-term project</title>
		<link>http://blog.abodit.com/2011/09/remember-everything-a-long-term-project/</link>
		<comments>http://blog.abodit.com/2011/09/remember-everything-a-long-term-project/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 07:26:42 +0000</pubDate>
		<dc:creator>Ian Mercer</dc:creator>
				<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[My News]]></category>
		<category><![CDATA[Natural Language Processing]]></category>
		<category><![CDATA[Semantic Web]]></category>

		<guid isPermaLink="false">http://blog.abodit.com/?p=1606</guid>
		<description><![CDATA[One of my long-term project ideas that is gradually coming together piece-by-piece is a system I call &#8220;Remember Everything&#8221; (for want of a better name). &#8220;Remember Everything&#8221; connects nearly all of my projects into one giant solution that, well, remembers everything and has a natural language interface over it. As inputs it will take information <a href="http://blog.abodit.com/2011/09/remember-everything-a-long-term-project/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<div id="attachment_1608" class="wp-caption alignright" style="width: 694px"><a href="http://blog.abodit.com/wp-content/uploads/2011/09/RememberEverything.png"><img src="http://blog.abodit.com/wp-content/uploads/2011/09/RememberEverything.png" alt="Remember Everything using Natural Language Interface" title="Remember Everything" width="684" height="290" class="size-full wp-image-1608" /></a><p class="wp-caption-text">Here&#039;s a working example of the kind of semantic and mathematical summarization possible.</p></div>One of my long-term project ideas that is gradually coming together piece-by-piece is a system I call &#8220;Remember Everything&#8221; (for want of a better name).</p>
<p>&#8220;Remember Everything&#8221; connects nearly all of my projects into one giant solution that, well, <i>remembers everything</i> and has a natural language interface over it.  </p>
<p>As inputs it will take information from my home automation system, my <a href="http://blog.abodit.com/2011/08/home-network-crawler-storage-file-mongodb/">whole-network storage crawler</a>, Google calendar, email, Twitter, blog, web crawler, an address-monitoring browser add-on I plan to write, the weather and traffic feeds, and, of course my <a href="http://nlp.abodit.com">natural language engine</a>.</p>
<p>All this data will be put into MongoDB and can then be queried.  Relationships between entities will be created using a semantic-web triple store and reasoner.</p>
<p>Together these capabilities will allow queries like:-</p>
<p>* Copy all the photos I took last week onto c:\vacationPhotos<br />
* Send img_0938.jpg to mum.<br />
* Who called last Monday?<br />
* Show pictures from last month taken on sunny days.<br />
* What was happening two weeks ago when X called?<br />
* Who called yesterday when I was in a meeting?<br />
* What song was playing around 9pm last night?<br />
* How long did I spend on the phone to my accountant last week?<br />
* What web pages did I read last week about the Semantic Web?<br />
* Send the web page I tweeted about last night to my Kindle.<br />
* We need butter and olives.<br />
* What do I need to buy from QFC?  (a semantic shopping list concept, more on that later &#8230;)</p>
<p>In addition to the shopping lists concept (that&#8217;s already in my home automation system but lacks the semantic reasoning) the system will take any subject-verb-object phrase and remember it and then allow you to query it back later, e.g.</p>
<p>* My son read 20 pages tonight <i>(making the weekly reading report easier)</i><br />
* How many pages did he read this week?<br />
* I took the red pill at 10AM<br />
* I walked 2 miles this morning<br />
* I ran 4 miles<br />
* How much exercise did I do this week when it wasn&#8217;t raining? (summarizing values semantically and mathematically)</i><br />
* The Audi was serviced this week <i>(remembering schedules so you can check if an item is overdue)</i><br />
* My BA frequent flyer number is #### <i>(remembering numbers you need to look up often)</i><br />
* I took the day off on friday  <i>(vacation reporting)</i><br />
* I spent $12.95 on lunch <i>(expense reporting)</i><br />
&#8230;</p>
<p>Whenever you have anything you need to remember the system will be able to remember it, recall it, and where possible aggregate or summarize it using math and/or semantic reasoning (e.g. running subClassOf exercise, butter subClassOf dairy product, dairy products areSoldAt QFC, &#8230;).</p>
<p>By linking my natural language engine to a triple store I can even allow users to teach it new concepts:</p>
<p><div id="attachment_1613" class="wp-caption alignright" style="width: 655px"><a href="http://blog.abodit.com/wp-content/uploads/2011/09/TeachNewMeaning.png"><img src="http://blog.abodit.com/wp-content/uploads/2011/09/TeachNewMeaning.png" alt="Using Natural Language to populate a triple store" title="Using Natural Language to populate a triple store" width="645" height="179" class="size-full wp-image-1613" /></a><p class="wp-caption-text">An in progress demonstration using English language input to populate a triple store</p></div>
<p>By silently monitoring your email, Twitter stream, calendar, activity in the house, &#8230; <strong>it will be able to answer questions based on the context not just on the content</strong> in ways that we take for granted as humans but which are not possible for computers today.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.abodit.com/2011/09/remember-everything-a-long-term-project/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert a property getter to a setter</title>
		<link>http://blog.abodit.com/2011/09/convert-a-property-getter-to-a-setter/</link>
		<comments>http://blog.abodit.com/2011/09/convert-a-property-getter-to-a-setter/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 04:52:40 +0000</pubDate>
		<dc:creator>Ian Mercer</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://blog.abodit.com/?p=1602</guid>
		<description><![CDATA[In the process of adding some strongly-typed extensions to the official MongoDB C# driver I needed some code to convert a property getter into a property setter. The following static method does that, turning e => e.Field into an Action method you can call to set the value of &#8216;Field&#8217;.]]></description>
			<content:encoded><![CDATA[<p>In the process of adding some strongly-typed extensions to the official MongoDB C# driver I needed some code to convert a property getter into a property setter.  The following static method does that, turning <strong>e => e.Field</string> into an Action method you can call to set the value of &#8216;Field&#8217;.</p>
<pre class="brush: csharp; title: ; notranslate">
        /// &lt;summary&gt;
        /// Convert a lambda expression for a getter into a setter
        /// &lt;/summary&gt;
        public static Action&lt;T, U&gt; GetSetter&lt;T,U&gt;(Expression&lt;Func&lt;T, U&gt;&gt; expression)
        {
            var memberExpression = (MemberExpression)expression.Body;
            var property = (PropertyInfo)memberExpression.Member;
            var setMethod = property.GetSetMethod();

            var parameterT = Expression.Parameter(typeof(T), &quot;x&quot;);
            var parameterU = Expression.Parameter(typeof(U), &quot;y&quot;);

            var newExpression =
                Expression.Lambda&lt;Action&lt;T, U&gt;&gt;(
                    Expression.Call(parameterT, setMethod, parameterU),
                    parameterT,
                    parameterU
                );

            return newExpression.Compile();
        }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.abodit.com/2011/09/convert-a-property-getter-to-a-setter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What if &#8230; you could define and query an Ontology using natural language?</title>
		<link>http://blog.abodit.com/2011/09/what-if-you-could-define-and-query-an-ontology-using-natural-language/</link>
		<comments>http://blog.abodit.com/2011/09/what-if-you-could-define-and-query-an-ontology-using-natural-language/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 08:30:35 +0000</pubDate>
		<dc:creator>Ian Mercer</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Natural Language Processing]]></category>
		<category><![CDATA[NLP]]></category>
		<category><![CDATA[Semantic Web]]></category>

		<guid isPermaLink="false">http://blog.abodit.com/?p=1596</guid>
		<description><![CDATA[Tonight as an experiment I connected my NLP engine to my MongoDB triple-store and built a reasoner that does simple-entailment over just RDFS:subClassOf and OWL:disjointWith Try it out at http://nlp.abodit.com/demo Ignore the instructions on the right and try building a simple ontology, Start by creating some root level class: car is a class Now expand <a href="http://blog.abodit.com/2011/09/what-if-you-could-define-and-query-an-ontology-using-natural-language/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Tonight as an experiment I connected my NLP engine to my MongoDB triple-store and built a reasoner that does simple-entailment over just RDFS:subClassOf and OWL:disjointWith</p>
<p>Try it out at http://nlp.abodit.com/demo</p>
<p>Ignore the instructions on the right and try building a simple ontology,</p>
<p>Start by creating some root level class:</p>
<p>car is a class</p>
<p>Now expand it:</p>
<p>A BMW is a car<br />
An Audi is a car<br />
what is a BMW<br />
<em>BMW is a car</em><br />
what is an Audi<br />
<em>Audi is a car</em><br />
is an Audi a BMW<br />
<em>I don&#8217;t know, under the open world assumption it could be</em><br />
an Audi is not a BMW<br />
is an Audi a BMW<br />
<em>No</em></p>
<p>Simple but promising.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.abodit.com/2011/09/what-if-you-could-define-and-query-an-ontology-using-natural-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

