Git Product home page Git Product logo

Comments (12)

ringgaard avatar ringgaard commented on May 19, 2024

I am not sure what you mean by "frame id reset". Could you provide an example?

from sling.

Jimmy-Mcnulty avatar Jimmy-Mcnulty commented on May 19, 2024

from sling.

ringgaard avatar ringgaard commented on May 19, 2024

I assume you are doing this from Python. The "frame id" is just a reference that is added to anonymous frames so you can refer to them from other frames. These ids are generated by the frame serialization and is not a permanent part of the frame. The frames form a graph which you can traverse, and you can just compare the frames to see if they are the same (PyFrame supports "rich compare"). You don't need the ids for this.

from sling.

Jimmy-Mcnulty avatar Jimmy-Mcnulty commented on May 19, 2024

from sling.

ringgaard avatar ringgaard commented on May 19, 2024

The frames in a store basically form a graph so when you want to serialize some of these to text all the (anonymous) frames are numbered consecutively as they are output, and if there is a back pointer, it will just output a reference to the frame.

Here is a simple example of parsing some text and traversing the mentions and frames output:

import sling

parser = sling.Parser("local/sempar.flow")

n_isa = parser.commons['isa']
n_name = parser.commons['name']

while True:
  text = raw_input('Enter text: ')
  if text == 'quit': break;
  doc = parser.parse(text)

  print "Text:", doc.phrase(0, len(doc.tokens))

  for mention in doc.mentions:
    for e in mention.evokes():
      if n_name not in e:
        e.name = doc.phrase(mention.begin, mention.end)

  for mention in doc.mentions:
    print "mention", doc.phrase(mention.begin, mention.end)
    for e in mention.evokes():
      print "  evoke", e[n_isa].name, e
      for r,v in e:
        if 'description' in r:
          print "    role", r.description, v
  print

However, I am stil not sure what your problem is. Maybe you could provide an example of the problem you encounter.

from sling.

Jimmy-Mcnulty avatar Jimmy-Mcnulty commented on May 19, 2024

from sling.

ringgaard avatar ringgaard commented on May 19, 2024

A semantic frame can be viewed as a N-way relation between the role fillers. A (subject, predicate, object) triple is encoded as {:predicate subject: {...} object: {...}}.

from sling.

Jimmy-Mcnulty avatar Jimmy-Mcnulty commented on May 19, 2024

from sling.

ringgaard avatar ringgaard commented on May 19, 2024

The SLING output is a graph. The syntax is like JSON, but with a few extensions (see here).

Each frame is a node in the graph, and each frame slot is an edge in the graph. Here is a simple example of the SLING output from the parser:

{=#1 
  :/s/document
  /s/document/text: "John hit the ball with a bat."
  /s/document/tokens: [
    {=#2 /s/token/text: "John" }, 
    {=#3 /s/token/text: "hit" }, 
    {=#4 /s/token/text: "the"}, 
    {=#5 /s/token/text: "ball"}, 
    {=#6 /s/token/text: "with"}, 
    {=#7 /s/token/text: "a"}, 
    {=#8 /s/token/text: "bat"}, 
    {=#9 /s/token/text: "."}
  ]
  /s/document/mention: {=#10 
    :/s/phrase
    /s/phrase/begin: 0
    /s/phrase/evokes: {=#11 :/saft/person }
  }
  /s/document/mention: {=#12 
    :/s/phrase
    /s/phrase/begin: 1
    /s/phrase/evokes: {=#13 
      :/pb/hit-01
      /pb/arg0: #11
      /pb/arg1: {=#14 :/saft/consumer_good }
      /pb/argm-mnr: {=#15 :/saft/consumer_good  }
    }
  }
  /s/document/mention: {=#16 
    :/s/phrase
    /s/phrase/begin: 3
    /s/phrase/evokes: #14
  }
  /s/document/mention: {=#17 
    :/s/phrase
    /s/phrase/begin: 6
    /s/phrase/evokes: #15
  }
}

For example, frame 13 is a node in the graph:

{=#13 
  :/pb/hit-01
  /pb/arg0: #11
  /pb/arg1: {=#14 :/saft/consumer_good  }
  /pb/argm-mnr: {=#15  :/saft/consumer_good  }
}

The id if the frame is 13 (=#13) which can be used to refer to this frame from other frames. The type of the frame is the PropBank predicate hit.01 (:/pb/hit-01). The frame has three roles:

  • The /pb/arg0 role points to #11 (evoked by "John")
  • The /pb/arg1 role points to #14 (evoked by "ball")
  • The /pb/argm-mnr role points to #15 (evoked by "bat")

A SLING store is a semantic frame store, but this is basically equivalent to a graph. You can read and write frame graphs using the Python SLING API in either text or binary encoded form:

import sling
store = sling.Store()
f = store.parse("{...}")

from sling.

Jimmy-Mcnulty avatar Jimmy-Mcnulty commented on May 19, 2024

from sling.

ringgaard avatar ringgaard commented on May 19, 2024

We are planning to release version 2 of the semantic parser later this year, based on the caspar branch.

from sling.

Jimmy-Mcnulty avatar Jimmy-Mcnulty commented on May 19, 2024

from sling.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.