Skip to content

Commit

Permalink
Fixed python list error for test by gen
Browse files Browse the repository at this point in the history
  • Loading branch information
rosypen committed Jul 10, 2022
1 parent 5789533 commit 41c785d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions gmcs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,16 @@ def clean_tree(tree):
return re.sub(r'\("([^()]+)"\)', r'(@\1@)', tree).replace('"', '').replace('@', "'")


def remove_duplicates(list):
def remove_duplicates(input_list):
'''Takes an input list that has the form [[a1,b1],[a2,b2], ... [a{n}, b{n}]] ie. a list of pairs.
It removes any pair in the list where the "a" value appeared earlier in the list.
For example if a2 == a1 in the example list above then [a2, b2] would be removed from the list.
'''
new_list = []
while(list != []):
new_list.append(list[0])
list = list(filter((lambda x: x[0] != list[0][0]), list))
while(input_list != []):
new_list.append(input_list[0])
input_list = list(filter((lambda x: x[0] != input_list[0][0]), input_list))
return new_list

# Extract predications from the grammar
Expand Down

1 comment on commit 41c785d

@rosypen
Copy link
Owner Author

Choose a reason for hiding this comment

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

To provide more context here,

Currently when visiting the test by generation tab of the customization page there is a python error about list not being callable

Screen Shot 2022-07-09 at 11 37 08 PM

This is because it was confused about the variable list and the python built-in function list having the same name. I have fixed the generate.py in the repo and tested it in https://matrix.ling.washington.edu/test-by-gen/matrix.cgi

With this fix the page loads without errors

Screen Shot 2022-07-09 at 11 20 34 PM

However the generated sentences are still missing. Will fix that in the next update.

Also worth noting is this change does not yet affect the main customization page (https://matrix.ling.washington.edu/customize/matrix.cgi)

Please sign in to comment.