<?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>Steven She at woggie.net &#187; Development</title>
	<atom:link href="http://www.woggie.net/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.woggie.net</link>
	<description>The life of a PhD Candidate in Software Engineering</description>
	<lastBuildDate>Wed, 16 Jun 2010 22:12:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Lesson to Self</title>
		<link>http://www.woggie.net/2009/03/11/lesson-to-self/</link>
		<comments>http://www.woggie.net/2009/03/11/lesson-to-self/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 06:43:33 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.woggie.net/2009/03/11/lesson-to-self/</guid>
		<description><![CDATA[I was debugging a seemingly random crash in some graph layout code. An hour later&#8230; feeling proud of myself for having fixed the problem, I wanted to file the problem in the bug tracker, only to find a bug report with the exact problem and resolution. Lesson learned: Always, always, check the bug tracker before [...]]]></description>
			<content:encoded><![CDATA[<p>I was debugging a seemingly random crash in some graph layout code. An hour later&#8230; feeling proud of myself for having fixed the problem, I wanted to file the problem in the bug tracker, only to find <a href="http://code.google.com/p/daglayout/issues/detail?id=3">a bug report with the exact problem</a> and resolution. Lesson learned: Always, always, check the bug tracker before trying to debug broken code yourself. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2009/03/11/lesson-to-self/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groovy Combinations Generator</title>
		<link>http://www.woggie.net/2008/12/13/groovy-combinations-generator/</link>
		<comments>http://www.woggie.net/2008/12/13/groovy-combinations-generator/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 20:14:49 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[choose]]></category>
		<category><![CDATA[closures]]></category>
		<category><![CDATA[combinations]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://www.woggie.net/?p=106</guid>
		<description><![CDATA[Ever needed to find all  k-combinations of a set? Of course! I&#8217;m pretty sure everybody has run into this problem one way or another, as part of your development work, a combinatorics assignment (eek!) or in every day life. For me, I needed to implement this for generating association rules. What better way to prototype [...]]]></description>
			<content:encoded><![CDATA[<p>Ever needed to find all  k-combinations of a set? Of course! I&#8217;m pretty sure everybody has run into this problem one way or another, as part of your development work, a combinatorics assignment (eek!) or in every day life. For me, I needed to implement this for generating association rules. What better way to prototype my eventual Java implementation than to use <a href="http://groovy.codehaus.org/">Groovy</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> choose<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">def</span> itemset, <span style="color: #993333;">int</span> choose<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> choose<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">def</span> itemset, <span style="color: #993333;">int</span> choose<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">def</span> results <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">//Initialize indices</span>
    <span style="color: #993333;">int</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> indices <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#91;</span>choose<span style="color: #66cc66;">&#93;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #b1b100;">in</span> 0..<span style="color: #66cc66;">&lt;</span>choose<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        indices<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> i
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #993333;">boolean</span> hasMore <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>hasMore<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">def</span> combo <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>
        <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #b1b100;">in</span> 0..<span style="color: #66cc66;">&lt;</span>indices.<span style="color: #663399;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            combo <span style="color: #66cc66;">&lt;&lt;</span> itemset<span style="color: #66cc66;">&#91;</span>indices<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>
        <span style="color: #66cc66;">&#125;</span>
        results <span style="color: #66cc66;">&lt;&lt;</span> combo
        hasMore <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Closure to move the right-most index */</span>
            <span style="color: #993333;">int</span> rightMostIndex <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Closure to find the right-most index */</span>
                    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #b1b100;">in</span> choose<span style="color: #66cc66;">-</span>1..0<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
                        <span style="color: #993333;">int</span> bounds <span style="color: #66cc66;">=</span> itemset.<span style="color: #663399;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">-</span> choose <span style="color: #66cc66;">+</span> i
                        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>indices<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&lt;</span> bounds<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> i
                    <span style="color: #66cc66;">&#125;</span>
                    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span>
            <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">// execute closure</span>
&nbsp;
            <span style="color: #808080; font-style: italic;">// increment all indices</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>rightMostIndex <span style="color: #66cc66;">&gt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                indices<span style="color: #66cc66;">&#91;</span>rightMostIndex<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">++</span>
                <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #b1b100;">in</span> rightMostIndex<span style="color: #66cc66;">+</span>1..<span style="color: #66cc66;">&lt;</span>choose<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    indices<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> indices<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">;</span>
                <span style="color: #66cc66;">&#125;</span>
                <span style="color: #808080; font-style: italic;">// there are still more combinations</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">true</span> 
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #808080; font-style: italic;">// reached the end, no more combinations</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">false</span>
        <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">// execute closure</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> results
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>I&#8217;ve based my implementation off one from <a href="http://www.amazon.ca/Applied-Combinatorics-Alan-Tucker/dp/0471735078">Applied Combinatorics by Alan Tucker</a>. First, there is an <code>indice</code> array that stores the k positions in the itemset. The items at these index locations are the k-combinations. The algorithm increases the right-most index until it reaches the last element of the itemset, then increases, the second right-most index and so on.</p>
<p>I wouldn&#8217;t recommend this implementation when dealing with large itemsets. A deficiency with this one-method approach is that a single list is constructed containing all of the combinations. This list can grow to be very large, very fast. It can be easily adapted to provide one combination at a time by refactoring the <code>hasMore</code> check into a separate method. This way, it would act like an iterator.  It&#8217;s too bad that Groovy doesn&#8217;t have support for the do-while loop as well, otherwise the <code>hasMore</code> closure could have been factored out into a really cool while check. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2008/12/13/groovy-combinations-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Opening a Marker in an Eclipse Java Editor</title>
		<link>http://www.woggie.net/2008/12/06/opening-a-marker-in-a-java-editor/</link>
		<comments>http://www.woggie.net/2008/12/06/opening-a-marker-in-a-java-editor/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 19:16:24 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">http://www.woggie.net/?p=100</guid>
		<description><![CDATA[Markers are a great feature of Eclipse and there are some great articles on creating Markers. However, I couldn&#8217;t find a good article on opening markers in an editor. So, here&#8217;s the best call sequence that I could figure out: IJavaElement element = ...; IEditorInput input = EditorUtility.getEditorInput&#40;element&#41;; IEditorPart editor = getSite&#40;&#41;.getPage&#40;&#41;.openEditor&#40;input, &#40;input instanceof FileEditorInput&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>Markers are a great feature of Eclipse and there are some great articles on creating Markers. However, I couldn&#8217;t find a good article on opening markers in an editor. So, here&#8217;s the best call sequence that I could figure out:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;">IJavaElement element = ...<span style="color: #339933;">;</span>
IEditorInput input = EditorUtility.<span style="color: #006633;">getEditorInput</span><span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
IEditorPart editor = getSite<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getPage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">openEditor</span><span style="color: #009900;">&#40;</span>input,
    <span style="color: #009900;">&#40;</span>input <span style="color: #000000; font-weight: bold;">instanceof</span> FileEditorInput<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> : JavaUI.<span style="color: #006633;">ID_CU_EDITOR</span> 
            : JavaUI.<span style="color: #006633;">ID_CF_EDITOR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
IDE.<span style="color: #006633;">gotoMarker</span><span style="color: #009900;">&#40;</span>editor, sNode.<span style="color: #006633;">getMarker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>EditorUtility is an internal JDT class, but I couldn&#8217;t find a better way of doing this. A check on the return type of the <code>getEditorInput</code> call is necessary to since it can return either a file editor (for compilation units) or a class file editor.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2008/12/06/opening-a-marker-in-a-java-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yet Another Groovy Spelling Corrector</title>
		<link>http://www.woggie.net/2008/11/05/spelling-corrector-implementation/</link>
		<comments>http://www.woggie.net/2008/11/05/spelling-corrector-implementation/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 05:48:04 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.woggie.net/?p=74</guid>
		<description><![CDATA[I&#8217;ve taken some time implementing Peter Norvig&#8217;s spelling corrector in an attempt to learn Groovy, a dynamic language that compiles to bytecode and is compatible with standard Java classes and libraries. There are a couple differences (most likely deficiencies) with my implementation. First, I use a list instead of a set when constructing the candidate [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve taken some time implementing <a href="http://norvig.com/spell-correct.html">Peter Norvig&#8217;s spelling corrector</a> in an attempt to learn <a href="http://groovy.codehaus.org/">Groovy</a>, a dynamic language that compiles to bytecode and is compatible with standard Java classes and libraries.</p>
<p>There are a couple differences (most likely deficiencies) with my implementation. First, I use a list instead of a set when constructing the candidate word list. Second, I created a separate occurrence function in order to provide the smoothing capability for our occurrence distribution. Third, I didn&#8217;t really care much for a low line count. It&#8217;s not the LOC that matter in the end, it&#8217;s how easily <em>you</em> can comprehend the code! <img src='http://www.woggie.net/wp-content/plugins/tango-smilies/tango/face-smile.png' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SpellingCorrector <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">def</span> wordoccur <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>:<span style="color: #66cc66;">&#93;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">def</span> words<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">File</span> file<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    Scanner scanner <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Scanner<span style="color: #66cc66;">&#40;</span>file<span style="color: #66cc66;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">def</span> words <span style="color: #66cc66;">=</span> scanner.<span style="color: #663399;">findAll</span><span style="color: #66cc66;">&#123;</span> x <span style="color: #66cc66;">-&gt;</span> x.<span style="color: #006600;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">==</span>~ ~/<span style="color: #66cc66;">&#91;</span>a<span style="color: #66cc66;">-</span>z<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">+</span>/  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">def</span> train<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">List</span> words<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    words.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>
      wordoccur<span style="color: #66cc66;">&#91;</span>it<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> wordoccur.<span style="color: #006600;">containsKey</span><span style="color: #66cc66;">&#40;</span>it<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">?</span> wordoccur<span style="color: #66cc66;">&#91;</span>it<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">+</span> <span style="color: #cc66cc;">1</span> : <span style="color: #cc66cc;">1</span>
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">def</span> edits1<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> word<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">def</span> results <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>
    <span style="color: #993333;">int</span> n <span style="color: #66cc66;">=</span> word.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #808080; font-style: italic;">//Deletion. Remove a character.</span>
    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #b1b100;">in</span> 0..<span style="color: #66cc66;">&lt;</span>n<span style="color: #66cc66;">&#41;</span>
      results <span style="color: #66cc66;">&lt;&lt;</span> word<span style="color: #66cc66;">&#91;</span>0..<span style="color: #66cc66;">&lt;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">+</span> word<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">+</span>1..<span style="color: #66cc66;">&lt;</span>n<span style="color: #66cc66;">&#93;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">//Transposition. Swap adjacent characters.</span>
    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #b1b100;">in</span> 0..<span style="color: #66cc66;">&lt;</span>n<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
      results <span style="color: #66cc66;">&lt;&lt;</span> word<span style="color: #66cc66;">&#91;</span>0..<span style="color: #66cc66;">&lt;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">+</span> word<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">+</span> word<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">+</span> word<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">+</span>2..<span style="color: #66cc66;">&lt;</span>n<span style="color: #66cc66;">&#93;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">//Alteration. Change one character for another letter.</span>
    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #b1b100;">in</span> 0..<span style="color: #66cc66;">&lt;</span>n<span style="color: #66cc66;">&#41;</span>
      <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>c <span style="color: #b1b100;">in</span> <span style="color: #ff0000;">'a'</span>..<span style="color: #ff0000;">'z'</span><span style="color: #66cc66;">&#41;</span>
        results <span style="color: #66cc66;">&lt;&lt;</span> word<span style="color: #66cc66;">&#91;</span>0..<span style="color: #66cc66;">&lt;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">+</span> c <span style="color: #66cc66;">+</span> word<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">+</span>1..<span style="color: #66cc66;">&lt;</span>n<span style="color: #66cc66;">&#93;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">//Insertion. Add a letter in between the others.</span>
    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #b1b100;">in</span> 0..<span style="color: #66cc66;">&lt;</span>n<span style="color: #66cc66;">&#41;</span>
      <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>c <span style="color: #b1b100;">in</span> <span style="color: #ff0000;">'a'</span>..<span style="color: #ff0000;">'z'</span><span style="color: #66cc66;">&#41;</span>
        results <span style="color: #66cc66;">&lt;&lt;</span> word<span style="color: #66cc66;">&#91;</span>0..<span style="color: #66cc66;">&lt;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">+</span> c <span style="color: #66cc66;">+</span> word<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">+</span>1..<span style="color: #66cc66;">&lt;</span>n<span style="color: #66cc66;">&#93;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">return</span> results
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">def</span> knownedits2<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> word<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">def</span> candidates <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>
    edits1<span style="color: #66cc66;">&#40;</span>word<span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>
      candidates.<span style="color: #006600;">addAll</span><span style="color: #66cc66;">&#40;</span> edits1<span style="color: #66cc66;">&#40;</span>it<span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">findAll</span> <span style="color: #66cc66;">&#123;</span> wordoccur.<span style="color: #006600;">containsKey</span><span style="color: #66cc66;">&#40;</span>it<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> candidates
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/**
   * Smoothing distribution. If the word hasn't been encountered (novel words),
   *  we give it an occurence value of 1.
   */</span>
  <span style="color: #000000; font-weight: bold;">def</span> <span style="color: #993333;">int</span> occurrence<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> word<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> wordoccur<span style="color: #66cc66;">&#91;</span>word<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">==</span> <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">?</span> <span style="color: #cc66cc;">1</span> : wordoccur<span style="color: #66cc66;">&#91;</span>word<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">;</span>  
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">def</span> <span style="color: #aaaadd; font-weight: bold;">List</span> known<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">List</span> words<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> words.<span style="color: #663399;">findAll</span> <span style="color: #66cc66;">&#123;</span> wordoccur.<span style="color: #006600;">containsKey</span><span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">def</span> correct<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> word<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">def</span> candidates <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>word<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">+</span> known<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>word<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> known<span style="color: #66cc66;">&#40;</span>edits1<span style="color: #66cc66;">&#40;</span>word<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> knownedits2<span style="color: #66cc66;">&#40;</span>word<span style="color: #66cc66;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">return</span> candidates.<span style="color: #663399;">max</span> <span style="color: #66cc66;">&#123;</span>  occurrence<span style="color: #66cc66;">&#40;</span>it<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>First, we don&#8217;t attempt to split words into two sub-words. For example, a common typo may be &#8220;Ihave&#8221; rather than &#8220;I have&#8221;. Second, the training and known function can definitely be improved to with support for proper nouns, stemming, and more. I think it would be a fun exercise to try and to create a simple implementation of these features, much like the SpellingCorrector.</p>
<p>So, Groovy has great support for regular expressions, list construction and compositions and best of all, <em>closures</em>! I also had a chance to play with the Groovy NodeBuilder (on a separate program), which is a great way for constructing tree structures. All said and done, I would <em>hate</em> to implement this in Java.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2008/11/05/spelling-corrector-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe Acrobat.com</title>
		<link>http://www.woggie.net/2008/08/04/adobe-acrobatcom/</link>
		<comments>http://www.woggie.net/2008/08/04/adobe-acrobatcom/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 16:29:08 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.woggie.net/2008/08/04/adobe-acrobatcom/</guid>
		<description><![CDATA[It seems that Adobe doesn&#8217;t want to be left out of the Web 2.0 office application fad with it&#8217;s Acrobat.com. It provides document writing, desktop sharing, PDF creation, and a neat online PDF reader. All of this was made possible by employing the formerly Macromedia&#8217;s Flash technology. I was initially excited about the online Acrobat [...]]]></description>
			<content:encoded><![CDATA[<p>It seems that Adobe doesn&#8217;t want to be left out of the Web 2.0 office application fad with it&#8217;s <a href="https://www.acrobat.com/">Acrobat.com</a>. It provides document writing, desktop sharing, PDF creation, and a neat online PDF reader. All of this was made possible by employing the formerly Macromedia&#8217;s Flash technology. I was initially excited about the online Acrobat reader since the Linux reader is <em>quite slow</em>, and the other online solutions, such as <a href="http://scribd.com">Scribd</a> are less than impressive. However, the Flash plug-in for Linux isn&#8217;t very impressive either. Well, in any case, Adobe seems to have gotten the right idea, by starting work on an <a href="http://www.adobe.com/openscreenproject/">open-source Flash</a> and certifying <a href="http://blogs.adobe.com/spartacusacrobat/2008/01/pdf_iso_standard.html">PDF as an ISO standard</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2008/08/04/adobe-acrobatcom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Distributed Source Control using Mercurial</title>
		<link>http://www.woggie.net/2008/07/17/distributed-source-control-using-mercurial/</link>
		<comments>http://www.woggie.net/2008/07/17/distributed-source-control-using-mercurial/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 05:52:15 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://www.woggie.net/?p=47</guid>
		<description><![CDATA[I&#8217;ve recently started to experiment with distributed source control systems for my personal repository. I had been using Subversion previously, but it had several issues with directories that bothered me. In addition, since my primary computer was a laptop, I also wanted to have full commit and change tracking when I was offline. So distributed [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently started to experiment with distributed source control systems for my personal repository. I had been using <a href="http://subversion.tigris.org">Subversion</a> previously, but it had several issues with directories that bothered me. In addition, since my primary computer was a laptop, I also wanted to have full commit and change tracking when I was offline.</p>
<p>So distributed source control systems seemed to fit the bill. I looked at two systems in particular, <a href="http://www.selenic.com/mercurial/">Mercurial</a> and <a href="http://git.or.cz">git</a>. Mercurial caught my eye because of its simplicity, and similarity with the traditional, centralized SCMs such as CVS and Subversion. However, I actually started using git first. The reason was that many open source projects had switched to git and I needed to compile several bleeding edge packages. So, I had no choice but to learn to use git. However, I couldn&#8217;t really wrap my head around it. While git is no doubt, a very powerful SCM, it was also a very complicated SCM. I took me a good hour or so before I understood how to track branches.</p>
<p>So, I settled for Mercurial. While I was worried that Mercurial was too immature, the fact that the <a href="http://www.mozilla.com">Mozilla</a> projects are <a href="http://weblogs.mozillazine.org/preed/2007/04/version_control_system_shootou_1.html">also using Mercurial</a> was very comforting.</p>
<p><span id="more-47"></span></p>
<h4>Usage, Tips and Tricks</h4>
<p>I will not describe the setup and typical usage of Mercurial, since there are plenty of <a href="http://blog.medallia.com/2007/02/a_guided_tour_of_mercurial.html">good tutorials</a> out there. What I will do, is highlight some of the features that have really caught my eye and I find indispensible now.</p>
<p>The first great feature of Mercurial is the <code>addremove</code> command, which removes deleted files and adds newly created files to the repository. The command also has an optional parameter which you can specify the directory to process. I typically use <code>.</code>, such that my next commit would only contain the changes that I&#8217;ve made in the current directory.</p>
<pre>hg addremove   #For the entire repository
hg addremove . #For the current directory</pre>
<p>Another nice feature of Mercurial is its ability to ignore certain files and file patterns specified using a <em>single</em> <code>.hgignore</code> file. This is very convenient, for excluding temporary files, such as the intermediary files that are left behind after compiling LaTeX source code. Mercurial supports two syntax types when specifying patterns in <code>.hgignore</code>, <em>glob</em> and <em>regex</em>. The glob syntax allows you to specify patterns using wildcards (*). I primarily use regex, since <a href="http://xkcd.com/208/">regular expressions are very powerful</a>.</p>
<p>Here are the contents of my current <code>.hgignore</code>:</p>
<pre>syntax: regexp
.*.swp
.*.swo
^results/.*
^projects/.*/bin/
^lab/[0-9][0-9](winter|spring|fall)/.+\.(log|glo|glg|gls|dvi|aux|bm|bbl|blg|brf|ist|lof|lot|out|toc|vrb|ps)</pre>
<p>After creating the <code>.hgignore</code> file, don&#8217;t forget to add it to the repository for tracking using:</p>
<pre>hg add .hgignore</pre>
<h4>Tracking Branches</h4>
<p>For those interested in how to track branches using git, here is the command that I used. the -b modifer creates a branch in the local repository. The checkout command further require the <code>origin/</code> prefix for branches. In addition, the <code>--track</code> modifier tracks the remote branch such that a future pull will retrieve updates from the branch.</p>
<p>Using Mercurial:</p>
<pre>hg co somebranch</pre>
<p>Using git:</p>
<pre>git checkout --track -b localbranch origin/somebranch</pre>
<p><strong>Update on git</strong><br />
Thanks to the comment by Jakub, tracking a remote branch is actually rather easy using the <code>git remote</code> command. Here is an example I had to do with retrieving a xf86-video-ati git repository.</p>
<pre>git remote add agd5f git://cgit.freedesktop.org/~agd5f/xf86-video-ati/</pre>
<p>To restrict the remote repository to a particular branch, use <code>-t</code> like the following:</p>
<pre>git remote add agd5f -t agd-powerplay git://cgit.freedesktop.org/~agd5f/xf86-video-ati/</pre>
<p>We can now fetch data from the remote repository using the command:</p>
<pre>git fetch agd5f</pre>
<p>We can list the branches that are present in our repository by executing the command. Note that the remote repository shows up just like a separate branch to our local repository:</p>
<pre>git branch -r</pre>
<p>Now, we can pull from this remote repository, and merge the changes from the branch <code>agd-powreplay</code>:</p>
<pre>git pull agd5f agd-powerplay</pre>
<h4>Restoring a Single File to a Previous Revision</h4>
<p>It seems that Mercurial is currently not able to checkout a single file or subdirectory. It is one of the &#8220;todo&#8221; items in <a href="http://code.google.com/soc/2008/hg/appinfo.html?csaid=B091D9B819911D09">their Google Summer of Code project</a> this year, so perhaps we&#8217;ll have this feature soon enough. However, this is rather inconvenient at the moment. A workaround for this issue is to use the <code>hg cat</code> command, to view a previous revision of a file. In my case, I had overwritten a file <code>applet.svg</code> with changes that I did not want to keep. To revert the file, I executed:</p>
<pre>hg cat applet.svg &gt; applet.svg</pre>
<h4>Tags</h4>
<p>In Mercurial, <a href="http://www.selenic.com/mercurial/wiki/index.cgi/Tag">tags</a> are simply aliases for changesets.</p>
<pre>hg checkout -r tagname</pre>
<p>git treats tags, branches and trunk/master as one and the same, in the sense that they are all <a href="http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#def_refspec">refspecs</a>. This is similar to Subversion&#8217;s model, however, tags and branches aren&#8217;t simply another directory in the repository. You have to add the <code>tags/</code> prefix when checking out a tag:</p>
<p>Using git:</p>
<pre>git checkout -b localtag tags/remotetag</pre>
<h4>Conclusions</h4>
<p>I am very happy with Mercurial. I ran into a very annoying issue with Mercurial early on, when I executed <code>hg fetch</code>, and it used my repository URI, along with my username and <em>password</em> as a commit message. However, luckily this issue was fixed in the Mercurial 1.0 release. Admittedly, I&#8217;ve only been using a single person Mercurial repository for the past couple months, so I haven&#8217;t really experienced a situation where I needed the full power of a SCM. However, Mercurial has been so far, been smooth sailing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2008/07/17/distributed-source-control-using-mercurial/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Pseudo-Random vs. True Random</title>
		<link>http://www.woggie.net/2008/07/16/pseudo-random-vs-true-random/</link>
		<comments>http://www.woggie.net/2008/07/16/pseudo-random-vs-true-random/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 00:23:12 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.woggie.net/2008/07/16/pseudo-random-vs-true-random/</guid>
		<description><![CDATA[A visual comparison between using the PHP rand() pseudo-random generator and the numbers generated by random.org, a truly random generator.]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://www.boallen.com/random-numbers.html">visual comparison</a> between using the PHP <code>rand()</code> pseudo-random  generator and  the numbers generated by <a href="http://random.org">random.org</a>, a truly random generator.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2008/07/16/pseudo-random-vs-true-random/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beamer, PDFTeX and XeTeX</title>
		<link>http://www.woggie.net/2008/07/16/beamer-pdftex-and-xetex/</link>
		<comments>http://www.woggie.net/2008/07/16/beamer-pdftex-and-xetex/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 05:17:35 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Site]]></category>
		<category><![CDATA[beamer]]></category>
		<category><![CDATA[latex]]></category>

		<guid isPermaLink="false">http://www.woggie.net/?p=44</guid>
		<description><![CDATA[I&#8217;ve recently started using the beamer class to create slides for my presentation. Up till now, I&#8217;ve been using powerdot, and found it more than sufficient. I initially thought beamer to be far more complex than necessary. However, one feature convinced me to switch: PDFTeX and XeTeX support. Both PDFTeX and XeTeX create a PDF [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently started using the beamer class to create slides for my presentation. Up till now, I&#8217;ve been using powerdot, and found it more than sufficient. I initially thought beamer to be far more complex than necessary. However, one feature convinced me to switch: PDFTeX and XeTeX support.</p>
<p>Both PDFTeX and XeTeX create a PDF directly from the LaTeX source. XeTeX is built on PDFTeX, and is of particular interest since it has added support for TrueType and OpenType fonts. For beamer presentations, this was <em>great</em>, since it opens up a huge selection of fonts for use in presentations. To change the default font in the document with XeTeX, use the <code>fontspec</code> package. The <code>xunicode</code> package provides additional mapping between LaTeX accents and the selected font. A third package, <code>xltxtra</code> provides some fixes relating to fonts.</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">documentclass</span></span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">xetex,mathserif,serif</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">beamer</span><span style="color: #E02020; ">}</span>
&nbsp;
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">fontspec</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">xunicode</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">%Unicode extras!</span>
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">xltxtra</span><span style="color: #E02020; ">}</span>  <span style="color: #2C922C; font-style: italic;">%Fixes</span>
<span style="color: #800000; font-weight: normal;">\setmainfont</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">Calibri</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\setmonofont</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">Scale=0.86</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">Andale Mono</span><span style="color: #E02020; ">}</span></pre></div></div>

<p>Of course, you should replace <code>Calibri</code> and <code>Andale Mono</code> with a font of your choice.</p>
<p>Another nice package to use with PDFTeX, is the <code>microtype</code> package, which provides better font output. Enable the package with this line:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">final,expansion=true,protrusion=true,spacing=true,kerning=true</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">microtype</span><span style="color: #E02020; ">}</span></pre></div></div>

<h3>XeTeX and PGF / TiKZ</h3>
<p>PGF / TiKZ is a TeX library for drawing graphics using the PDFTeX and XeTeX drivers. However, you may encounter the following error message when attempting to compile a presentation with PGF / TiKZ pictures in your Beamer slides:</p>
<pre>Package pgf Warning: Your graphic driver pgfsys-dvipdfm.def does not supported marking the current position.</pre>
<p>Unfortunately, the included TiKZ library in the TeXLive 2007 distribution does not support XeTeX. This causes cross-picture coordinates to break, which can be used to <a href="http://www.fauskes.net/pgftikzexamples/beamer-arrows/">draw arrows between various TiKZ pictures</a> in a Beamer frame.</p>
<p>While we wait for TeXLive 2008, you can install the <a href="http://www.ctan.org/tex-archive/help/Catalogue/entries/pgf.html">new version of PGF from the CTAN</a> which adds support for the XeTeX driver. Simply download the package, and copy the files to your local <code>~/texmf/tex/</code> directory and execute <code>texhash</code> to update the TeX listings.</p>
<h3>XeTeX and Wide Pages</h3>
<p>Although I haven&#8217;t had much time to investigate the issue, but it seems that the <code>pgfpages</code> package that is used with beamer, is not entirely compatible with XeTeX. In particular, the commands:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">pgfpages</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\setbeameroption</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">show notes on second screen</span><span style="color: #E02020; ">}</span>        <span style="color: #2C922C; font-style: italic;">%beamer</span>
<span style="color: #800000; font-weight: normal;">\pgfpagesuselayout</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">two screens with optional second</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">%pgfpages</span></pre></div></div>

<p>is enough to have <code>pdflatex</code> generate notes to the right of the slide, but on <code>xelatex</code> it doesn&#8217;t have any effect. <a href="http://www.tug.org/pipermail/xetex/2009-June/013325.html">This post by Tomáš Janoušek</a> to the XeTeX mailing list noted that the problem was due to a bug in the <code>pgfpages</code> package. Adding the following snippet fixes the probblem:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\renewcommand</span><span style="color: #800000; font-weight: normal;">\pgfsetupphysicalpagesizes</span><span style="color: #E02020; ">{</span><span style="color: #2C922C; font-style: italic;">%</span>
    <span style="color: #800000; font-weight: normal;">\pdfpagewidth</span><span style="color: #800000; font-weight: normal;">\pgfphysicalwidth</span><span style="color: #800000; font-weight: normal;">\pdfpageheight</span><span style="color: #800000; font-weight: normal;">\pgfphysicalheight</span><span style="color: #2C922C; font-style: italic;">%</span>
<span style="color: #E02020; ">}</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2008/07/16/beamer-pdftex-and-xetex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>fmp 0.7.0 Development Release</title>
		<link>http://www.woggie.net/2008/04/01/fmp-070-development-release/</link>
		<comments>http://www.woggie.net/2008/04/01/fmp-070-development-release/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 20:31:48 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[School]]></category>

		<guid isPermaLink="false">http://www.woggie.net/2008/04/01/fmp-070-development-release/</guid>
		<description><![CDATA[I&#8217;ve been doing some development on the feature modeling plug-in during the past week and have implemented several new features and bug fixes (shown below). I&#8217;m releasing the plug-in as a development release, for now. I have started rewriting the configuration backend, but my thesis deadline is fast approaching and I will not have enough [...]]]></description>
			<content:encoded><![CDATA[<p class="bordered" align="center"><a title="fmp 0.7.0 Screenshot" href="http://www.woggie.net/wp-content/uploads/2008/04/fmp-070.gif"><img class="imageframe imgalignleft" src="http://www.woggie.net/wp-content/uploads/2008/04/fmp-070.gif" alt="fmp 0.7.0 Screenshot" width="650" height="210" /></a></p>
<p>I&#8217;ve been doing some development on the <a href="http://gsd.uwaterloo.ca/projects/fmp-plugin">feature modeling plug-in</a> during the past week and have implemented several new features and bug fixes (shown below).</p>
<p>I&#8217;m releasing the plug-in as a <em>development release</em>, for now. I have started rewriting the configuration backend, but my thesis deadline is fast approaching and I will not have enough time to complete the changes in <em>fmp</em>. In any case, please let me know of any bugs you find, or if you have a feature request. The source code is also included in the plug-in, so feel free to hack away at it yourself if you are inclined. When the plug-in is sufficiently tested, I will merge this branch into the trunk of the CVS repository on SourceForge. Give it a try!</p>
<h4>New Features</h4>
<ul>
<li>New, more robust and featureful constraint view.</li>
<li>Constraints are shown for the feature hierarchy in addition to additional constraints.</li>
<li>When a configuration is selected in the feature model editor, the constraints are evaluated and the status of each constraint is shown (ie. satisfied or not satisfied).</li>
<li>Support for arbitrary propositional formulas when writing additional constraints. <strong>NOTE:</strong> constraints are written using node Id instead of an XPath expression. However, feature models created using fmp 0.6.6 are compatible, but will require re-writing the constraints using the new grammar. See below for examples.</li>
<li>Ability to view Node Ids next to feature names in the feature model.</li>
<li>Constraint input validation.</li>
<li>Constraint resolution. An unsatisfied constraint can be resolved in a configuration by right-clicking and selecting ‘Resolve Constraint’.</li>
</ul>
<h4>Installation</h4>
<ul>
<li>Download <a href="http://gsd.uwaterloo.ca/%7Eshshe/ca.uwaterloo.gp.fmp_0.7.0.jar">ca.uwaterloo.gp.fmp_0.7.0.jar</a></li>
<li>Compiled for Java 5 (Java 6 compatible), Eclipse 3.2</li>
</ul>
<p>Project Homepage: <a href="http://gsd.uwaterloo.ca/projects/fmp-plugin/fmp-070/">http://gsd.uwaterloo.ca/projects/fmp-plugin/fmp-070/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2008/04/01/fmp-070-development-release/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Loading an Ecore model without initializing all necessary packages or schemas</title>
		<link>http://www.woggie.net/2008/03/29/loading-an-ecore-model-without-initializing-all-necessary-packages-or-schemas/</link>
		<comments>http://www.woggie.net/2008/03/29/loading-an-ecore-model-without-initializing-all-necessary-packages-or-schemas/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 17:57:26 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ecore]]></category>
		<category><![CDATA[emf]]></category>
		<category><![CDATA[serialization]]></category>

		<guid isPermaLink="false">http://www.woggie.net/2008/03/29/loading-an-ecore-model-without-initializing-all-necessary-packages-or-schemas/</guid>
		<description><![CDATA[Here&#8217;s a small snippet of code to load an Ecore resource without having to initialize all the necessary packages needed to read all elements. This is useful if we&#8217;re interested in only a subset of the schema elements that are present in the Ecore model. public static EList open&#40;File file&#41; throws IOException &#123; ResourceSet resourceSet [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a small snippet of code to load an Ecore resource without having to initialize all the necessary packages needed to read all elements. This is useful if we&#8217;re interested in only a subset of the schema elements that are present in the Ecore model.</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> EList open<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">File</span> file<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399; font-weight: bold;">IOException</span> <span style="color: #009900;">&#123;</span>
	ResourceSet resourceSet = <span style="color: #000000; font-weight: bold;">new</span> ResourceSetImpl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Initialize the FSML Package information (ie. URI)</span>
	MyPackageImpl.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Set OPTION_RECORD_UNKNOWN_FEATURE prior to calling getResource</span>
	Resource.<span style="color: #006633;">Factory</span>.<span style="color: #003399; font-weight: bold;">Registry</span>.<span style="color: #006633;">INSTANCE</span>.<span style="color: #006633;">getExtensionToFactoryMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">&quot;*&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> EcoreResourceFactoryImpl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			@<span style="color: #003399; font-weight: bold;">Override</span>
			<span style="color: #000000; font-weight: bold;">public</span> Resource createResource<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">URI</span> uri<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			XMIResourceImpl resource = <span style="color: #009900;">&#40;</span>XMIResourceImpl<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">createResource</span><span style="color: #009900;">&#40;</span>uri<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			resource.<span style="color: #006633;">getDefaultLoadOptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>XMLResource.<span style="color: #006633;">OPTION_RECORD_UNKNOWN_FEATURE</span>, <span style="color: #003399; font-weight: bold;">Boolean</span>.<span style="color: #006633;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">return</span> resource<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	XMIResource resource = <span style="color: #009900;">&#40;</span>XMIResource<span style="color: #009900;">&#41;</span> resourceSet.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span>
	<span style="color: #003399; font-weight: bold;">URI</span>.<span style="color: #006633;">createFileURI</span><span style="color: #009900;">&#40;</span>file.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>,
	<span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Unknown elements will appear in this map</span>
	<span style="color: #003399; font-weight: bold;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>resource.<span style="color: #006633;">getEObjectToExtensionMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	resource.<span style="color: #006633;">load</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">Collections</span>.<span style="color: #006633;">EMPTY_MAP</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">return</span> resource.<span style="color: #006633;">getContents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Be aware that any unrecognized elements will be null in the retrieved Ecore model.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2008/03/29/loading-an-ecore-model-without-initializing-all-necessary-packages-or-schemas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RDF API for PHP 0.9.5: Bug with ResResource and ResModel::find</title>
		<link>http://www.woggie.net/2007/07/19/rdf-api-for-php-095-bug-with-resresource-and-resmodelfind/</link>
		<comments>http://www.woggie.net/2007/07/19/rdf-api-for-php-095-bug-with-resresource-and-resmodelfind/#comments</comments>
		<pubDate>Fri, 20 Jul 2007 01:21:49 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.woggie.net/2007/07/19/rdf-api-for-php-bug-with-resresource-and/</guid>
		<description><![CDATA[I ran into a problem when using the statement-centric find(&#8230;) query using the OntModel with the RDF Vocabulary. The specified RDF resources were treated like NULL in the find function. In order to fix this, create a ResProperty instead of a ResResource, and all will be well. This can be done like so: $rest = [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a problem when using the statement-centric find(&#8230;) query using the OntModel with the RDF Vocabulary. The specified RDF resources were treated like NULL in the find function. In order to fix this, create a ResProperty instead of a ResResource, and all will be well. This can be done like so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$rest</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>ontModel<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>find<span style="color: #009900;">&#40;</span><span style="color: #000088;">$statement</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">new</span> ResProperty<span style="color: #009900;">&#40;</span>RDF_NAMESPACE_URI <span style="color: #339933;">.</span> <span style="color: #0000ff;">'rest'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h4>References</h4>
<p>My open source contribution, a bug report <img src='http://www.woggie.net/wp-content/plugins/tango-smilies/tango/face-smile.png' alt=':)' class='wp-smiley' />  : <a href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1757224&amp;group_id=63257&amp;atid=503361">ResResource as parameter for ResModel::find does not work</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2007/07/19/rdf-api-for-php-095-bug-with-resresource-and-resmodelfind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customizing EMF XML Serialization</title>
		<link>http://www.woggie.net/2007/07/17/customizing-emf-xml-serialization/</link>
		<comments>http://www.woggie.net/2007/07/17/customizing-emf-xml-serialization/#comments</comments>
		<pubDate>Wed, 18 Jul 2007 03:27:43 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.woggie.net/2007/07/17/customizing-xml-serialization-using-emf/</guid>
		<description><![CDATA[It&#8217;s unfortunately that much documentation on the Eclipse Modeling Framework (EMF) is scattered around the &#8216;net. After digging through the EMF newsgroups (which are immensely useful, and full of useful information!) and several articles, I pieced together how XML serialization of an Ecore model can be customized using ExtendedMetaData EAnnotations. However, when saving the model [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s unfortunately that much documentation on the Eclipse Modeling Framework (EMF) is scattered around the &#8216;net. After digging through the EMF newsgroups (which are immensely useful, and full of useful information!) and several articles, I pieced together how XML serialization of an Ecore model can be customized using ExtendedMetaData EAnnotations.</p>
<p style="text-align: center"><img src="http://www.woggie.net/wp-content/uploads/2007/07/emf-extendedmetadata.gif" alt="EMF ExtendedMetaData Screenshot" /></p>
<p>However, when saving the model the <code>XMLResource.OPTION_EXTENDED_META_DATA</code> option must be set to true in order for the EAnnotations to be effective. To do this:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #003399; font-weight: bold;">Map</span> options = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">HashMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>options.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>XMLResource.<span style="color: #006633;">OPTION_EXTENDED_META_DATA</span>, <span style="color: #003399; font-weight: bold;">Boolean</span>.<span style="color: #006633;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
options.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>XMLResource.<span style="color: #006633;">OPTION_XML_MAP</span>, xmlMap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Finally, saving the model with the specified XML resource options:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;">resource.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Save with the options map</span></pre></div></div>

<h4>References</h4>
<ul>
<li><a href="http://www.devx.com/Java/Article/29093/0/page/3">Discover the Eclipse Modeling Framework (EMF) and Its Dynamic Capabilities [devx.com]</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2007/07/17/customizing-emf-xml-serialization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turn off caching on the PHP SOAP extension</title>
		<link>http://www.woggie.net/2007/07/17/turn-off-caching-for-php-soap-extension/</link>
		<comments>http://www.woggie.net/2007/07/17/turn-off-caching-for-php-soap-extension/#comments</comments>
		<pubDate>Tue, 17 Jul 2007 18:54:55 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.woggie.net/2007/07/17/turn-off-caching-for-php-soap-extension/</guid>
		<description><![CDATA[WSDL not being updated from your PHP SOAP app? After struggling for three hours trying to figure out what was wrong with my web service, it turned out that the WSDL was being cached by the PHP SOAP extension. To disable WSDL caching, add the following lines to the php.ini configuration file: [soap] soap.wsdl_cache_enabled = [...]]]></description>
			<content:encoded><![CDATA[<p>WSDL not being updated from your PHP SOAP app?</p>
<p>After struggling for three hours trying to figure out what was wrong with my web service, it turned out that the WSDL was being cached by the PHP SOAP extension. To disable WSDL caching, add the following lines to the php.ini configuration file:</p>
<pre>[soap]
soap.wsdl_cache_enabled = "0"</pre>
<p>You should also delete the cached WSDL (located in /tmp/ for me).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2007/07/17/turn-off-caching-for-php-soap-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The new woggie.net</title>
		<link>http://www.woggie.net/2007/07/08/hello-world/</link>
		<comments>http://www.woggie.net/2007/07/08/hello-world/#comments</comments>
		<pubDate>Sun, 08 Jul 2007 06:30:37 +0000</pubDate>
		<dc:creator>Steven She</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Site]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Welcome to the new woggie.net. I will be adding more content in the future, so stay tuned! Update: I started transferring some of the Linux guides from my old site, but found that many of them were outdated and obsolete. It&#8217;s great to find that a lot of things just work now with most Linux [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to the new woggie.net. I will be adding more content in the future, so stay tuned!</p>
<p>Update: I started transferring some of the Linux guides from my old site, but found that many of them were outdated and obsolete. It&#8217;s great to find that a lot of things <em>just work</em> now with most Linux distributions <img src='http://www.woggie.net/wp-content/plugins/tango-smilies/tango/face-smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.woggie.net/2007/07/08/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
