Skip to content

Commit

Permalink
deploy: 68ce919
Browse files Browse the repository at this point in the history
  • Loading branch information
beckydvn committed Aug 17, 2023
1 parent 03f1a1c commit 264620e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
21 changes: 16 additions & 5 deletions _modules/plan4dial/for_generating/custom_actions/slot_fill.html
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,23 @@ <h1>Source code for plan4dial.for_generating.custom_actions.slot_fill</h1><div c
<span class="c1"># store the intent based on the refined combo.</span>
<span class="c1"># if we are only extracting one entity of multiple, use the intent for</span>
<span class="c1"># just that entity; otherwise use the &quot;overarching&quot; intent</span>
<span class="n">next_out</span><span class="p">[</span><span class="s2">&quot;intent&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">config_entities</span><span class="p">[</span><span class="nb">list</span><span class="p">(</span><span class="n">refined_combo</span><span class="o">.</span><span class="n">keys</span><span class="p">())[</span><span class="mi">0</span><span class="p">]][</span><span class="s2">&quot;single_slot_intent&quot;</span><span class="p">]</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">refined_combo</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">entities</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span>
<span class="k">else</span> <span class="n">overall_intent</span>
<span class="p">)</span>
<span class="n">outcome_name</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">entity</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">certainty</span><span class="si">}</span><span class="s2">-&quot;</span> <span class="k">for</span> <span class="n">entity</span><span class="p">,</span> <span class="n">certainty</span> <span class="ow">in</span> <span class="n">refined_combo</span><span class="o">.</span><span class="n">items</span><span class="p">()</span>
<span class="p">)[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">refined_combo</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">entities</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">single_slot_int</span> <span class="o">=</span> <span class="n">config_entities</span><span class="p">[</span><span class="nb">list</span><span class="p">(</span><span class="n">refined_combo</span><span class="o">.</span><span class="n">keys</span><span class="p">())[</span><span class="mi">0</span><span class="p">]][</span>
<span class="s2">&quot;single_slot_intent&quot;</span>
<span class="p">]</span>
<span class="k">if</span> <span class="nb">list</span><span class="p">(</span><span class="n">refined_combo</span><span class="o">.</span><span class="n">values</span><span class="p">())[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;maybe-found&quot;</span><span class="p">:</span>
<span class="n">next_out</span><span class="p">[</span><span class="s2">&quot;intent_cfg&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">single_slot_int</span><span class="si">}</span><span class="s2">__</span><span class="si">{</span><span class="n">outcome_name</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="n">next_out</span><span class="p">[</span><span class="s2">&quot;intent&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">single_slot_int</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># make intent name more specific to avoid duplicate intent names</span>
<span class="k">if</span> <span class="nb">list</span><span class="p">(</span><span class="n">refined_combo</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> <span class="o">!=</span> <span class="p">[</span>
<span class="s2">&quot;found&quot;</span> <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">entities</span><span class="p">))</span>
<span class="p">]:</span>
<span class="n">next_out</span><span class="p">[</span><span class="s2">&quot;intent_cfg&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">overall_intent</span><span class="si">}</span><span class="s2">__</span><span class="si">{</span><span class="n">outcome_name</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="n">next_out</span><span class="p">[</span><span class="s2">&quot;intent&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">overall_intent</span>
<span class="c1"># add the updates based on what&#39;s in this refined combo (again, ignoring</span>
<span class="c1"># what we didn&#39;t find)</span>
<span class="k">for</span> <span class="n">entity</span><span class="p">,</span> <span class="n">certainty</span> <span class="ow">in</span> <span class="n">refined_combo</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
Expand Down Expand Up @@ -433,6 +442,8 @@ <h1>Source code for plan4dial.for_generating.custom_actions.slot_fill</h1><div c
<span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;updates&quot;</span><span class="p">:</span> <span class="n">slot_unclear_updates</span><span class="p">,</span>
<span class="s2">&quot;intent&quot;</span><span class="p">:</span> <span class="n">config_entity</span><span class="p">[</span><span class="s2">&quot;single_slot_intent&quot;</span><span class="p">],</span>
<span class="s2">&quot;intent_cfg&quot;</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">config_entity</span><span class="p">[</span><span class="s1">&#39;single_slot_intent&#39;</span><span class="p">]</span><span class="si">}</span><span class="se">\</span>
<span class="s2">__</span><span class="si">{</span><span class="n">entity</span><span class="si">}</span><span class="s2">_maybe-found&quot;</span><span class="p">,</span>
<span class="p">}</span>
<span class="k">if</span> <span class="s2">&quot;fallback_message_variants&quot;</span> <span class="ow">in</span> <span class="n">config_entity</span><span class="p">:</span>
<span class="n">single_slot</span><span class="p">[</span><span class="s2">&quot;fallback_message_variants&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">config_entity</span><span class="p">[</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h1>Source code for plan4dial.for_generating.parsers.pddl_for_rollout</h1><div c
<span class="n">actions</span><span class="p">[</span><span class="n">act</span><span class="p">][</span><span class="s2">&quot;effect&quot;</span><span class="p">][</span><span class="n">out</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span>
<span class="n">get_update_fluents</span><span class="p">(</span>
<span class="n">configuration_data</span><span class="p">[</span><span class="s2">&quot;context_variables&quot;</span><span class="p">],</span> <span class="n">out</span><span class="p">[</span><span class="s2">&quot;updates&quot;</span><span class="p">]</span>
<span class="p">)</span>
<span class="p">)</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="n">act</span><span class="p">][</span><span class="s2">&quot;condition&quot;</span><span class="p">]))</span>
<span class="p">)</span>
<span class="c1"># return the actions, and initial state, and all fluents</span>
<span class="k">return</span> <span class="p">{</span>
Expand Down
10 changes: 7 additions & 3 deletions _modules/plan4dial/for_generating/parsers/pddl_parser.html
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,10 @@ <h1>Source code for plan4dial.for_generating.parsers.pddl_parser</h1><div class=
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">act_param</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">TAB</span><span class="si">}</span><span class="s2">(:action </span><span class="si">{</span><span class="n">act</span><span class="si">}</span><span class="se">\n</span><span class="si">{</span><span class="n">TAB</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">2</span><span class="si">}</span><span class="s2">:parameters()&quot;</span>

<span class="n">pre_fluents</span> <span class="o">=</span> <span class="n">get_precond_fluents</span><span class="p">(</span><span class="n">context_variables</span><span class="p">,</span> <span class="n">act_config</span><span class="p">[</span><span class="s2">&quot;condition&quot;</span><span class="p">])</span>
<span class="c1"># convert the preconditions</span>
<span class="n">precond</span> <span class="o">=</span> <span class="n">_fluents_to_pddl</span><span class="p">(</span>
<span class="n">fluents</span><span class="o">=</span><span class="n">get_precond_fluents</span><span class="p">(</span><span class="n">context_variables</span><span class="p">,</span> <span class="n">act_config</span><span class="p">[</span><span class="s2">&quot;condition&quot;</span><span class="p">]),</span>
<span class="n">pre_fluents</span><span class="p">,</span>
<span class="n">tabs</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
<span class="n">name_wrap</span><span class="o">=</span><span class="s2">&quot;:precondition&quot;</span><span class="p">,</span>
<span class="n">and_wrap</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
Expand All @@ -318,9 +319,12 @@ <h1>Source code for plan4dial.for_generating.parsers.pddl_parser</h1><div class=
<span class="k">for</span> <span class="n">out_config</span> <span class="ow">in</span> <span class="n">act_config</span><span class="p">[</span><span class="s2">&quot;effect&quot;</span><span class="p">][</span><span class="s2">&quot;outcomes&quot;</span><span class="p">]:</span>
<span class="k">if</span> <span class="s2">&quot;updates&quot;</span> <span class="ow">in</span> <span class="n">out_config</span><span class="p">:</span>
<span class="c1"># for each outcome, get the update fluents</span>
<span class="n">update_fluents</span> <span class="o">=</span> <span class="n">get_update_fluents</span><span class="p">(</span>
<span class="n">context_variables</span><span class="p">,</span> <span class="n">out_config</span><span class="p">[</span><span class="s2">&quot;updates&quot;</span><span class="p">]</span>
<span class="n">update_fluents</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span>
<span class="n">get_update_fluents</span><span class="p">(</span><span class="n">context_variables</span><span class="p">,</span> <span class="n">out_config</span><span class="p">[</span><span class="s2">&quot;updates&quot;</span><span class="p">])</span>
<span class="p">)</span>
<span class="c1"># we don&#39;t want to add fluents in the effect that are already</span>
<span class="c1"># in the precondition</span>
<span class="n">update_fluents</span> <span class="o">=</span> <span class="n">update_fluents</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="n">pre_fluents</span><span class="p">)</span>
<span class="c1"># add the outcome to the effect string</span>
<span class="n">effects</span> <span class="o">+=</span> <span class="n">_fluents_to_pddl</span><span class="p">(</span>
<span class="n">fluents</span><span class="o">=</span><span class="n">update_fluents</span><span class="p">,</span>
Expand Down
1 change: 1 addition & 0 deletions _static/pygments.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #E40000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #008400 } /* Generic.Inserted */
Expand Down

0 comments on commit 264620e

Please sign in to comment.