Javascript filler functions



I am trying to understand how argument structure options get filled in on the website:

I need to add other options there and so I need to figure out how.

I am having trouble finding the appropriate place in the code to mock a call to in order to look at things in the debugger, so I’d greatly appreciate pointers.

I think I need to be modifying this function in matrix.js (possibly eventually separating case from arg-structure, or adding a separate similar function and leaving this alone):

// fill_case_patterns()
// Return items from either array morph_case_patterns or verb_case_patterns, as
// determined by the morph argument.
function fill_case_patterns(morph)
var items = new Array();
var pats = (morph) ? morph_case_patterns : verb_case_patterns;
for (var i = 0; i < pats.length; i++) {
var p = pats[i].split(’:’);
items.push([p[1], p[0]]);
// add clausal complement strategies as possible argument structure
return items

However, I do not understand how it is getting called. Its alias in is “fillverbpat”, and that occurs exactly once, on the Lexicon subpage in matrixdef:

Select valence “Verb {i} arguments” "

Argument structure: " “


So, I am assuming that’s how it gets called?

But in any case, right now it is a mystery to me how the function works. It relies, apparently, on a variable called verb_case_patterns, but where is this variable set? It does not get passed to the function; is it a global of some sort? The only other mention of it I think is this, in

var verb_case_patterns = [

– and that is within a script. So I am assuming this script calls javascript somehow, but what does actually happen? What is verb_case_patterns set to and where, and how to modify it or add something similar?


OK, I think I know how this works now.

This part:

var verb_case_patterns = [

means verb_case_patterns belongs to the embedding script (which I can’t post here since the forum does not like it :slight_smile: ). The script is called HTML_posttitle.

Here’s where it gets called:

  print HTML_posttitle % \
         js_array([c for c in choices.patterns() if not c[2]]),
         js_array([n for n in choices.numbers()]))

So, verb_case_patterns is filled as the second argument above. Therefore, it gets filled bythe choices.patters() function.


That looks like it makes sense!