syntax-prosody-ot / main

A webapp for the syntax-prosody analyst working in Optimality Theory, with automated Gen, Con and Eval. Download build files from syntax-prosody-ot/build
https://spot.sites.ucsc.edu/
GNU General Public License v2.0
12 stars 2 forks source link

Make GENwithPermutation able to handle string input if stree is empty / null #554

Closed jbellik closed 3 years ago

jbellik commented 3 years ago

Wow. I see what you mean. I also tried it with GENwithPermutation({}, 'a b') and it gave me 248 structures back! Sheesh. You can see them if you do:

var x = GENwithPermutation({}, 'a b'); for(let i in x){ console.log(parenthesizeTree(x[i][1])); }

Here are the first few entries: {a (b)} VM549:2 {(a) b} VM549:2 {(a) (b)} VM549:2 {a b} VM549:2 {(a (b))} VM549:2 {((a) b)} VM549:2 {((a) (b))} VM549:2 {(a b)} VM549:2 { (a) b} VM549:2 { (a) (b)} VM549:2 { (a (b))} VM549:2 { ((a) b)} VM549:2 { ((a) (b))} { (a b)} VM549:2 {( ) a (b)} VM549:2 {( ) (a) b} VM549:2 {( ) (a) (b)} VM549:2 {( ) a b} VM549:2 {( ) (a (b))} VM549:2 {( ) ((a) b)} VM549:2 {( ) ((a) (b))} VM549:2 {( ) (a b)} VM549:2 { a (b)} VM549:2 {( (a)) b} VM549:2 {( (a)) (b)} VM549:2 {(( ) a) b} VM549:2 {(( ) a) (b)} VM549:2 {(( ) (a)) b} VM549:2 {(( ) (a)) (b)} VM549:2 {( a) b} VM549:2 {( a) (b)}

As you can see, it's weirdly adding spaces. I had a look at the code and it doesn't seem to be coping with the case where stree is an empty object. If you try it with a defined stree and no words, it seems to work fine: 288 candidates for a tree with three terminals and 16 candidates for a tree with 16 terminals. I haven't verified that those are correct but they are obviously a lot more in the correct ballpark. So a good thing to try would be to write some code to handle it if there are no leaf objects provided in the input (i.e., stree is an empty object), and only words (a string) has been provided. Simplest would be to throw an error if leaves is empty or if stree.id doesn't exist.

Also, some comments in the code specifying what the arguments to the function and its return value are would be good! Best of all would be if you could set up a proper test file for the components of GENwithPermutation (not for all the combinations with the various GEN options, I mean a test file that would primarily check that the reordering part was working). There is a skeletal test file here that you can start from: main/test/manual_testing/multi-clitic_test.html

On Mon, Feb 1, 2021 at 1:57 PM 3ddiehead notifications@github.com wrote:

If you run

GENwithPermutation({},'a b c');

it will return the massive array. This is in candidategenerator.js

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/syntax-prosody-ot/main/issues/448#issuecomment-771187003, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ROKXNHXMWBLWBHUMW7N3S44PWLANCNFSM4QT3EYMA .

--

-- Jennifer Bellik, PhD Post-doctoral researcher & lecturer UC Santa Cruz https://people.ucsc.edu/~jbellik/

Originally posted by @jbellik in https://github.com/syntax-prosody-ot/main/issues/448#issuecomment-771210395