GrammaticalFramework/gf-core

complete function returns non-deterministic results

Saibo-creator opened this issue · 0 comments

Hello,
Today I noticed two wired behaviors while using complete function with GF.

The following code are executed with pyg==1.0

Strange Behavior Reproduction 1

Take this PGF file as example: https://listenmaa.fi/b/Foods.pgf

In python interpreter, run the following command line by line

import pgf
grammar = pgf.readPGF("Foods.pgf")
lang = grammar.languages["FoodsEng"]
x = lang.complete("that fish is very delicious")
print([t for t in x] )
# [(4.9416422843933105, 'very', 'Quality', 'Very'),
# (6.887552261352539, 'very', 'Quality', 'Very')]

# Do it again
x = lang.complete("that fish is very delicious")
print([t for t in x] )

# [(4.9416422843933105, 'very', 'Quality', 'Very'),
# (6.887552261352539, 'very', 'Quality', 'Very')]

# Do it again
x = lang.complete("that fish is very delicious")
print([t for t in x] )
# [(6.887552261352539, 'very', 'Quality', 'Very')]

# Do it again
x = lang.complete("that fish is very delicious")
print([t for t in x] )
# []

# Do it again
x = lang.complete("that fish is very delicious")
print([t for t in x] )
# [(6.887552261352539, 'very', 'Quality', 'Very')]

It seems the completion results change every time, and if I restart the python interpreter and do it again , it also changes.

Strange Behavior Reproduction 2

If I put the above code into a python script, say run.py and execute it with python interpreter.

The results will always be empty list;

[]
[]
[]
[]
[]

This seems to be deterministic, but it doesn't align with the above behavior.

How would you interpret these two behavior ?