Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complete function returns non-deterministic results #158

Open
Saibo-creator opened this issue Mar 22, 2023 · 0 comments
Open

complete function returns non-deterministic results #158

Saibo-creator opened this issue Mar 22, 2023 · 0 comments

Comments

@Saibo-creator
Copy link

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant