Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #12 from Herb-AI/evaluate-on-program
Browse files Browse the repository at this point in the history
add `evaluate_on_program` based on program and grammar
  • Loading branch information
THinnerichs authored Aug 25, 2023
2 parents 6baff57 + 5869b16 commit 72c7115
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/interpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ function execute_on_examples(tab::SymbolTable, expr::Any, example_inputs::Vector
end


"""
evaluate_program(program::RuleNode, examples::Vector{<:Example}, grammar::Grammar, evaluation_function::Function)
Runs a program on the examples and returns tuples of actual desired output and the program's output
"""
function evaluate_program(program::RuleNode, examples::Vector{<:Example}, grammar::Grammar, evaluation_function::Function)
results = Tuple{<:Number,<:Number}[]
expression = rulenode2expr(program, grammar)
symbol_table = SymbolTable(grammar)
for example filter(e -> e isa IOExample, examples)
outcome = evaluation_function(symbol_table, expression, example.in)
push!(results, (example.out, outcome))
end
return results
end


"""
interpret(tab::SymbolTable, ex::Expr)
Expand Down

2 comments on commit 72c7115

@THinnerichs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/89706

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 72c7115c9e4d87c75ee21f838aadda231e31eabb
git push origin v0.1.0

Please sign in to comment.