utahnlp / madlibs Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
The following test fails
def test_multiple_dependents_failure():
fillers = {
"person": [
{"name": "Jack", "pronoun": "he", "noun": "man"},
{"name": "Jill", "pronoun": "she", "noun": "woman"},
],
"place": [
{"location": "New York", "pronoun": "it"},
{"location": "Chicago", "pronoun": "it"},
],
}
template = '{{name}} {{p | type("pronoun")}} {{noun}} {{p}}'
pytest.raises(Exception):
m = MadLibTemplate(template, fillers)
The expected behavior is that there should be confusion with which pronoun
is to be used. But the template is created with the assumption that the first pronoun is used. This may be okay, but unsatisfactory and can lead to silent bugs downstream.
Maybe one way to get around this is to allow for types to be specified using fully qualified names like:
'{{person.name}} {{p | type("person.pronoun")}} {{person.noun}} {{p}}'
This will remove all ambiguity about which pronoun we are talking about.
The following test fails:
def test_dependent_variables():
fillers = {
"person": [
{"name": "Jack", "pronoun": "he", "noun": "man"},
{"name": "Jill", "pronoun": "she", "noun": "woman"},
],
"location": ["New York", "Chicago"],
}
template = '{{name}} {{p | type("pronoun")}} {{noun}} {{p}}'
m = MadLibTemplate(template, fillers)
generated = m.render({"name": "Jack", "pronoun": "he", "noun": "man"})
assert generated == "Jack he man he"
The expected behavior is that the variable p
in the template should be reused, but the template creation fails with an Exception: Unknown domain for p
, probably because there is so much hard coding in how variables for dependent domains are handled.
Right now, there is no documentation that explains how to use madlibs
, either as an API or as a tool
Allow constraints in templates that include numeric comparison. Here is an example template:
{
"s1": "{{person}} is {{n | range(5, 50, 5)}} years old.",
"s2": "{{person}} is less than {{m | range(6, 51, 5) | less_than(n, m)}} years old."
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.