<div dir="ltr">I wound up putting the project I needed this for on hold for a little while, but have just recently been trying to get this working -- in particular, the approach involving checking for p-tokens with the same vertices in the chart as the candidate token and then using this token if the orthography differs from that of the candidate token.<div>

<br></div><div>I&#39;ve discovered two gotchas with this approach. One is when the candidate token is not actually downcased so just checking for differences in orthography will match with downcased p-tokens. (Apparently some tokens in the derivation are not downcased for whatever reason -- the second word in a two word all-capitalized proper name is one example I noticed). I solved this by downcasing the token myself before doing the comparison. </div>

<div><br></div><div>The second is that unfortunately it seems capitalization is not always preserved in the p-tokens. Some sentence initial tokens in particular only seem to have all lower case characters.  This one from DeepBank&#39;s 20003004 (wsj00a) for instance where the i-input began with &#39;Although&#39;:</div>

<div><div><br></div><div>(407, 0, 1, &lt;0:8&gt;, 1, &quot;although&quot;, 0, &quot;null&quot;) (324, 1, 2, &lt;9:20&gt;, 1, &quot;preliminary&quot;, 0, &quot;null&quot;) (391, 1, 2, &lt;9:20&gt;, 1, &quot;preliminary&quot;, 0, &quot;null&quot;, &quot;JJ&quot; 1.0000) (326, 2, 3, &lt;21:29&gt;, 1, &quot;findings&quot;, 0, &quot;null&quot;) (392, 2, 3, &lt;21:29&gt;, 1, &quot;findings&quot;, 0, &quot;null&quot;, &quot;NNS&quot; 1.0000) (328, 3, 4, &lt;30:34&gt;, 1, &quot;were&quot;, 0, &quot;null&quot;) (393, 3, 4, &lt;30:34&gt;, 1, &quot;were&quot;, 0, &quot;null&quot;, &quot;VBD&quot; 1.0000) (365, 4, 5, &lt;35:43&gt;, 1, &quot;reported&quot;, 0, &quot;null&quot;) (382, 4, 5, &lt;35:43&gt;, 1, &quot;reported&quot;, 0, &quot;null&quot;, &quot;VBN&quot; 0.9416) .......</div>

</div><div><br></div><div>Unless there are more gotchas I haven&#39;t noticed, this is pretty close so maybe close enough is good enough (or I could just fudge it and uppercase the first token). But if anyone has any further ideas regarding improving this approach, they would be most welcome. </div>
<div><br></div><div><br></div><div>Cheers,</div><div>Ned</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 13, 2014 at 6:16 PM, Ned Letcher <span dir="ltr">&lt;<a href="mailto:nletcher@gmail.com" target="_blank">nletcher@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks everyone for the suggestions and input; it&#39;s been most helpful. I think that in my current setup it would be easier if I didn&#39;t have to invoke a separate tool, so it sounds like Angelina&#39;s approach of using the internal tokens and then comparing with the orthography of the tokens in the chart that occupy the same position --  while still somewhat fiddly -- might be the way to go. <div>




<br></div><div>Ned</div><div class="gmail_extra"><div><div><br><br><div class="gmail_quote">On Thu, Feb 6, 2014 at 8:41 PM, Stephan Oepen <span dir="ltr">&lt;<a href="mailto:oe@ifi.uio.no" target="_blank">oe@ifi.uio.no</a>&gt;</span> wrote:<br>




<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">indeed, following PTB conventions, the splitting of &#39;constraint-based&#39; or &#39;1/2&#39; happens in token mapping, and hence i believe working off internal tokens (where there is a one-to-one correspondence to leaf nodes of the derivation) should be less fiddly.  recovering capitalization, i think is the only challenge at this level, and looking in the same chart cell for another token that was not downcased (as angelina does) seems relative straightforward to me.</p>






<p dir="ltr">ned, i forgot: you could also just use the dependency converter, to obtain a token sequence corresponding to the derivation leafs. a little round-about but probably easy to pull off.  interested in instructions?</p>






<p dir="ltr">oe</p><div><div>
<div class="gmail_quote">On Feb 6, 2014 9:33 AM, &quot;Woodley Packard&quot; &lt;<a href="mailto:sweaglesw@sweaglesw.org" target="_blank">sweaglesw@sweaglesw.org</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div style="word-wrap:break-word"><div>You&#39;re right Bec that I overlooked the question of where to put spaces.  My suggestion also doesn&#39;t work for cases where the p-input tokens get split in half by token mapping (e.g. &quot;the blue-colored dog&quot;).  I believe both problems are solvable, but it starts to get fiddly.  Probably best to scratch that idea.</div>





<div><br></div><div>Woodley</div><br><div><div>On Feb 6, 2014, at 12:10 AM, Bec Dridan &lt;<a href="mailto:bec.dridan@gmail.com" target="_blank">bec.dridan@gmail.com</a>&gt; wrote:</div><br><blockquote type="cite"><div dir="ltr">





<div><div>Concatenating the p-input tokens will mostly get you what you want. I think you might run in to issues with leaves with spaces though, if you always concatenate. You&#39;ll need some extra checking of the span between tokens, possibly just the immediately adjacent characters.  I can still imagine some combinations of wiki mark up, punctuation and words-with-spaces that will cause problems, but I believe they would be rare.<br>






<br></div>I still think it could be useful to not downcase at the end of token mapping, but just at the time of lexicon lookup. It wouldn&#39;t solve all these problems, but it would retain useful information in a more accessible way.<br>






<br></div>bec<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 6, 2014 at 6:56 AM, Woodley Packard <span dir="ltr">&lt;<a href="mailto:sweaglesw@sweaglesw.org" target="_blank">sweaglesw@sweaglesw.org</a>&gt;</span> wrote:<br>






<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi Ned and Stephan,</div><div><br></div><div>Actually, I think you may want to look at the p-input field of the parse relation.  These are the tokens that come out of REPP, i.e. the input to token mapping.  There is no ambiguity at this point, the bad characters are already removed, and case is preserved.  What I would suggest is to concatenate the strings of all tokens contained in the character offset you got from the derivation tree.</div>






<div><br></div><div>In the case of the example you referenced, the p-input field contains (among other tokens) the following:</div><div><br></div><div>(21, 20, 21, &lt;137:144&gt;, 1, &quot;control&quot;, 0, &quot;null&quot;, &quot;NN&quot; 1.0000)</div>






<div>(22, 21, 22, &lt;146:147&gt;, 1, &quot;,&quot;, 0, &quot;null&quot;, &quot;,&quot; 1.0000)</div><div><br></div><div>All this headache is brought about by the extra wiki markup embedded in the input string, which IMHO is not English.  If you put English in, taking the substring directly out of the input string will give you something more worth looking at :-)</div>






<span><font color="#888888"><div><br></div><div>-Woodley</div></font></span><div><div><br><div><div>On Feb 5, 2014, at 9:21 PM, Ned Letcher &lt;<a href="mailto:nletcher@gmail.com" target="_blank">nletcher@gmail.com</a>&gt; wrote:</div>






<br><blockquote type="cite"><div dir="ltr">What Woodley described is I think what&#39;s going on. It looks like the START/END offsets returned by the lkb:repp call are different to that of the +FROM/+TO offsets found in the derivation. The derivation I&#39;m using is from the gold tree in the logon repository: i-id 10032820 in $LOGONROOT/lingo/erg/tsdb/gold/ws01/result.gz. (also, for some reason I just get NIL when I try to evaluate that repp function call in my lisp buffer after loading logon)<div>









<br></div><div>From comparing derivations and the relevant portions of the p-token field, it looks to me like using the +FORM feature of the has the same effect as extracting the string from the p-tokens field for the token that was ultimately used? But as you say, this still leaves the issue of the correct casing. Angelina&#39;s workaround is a good suggestion, but definitely feels like a hack. It seems like it would be desirable to be keeping track of the value of tokens after REPP normalization but before downcasing for lexicon lookup. I was talking about this with Bec also, and while her problem was slightly different in that she only needed features for ubertagging rather than the original surface form, she said she was also struggling with this limitation.</div>








<div><br></div><div>Ned</div><div><br></div><div><div>
<br></div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 6, 2014 at 11:26 AM, Woodley Packard <span dir="ltr">&lt;<a href="mailto:sweaglesw@sweaglesw.org" target="_blank">sweaglesw@sweaglesw.org</a>&gt;</span> wrote:<br>







<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I believe what happened in this particular case is that &quot;control&quot; and the following &quot;,&quot; punctuation token got combined, resulting in a contiguous CFROM/CTO span of 137 to 147, which includes not only &quot;control&quot; and &quot;,&quot; but also the deleted text in the middle.<br>








<span><font color="#888888"><br>
-Woodley<br>
</font></span><div><br>
On Feb 5, 2014, at 2:24 PM, Stephan Oepen &lt;<a href="mailto:oe@ifi.uio.no" target="_blank">oe@ifi.uio.no</a>&gt; wrote:<br>
<br>
&gt; hi ned,<br>
&gt;<br>
&gt; the practical challenge you are facing is deeply interesting.  i<br>
&gt; believe both angelina (in conversion to bi-lexical dependencies)<br>
&gt; and bec (working on ubertagging in PET) have looked at this.<br>
&gt;<br>
&gt; the derivation trees include the identifiers of internal tokens<br>
&gt; (an integer immediately preceding the token feature structure),<br>
&gt; and these tokens you can retrieve from the :p-tokens field in<br>
&gt; reasonably up-to-date [incr tsdb()] profiles.  this will give you<br>
&gt; the strings that were used for lexical lookup.  capitalization is<br>
&gt; lost at this point, more often than not, hence one needs to do<br>
&gt; something approximative in addition to finding the token.  for<br>
&gt; all i recall, angelina compares the actual token to others that<br>
&gt; have the same position in the chart (by start and end vertex,<br>
&gt; as recorded in the :p-tokens format); in case she finds one<br>
&gt; whose orthography differs from the downcased string, then<br>
&gt; she uses that token instead.  bec, on the other hand, i think<br>
&gt; consults the +CASE feature in the token feature structure.<br>
&gt;<br>
&gt; underlying all this, i suspect there is a question of what the<br>
&gt; characterization of initial tokens really should be, e.g. when<br>
&gt; we strip wiki markup at the REPP level.  but i seem unable<br>
&gt; to reproduce the particular example you give:<br>
&gt;<br>
&gt; TSNLP(88): (setf string<br>
&gt;             &quot;Artificial intelligence has successfully been used in a<br>
&gt; wide range of fields including [[medical diagnosis]], [[stock<br>
&gt; trading]], [[robot control]], [[law]], scientific discovery and<br>
&gt; toys.&quot;)<br>
&gt; &quot;Artificial intelligence has successfully been used in a wide range of<br>
&gt; fields including [[medical diagnosis]], [[stock trading]], [[robot<br>
&gt; control]], [[law]], scientific discovery and toys.&quot;<br>
&gt;<br>
&gt; TSNLP(89): (pprint (lkb::repp string :calls &#39;(:xml :wiki :lgt :ascii<br>
&gt; :quotes) :format :raw))<br>
&gt; ...<br>
&gt; #S(LKB::TOKEN :ID 20 :FORM &quot;control&quot; :STEM NIL :FROM 20 :TO 21 :START<br>
&gt; 137 :END 144 :TAGS NIL :ERSATZ NIL)<br>
&gt; ...<br>
&gt;<br>
&gt; TSNLP(90): (subseq string <a href="tel:137%20144" value="+61137144" target="_blank">137 144</a>)<br>
&gt; &quot;control&quot;<br>
&gt;<br>
&gt; i don&#39;t doubt the problem is real, but out of curiosity: how did<br>
&gt; you produce your derivations?<br>
&gt;<br>
&gt; all best, oe<br>
&gt;<br>
&gt; On Wed, Feb 5, 2014 at 5:02 AM, Ned Letcher &lt;<a href="mailto:nletcher@gmail.com" target="_blank">nletcher@gmail.com</a>&gt; wrote:<br>
&gt;&gt; Hi all,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m trying to export DELPH-IN derivation trees for use in the Fangorn<br>
&gt;&gt; treebank querying tool (which uses PTB style trees for importing) and have<br>
&gt;&gt; run into a hiccup extracting the string to use for the leaves of the trees.<br>
&gt;&gt; Fangorn does not support storing the original input string alongside the<br>
&gt;&gt; derivation, with the string used for displaying the original sentence being<br>
&gt;&gt; reconstructed by concatenating the leaves of the tree together.<br>
&gt;&gt;<br>
&gt;&gt; I&#39;ve been populating the leaves of the exported PTB tree by extracting the<br>
&gt;&gt; relevant slice of the i-input string using the +FROM +TO offsets in the<br>
&gt;&gt; token information (if token mapping was used). One case I&#39;ve found where<br>
&gt;&gt; this doesn&#39;t work so well (and there may be more), is where characters which<br>
&gt;&gt; have been stripped by REPP occur within a token, so these characters are<br>
&gt;&gt; then included in the slice. Wikipedia markup, for instance, results in these<br>
&gt;&gt; artefacts:<br>
&gt;&gt;<br>
&gt;&gt; &quot;Artificial intelligence has successfully been used in a wide range of<br>
&gt;&gt; fields including medical diagnosis]], stock trading]], robot control]],<br>
&gt;&gt; law]], scientific discovery and toys.&quot;<br>
&gt;&gt;<br>
&gt;&gt; I also tried using the value of the +FORM feature, but it seems that this<br>
&gt;&gt; doesn&#39;t always preserve the casing of the original input string.<br>
&gt;&gt;<br>
&gt;&gt; Does anyone have any ideas for combating this problem?<br>
&gt;&gt;<br>
&gt;&gt; Ned<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; <a href="http://nedned.net/" target="_blank">nedned.net</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
&gt; +++ Universitetet i Oslo (IFI); Boks 1080 Blindern; 0316 Oslo; <a href="tel:%28%2B47%29%202284%200125" value="+4722840125" target="_blank">(+47) 2284 0125</a><br>
&gt; +++    --- <a href="mailto:oe@ifi.uio.no" target="_blank">oe@ifi.uio.no</a>; <a href="mailto:stephan@oepen.net" target="_blank">stephan@oepen.net</a>; <a href="http://www.emmtee.net/oe/" target="_blank">http://www.emmtee.net/oe/</a> ---<br>







&gt; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
<br>
</div></blockquote></div><br><br clear="all"><div><br></div>-- <br><a href="http://nedned.net/" target="_blank">nedned.net</a>
</div>
</blockquote></div><br></div></div></div></blockquote></div><br></div>
</blockquote></div><br></div></blockquote></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span><font color="#888888">-- <br><a href="http://nedned.net" target="_blank">nedned.net</a>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><a href="http://nedned.net" target="_blank">nedned.net</a>
</div></div>