Extracting typehierarchy with lgbtypes


#1

Hi all,

I am trying to extract the expanded hierarchy with the lgbtypes but I haven’t had much luck. I tried reading through the source files but they are a bit obscure. The output format could be a tdl, or hash table or whatever. My guess is this should be possible, given that the functions to parse and process the hierarchy are there…

Thanks a lot!


#2

There is a function lkb:output-types that may do what you want.

I have a patched version here that outputs them as xml:
https://github.com/fcbond/ltdb/blob/master/patch-lextypedb.lsp

I would like the opposite, output types without the glbs, if anyone
knows how to do that :-).


#3

This works, thanks! Btw, is there any way to run this as a script without having to click through the lkb interface?


#4

Glad to help!

take a look at: https://github.com/fcbond/ltdb/blob/master/make-ltdb.bash


#5

Perfect, thank you!


#6

I think this should be fairly easily doable with PyDelphin’s tdl module, since it does not compute glb types. You would use tdl.iterparse() to enumerate the objects in some top-level TDL file, then look for TypeDefinition events and extract the object’s identifier and supertypes in order to build the hierarchy, and look for FileInclude events to parse an included TDL file.


#7

Apologies for the late reply. The function that best matches your description is lkb::types-to-xml. It outputs only type names, including GLB types. E.g. (lkb::types-to-xml :file "myfile.txt")

<type name="*top*">
  <parents>
  </parents>
  <children>
    <type name="u"/>
    <type name="tree_node_label"/>
    <type name="tokens"/>
    <type name="token_trait"/>
    <type name="tnt_main"/>
    <type name="tnt"/>
    <type name="scratch"/>
    <type name="scp_pr"/>
    <type name="n"/>
    <type name="mrs_transfer_rule"/>
    <type name="hook_min"/>
    <type name="flags"/>
    <type name="chart_mapping_rule"/>
    <type name="*sort*"/>
    <type name="*avm*"/>
  </children>
</type>
<type name="sign_min">
  <parents>
    <type name="*avm*"/>
  </parents>
  <children>
    <type name="word_or_lexrule_min"/>
    <type name="sign"/>
  </children>
</type>
...

You could run this in a script, immediately after loading your grammar with read-script-file-aux.