Comments (12)
I am not sure what you mean by "frame id reset". Could you provide an example?
from sling.
from sling.
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.
from sling.
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.
from sling.
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.
from sling.
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.
from sling.
We are planning to release version 2 of the semantic parser later this year, based on the caspar branch.
from sling.
from sling.
Related Issues (20)
- Wiki markup parsing is hard HOT 1
- Could the training data of 'caspar.flow' be released? HOT 2
- Open source projects using SLING?
- The caspar.flow appears to be un-trained HOT 9
- Problem converting Ontonotes corpus to SLING HOT 3
- Build Error: object of type 'ctx' has no field 'actions' HOT 2
- /data/wiki/templates-en.sling: No such file or directory HOT 4
- ImportError: No module named 'sling.pysling' HOT 3
- SLING for other languages HOT 1
- TypeError: 'ParserState' object is not iterable HOT 1
- Beyond 12 languages HOT 18
- SLING Frames - how can one retrieve multiple slot values? HOT 5
- What does "mapping.sling" do? HOT 4
- Training sling in Korean | How do I make a `.rec` file? HOT 4
- simple python example HOT 2
- SLING with many frames on a small dataset HOT 3
- Annotating data HOT 1
- Python API for the tokenizer HOT 5
- problem about "sling fuse_items" HOT 2
- Error: No kernel supports step features/GatherSum HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sling.