mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
resource-api demo
This commit is contained in:
947
demos/resource-api/code.js
Normal file
947
demos/resource-api/code.js
Normal file
@@ -0,0 +1,947 @@
|
||||
|
||||
//Variable and Constant definitions
|
||||
|
||||
var expColImg = new Array(2);
|
||||
expColImg[0] = new Image(12,12);
|
||||
expColImg[0].src = "minus.png";
|
||||
expColImg[1] = new Image(12,12);
|
||||
expColImg[1].src = "plus.png";
|
||||
|
||||
var selectedNode = "";
|
||||
var collapseBuffer = new Array();
|
||||
var abstractTree = new Fun ("?");
|
||||
|
||||
var navigationControlString = new Array();
|
||||
var undoArray = new Array();
|
||||
var redoArray = new Array();
|
||||
var clipBoard;
|
||||
var refPageCounter = 0;
|
||||
|
||||
var stringAbstractTree = undefined;
|
||||
|
||||
var myTree = treeFromAbstract(myAbstract.annotate(abstractTree, myAbstract.startcat), "0");
|
||||
|
||||
var keys = new Array();
|
||||
keys ["Z"] = function() { clickUndo('actUndo'); }
|
||||
keys ["Y"] = function() { clickRedo('actRedo'); }
|
||||
keys ["R"] = function() { clickRefine('actRefine'); };
|
||||
keys ["V"] = function() { clickPaste('actPaste'); };
|
||||
keys ["X"] = function() { clickCut('actCut'); };
|
||||
keys ["C"] = function() { clickCopy('actCopy'); };
|
||||
keys ["D"] = function() { clickDelete('actDelete'); };
|
||||
keys ["E"] = function() { clickReplace('actReplace'); };
|
||||
keys ["W"] = function() { clickWrap('actWrap'); };
|
||||
keys ["N"] = function() { clickRandomNode('actRandomNode'); };
|
||||
keys ["T"] = function() { clickRandomTree('actRandomTree'); };
|
||||
keys ["%"] = function() { leftArrowKey(); };
|
||||
keys ["&"] = function() { upDownArrowKey(-1); };
|
||||
keys ["'"] = function() { rightArrowKey(); };
|
||||
keys ["("] = function() { upDownArrowKey( 1); };
|
||||
keys ["27"] = function() { clickEsc(); };
|
||||
|
||||
function state(selectedNode, tree, collapseBuffer) {
|
||||
this.selectedNode = selectedNode;
|
||||
this.tree = myAbstract.copyTree(tree);
|
||||
this.collapseBuffer = collapseBuffer;
|
||||
return this;
|
||||
}
|
||||
|
||||
function treeNode(name, caption) {
|
||||
this.name = name;
|
||||
this.caption = caption;
|
||||
this.cat = "";
|
||||
this.children = new Array();
|
||||
this.collapsed = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
treeNode.prototype.addChild = function (i, c) {
|
||||
this.children[i] = c;
|
||||
}
|
||||
|
||||
treeNode.prototype.hasChildren = function() {
|
||||
return this.children.length;
|
||||
}
|
||||
|
||||
// Generates a tree from the abstract tree contained in the element "stringTree"
|
||||
function parseStringTree(elementToParse) {
|
||||
stringAbstractTree = elementToParse;
|
||||
abstractTree = myAbstract.parseTree(document.getElementById(elementToParse).value, myAbstract.startcat);
|
||||
myTree = treeFromAbstract(myAbstract.annotate(abstractTree, myAbstract.startcat), "0");
|
||||
nodeClick("0");
|
||||
}
|
||||
|
||||
// If a key is pressed and a function assigned to that key, calls the function
|
||||
function hotKeys(event) {
|
||||
event = (event) ? event : ((window.event) ? event : null);
|
||||
if (event) {
|
||||
var charCode = (event.charCode) ? event.charCode : ((event.which) ? event.which : event.keyCode);
|
||||
if (keys[String.fromCharCode(charCode).toUpperCase()] &&
|
||||
!event.ctrlKey && !event.altKey && !event.shiftKey && !event.metaKey) {
|
||||
keys[String.fromCharCode(charCode).toUpperCase()]();
|
||||
}
|
||||
else if (keys["" + charCode] &&
|
||||
!event.ctrlKey && !event.altKey && !event.shiftKey && !event.metaKey) {
|
||||
keys["" + charCode]();
|
||||
}
|
||||
else if (charCode >= "96" && charCode <= "105" &&
|
||||
!event.ctrlKey && !event.altKey && !event.shiftKey && !event.metaKey) {
|
||||
keys["" + (charCode - 96)]();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clears "numeric" hotkeys
|
||||
function clearHotKeys() {
|
||||
for (var key in keys) {
|
||||
if ((parseInt(key) + 1) && (key != "27")) { keys[key] = function() { }; }
|
||||
}
|
||||
}
|
||||
|
||||
// Action to be performed when the up/down arrow key is pressed
|
||||
function upDownArrowKey(pos) {
|
||||
var nodePos = getNavPos(selectedNode);
|
||||
if ((nodePos > 0 && pos < 0) || (nodePos < navigationControlString.length - 1 && pos > 0)) {
|
||||
nodeClick(navigationControlString[nodePos + pos]);
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the position of a given node in the navigationControlString
|
||||
function getNavPos(nodeName) {
|
||||
for (var i = 0, j = navigationControlString.length; i < j; i++) {
|
||||
if (navigationControlString[i] == nodeName) { return i; };
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Given a name and a tree, gets the node in the tree with that name
|
||||
function getNode(nodeName, node) {
|
||||
if (nodeName == node.name) {
|
||||
return node;
|
||||
}
|
||||
else {
|
||||
for (var i = 0, j = node.children.length; i < j; i++) {
|
||||
var found = getNode(nodeName, node.children[i]);
|
||||
if (found) { return found; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Action to be performed when the left arrow key is pressed
|
||||
function leftArrowKey() {
|
||||
var node = getNode(selectedNode, myTree);
|
||||
if (!node.collapsed && node.hasChildren()) {
|
||||
signClick(node.name, node.caption);
|
||||
}
|
||||
else {
|
||||
var parentNode = getParent(node.name, myTree);
|
||||
if (parentNode) { nodeClick(parentNode.name); }
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the parent of the selected node
|
||||
function getParent(nodeName, node) {
|
||||
if (node.name == nodeName) {
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
for (var i = 0, j = node.children.length; i < j; i++) {
|
||||
if (node.children[i].name == nodeName) { return node; }
|
||||
}
|
||||
for (var i = 0, j = node.children.length; i < j; i++) {
|
||||
var found = getParent(nodeName, node.children[i]);
|
||||
if (found) { return found; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Action to be performed when the right arrow key is pressed
|
||||
function rightArrowKey() {
|
||||
var node = getNode(selectedNode, myTree);
|
||||
if (node.collapsed) {
|
||||
signClick(node.name, node.caption);
|
||||
}
|
||||
else {
|
||||
var firstDescendant = getfirstDescendant(node);
|
||||
if (firstDescendant) {
|
||||
nodeClick(firstDescendant.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the first descendant child of a node
|
||||
function getfirstDescendant(node) {
|
||||
if (node.hasChildren() && !node.collapsed) { return node.children[0]; }
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Produces and displays an HTML representation of the tree
|
||||
function drawTree() {
|
||||
var frame = document.getElementById("absFrame");
|
||||
navigationControlString = new Array();
|
||||
frame.innerHTML = "<ul id='tree'>" + getTree(myTree, 0) + "</ul>";
|
||||
document.getElementById("link" + selectedNode).scrollIntoView(false);
|
||||
}
|
||||
|
||||
// Produces an HTML representation of the tree
|
||||
function getTree(tree, level) {
|
||||
navigationControlString[navigationControlString.length] = tree.name;
|
||||
var htmlTree = "";
|
||||
htmlTree += "<li>";
|
||||
if (tree.hasChildren()) {
|
||||
htmlTree += "<img class='tree-menu'";
|
||||
if (tree.collapsed) {
|
||||
htmlTree += " src='plus.png'";
|
||||
}
|
||||
else { htmlTree += " src='minus.png'"; }
|
||||
htmlTree += " onclick='signClick(\"" + tree.name + "\", \"" + tree.caption + "\")' />";
|
||||
}
|
||||
else {
|
||||
htmlTree += "<img class='tree-menu' src='empty.png' />";
|
||||
}
|
||||
htmlTree += "<a id='link" + tree.name + "'";
|
||||
if (document.getElementById("actRefine").className == "selected" ||
|
||||
document.getElementById("actReplace").className == "selected" ||
|
||||
document.getElementById("actWrap").className == "selected") {
|
||||
htmlTree += "class='treeGray' "; }
|
||||
else if (selectedNode == tree.name) { htmlTree += "class='treeSelected' "; }
|
||||
else { htmlTree += "class='tree' "; }
|
||||
htmlTree += "href='' onclick='nodeClick(\"" + tree.name + "\"); return false'>" + overl(tree.caption) +
|
||||
" : " + tree.cat + "</a></li><ul>";
|
||||
if (tree.hasChildren() && !tree.collapsed) {
|
||||
for (var i = 0, j = tree.children.length; i < j; i++) {
|
||||
htmlTree += getTree(tree.children[i], level + 1);
|
||||
}
|
||||
}
|
||||
htmlTree += "</ul>";
|
||||
return htmlTree;
|
||||
}
|
||||
|
||||
// Linearizes and displays the abstract tree
|
||||
function drawLinearizedFrame() {
|
||||
var frame = document.getElementById("conFrame");
|
||||
frame.innerHTML = getLinearizedFrame();
|
||||
}
|
||||
|
||||
// Linearizes the abstract tree and returns it in HTML form
|
||||
function getLinearizedFrame() {
|
||||
var linearizedFrame = "";
|
||||
for (var i = 0; i < myConcrete.length; i++) {
|
||||
// linearizedFrame += "<h4>" + myConcrete[i].concreteSyntaxName + "</h4>";
|
||||
linearizedFrame += "<p id='line" + myConcrete[i].concreteSyntaxName +"'>";
|
||||
var tokens = myConcrete[i].concreteSyntax.tagAndLinearize(abstractTree);
|
||||
for (var j = 0, k = tokens.length; j < k; j++) {
|
||||
linearizedFrame += createLinearized(tokens[j]);
|
||||
}
|
||||
linearizedFrame += "</p>";
|
||||
}
|
||||
linearizedFrame += abstractTree.printOverl();
|
||||
|
||||
return linearizedFrame;
|
||||
}
|
||||
|
||||
// Creates an HTML representation of a linearization of an abstract tree
|
||||
function createLinearized(token) {
|
||||
var node = getNode(token.tag, myTree);
|
||||
var linearized = "<span id='" + token.tag + "' class=";
|
||||
if (node.name.substr(0, selectedNode.length) == selectedNode) {
|
||||
linearized += "'selected'";
|
||||
}
|
||||
else {
|
||||
linearized += "'normal'";
|
||||
}
|
||||
if (token == "&-") { linearized += "<br />"; }
|
||||
else { linearized += " onclick='nodeClick(\"" + node.name + "\");'> " + token + " </span>"; }
|
||||
return linearized;
|
||||
}
|
||||
|
||||
// Expands/Collapses node
|
||||
function signClick(name, caption) {
|
||||
myTree = expandCollapse(myTree, name);
|
||||
nodeClick(name);
|
||||
}
|
||||
|
||||
// Sets the "collapsed" property of a given node
|
||||
function expandCollapse(node, name) {
|
||||
if (node.name == name) {
|
||||
if (wasCollapsed(node.name)) { removeFromCollapseBuffer(node.name); }
|
||||
else { collapseBuffer[collapseBuffer.length] = node.name; }
|
||||
node.collapsed ^= true;
|
||||
}
|
||||
else {
|
||||
for (var i = 0, j = node.children.length; i < j; i++) {
|
||||
expandCollapse(node.children[i], name);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
// Checks if a node was collapsed on the previous cycle
|
||||
function wasCollapsed(nodeName) {
|
||||
for (var i = 0, j = collapseBuffer.length; i < j; i++) {
|
||||
if (nodeName == collapseBuffer[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Removes a node from the collapseBuffer array
|
||||
function removeFromCollapseBuffer(nodeName) {
|
||||
var newBuffer = new Array();
|
||||
for (var i = 0, j = collapseBuffer.length; i < j; i++) {
|
||||
if (nodeName != collapseBuffer[i]) {
|
||||
newBuffer[newBuffer.length] = collapseBuffer[i];
|
||||
}
|
||||
}
|
||||
collapseBuffer = newBuffer;
|
||||
}
|
||||
|
||||
// Selects a node
|
||||
function nodeClick(name) {
|
||||
if ((document.getElementById("actRefine") && document.getElementById("actRefine").className == "selected") ||
|
||||
(document.getElementById("actReplace") && document.getElementById("actReplace").className == "selected") ||
|
||||
(document.getElementById("actWrap") && document.getElementById("actWrap").className == "selected")) {
|
||||
return; }
|
||||
selectedNode = name;
|
||||
if (stringAbstractTree) {
|
||||
document.getElementById(stringAbstractTree).value = abstractTree.show();
|
||||
}
|
||||
document.getElementById("actFrame").innerHTML = showActions();
|
||||
document.getElementById("refFrame").innerHTML = "";
|
||||
drawTree();
|
||||
drawLinearizedFrame();
|
||||
}
|
||||
|
||||
// Shows the available actions for a node
|
||||
function showActions(caption) {
|
||||
var node = getNode(selectedNode, myTree);
|
||||
var abstractNode = getNodeFromAbstract(abstractTree, node.name, "0");
|
||||
var actions = "<table class='action'>";
|
||||
if (undoArray.length) {
|
||||
actions += createAction("Undo", "action", "Undo", "Z"); }
|
||||
else { actions += createAction("Undo", "unavailable", "Undo", "Z"); };
|
||||
if (redoArray.length) {
|
||||
actions += createAction("Redo", "action", "Redo", "Y"); }
|
||||
else { actions += createAction("Redo", "unavailable", "Redo", "Y"); }
|
||||
if (node.caption == "?") {
|
||||
actions += createAction("Cut", "unavailable", "Cut", "X");
|
||||
actions += createAction("Copy", "unavailable", "Copy", "C");
|
||||
var AbsNodeType = abstractNode.type;
|
||||
if (clipBoard && (AbsNodeType == myAbstract.getCat(clipBoard.name))) {
|
||||
actions += createAction("Paste", "action", "Paste", "V");
|
||||
}
|
||||
else { actions += createAction("Paste", "unavailable", "Paste", "V"); }
|
||||
actions += createAction("Delete", "unavailable", "Delete", "D");
|
||||
actions += createAction("Refine", "action", "Refine", "R");
|
||||
actions += createAction("Replace", "unavailable", "Replace", "E");
|
||||
actions += createAction("Wrap", "unavailable", "Wrap", "W")
|
||||
}
|
||||
else if (node.caption) {
|
||||
actions += createAction("Cut", "action", "Cut", "X");
|
||||
actions += createAction("Copy", "action", "Copy", "C");
|
||||
actions += createAction("Paste", "unavailable", "Paste", "V");
|
||||
actions += createAction("Delete", "action", "Delete", "D");
|
||||
actions += createAction("Refine", "unavailable", "Refine", "R");
|
||||
actions += createAction("Replace", "action", "Replace", "E");
|
||||
actions += createAction("Wrap", "action", "Wrap", "W")
|
||||
}
|
||||
if (node && !abstractNode.isComplete()) {
|
||||
actions += createAction("RandomNode", "action", "Fill out the node at random", "N");
|
||||
}
|
||||
else {
|
||||
actions += createAction("RandomNode", "unavailable", "Fill out the node at random", "N");
|
||||
}
|
||||
if (!abstractTree.isComplete()) {
|
||||
actions += createAction("RandomTree", "action", "Fill out the tree at random", "T");
|
||||
}
|
||||
else {
|
||||
actions += createAction("RandomTree", "unavailable", "Fill out the tree at random", "T");
|
||||
}
|
||||
actions += "</table>";
|
||||
return actions;
|
||||
}
|
||||
|
||||
// Gets a node from the abstract tree
|
||||
function getNodeFromAbstract(absNode, route, currRoute) {
|
||||
if (route == currRoute) {
|
||||
return absNode;
|
||||
}
|
||||
else {
|
||||
for (var i = 0, j = absNode.args.length; i < j; i++) {
|
||||
var found = getNodeFromAbstract(absNode.args[i], route, currRoute + "-" + i);
|
||||
if (found) { return found }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Creates an action
|
||||
function createAction(actionName, className, caption, hotKey) {
|
||||
return "<tr id='act" + actionName + "' class='" + className +"' onclick='click" +
|
||||
actionName + "(\"act" + actionName + "\")'><td class='action'>" + caption +
|
||||
"</td><td class='hotKey'>(" + hotKey + ")</td></tr>";
|
||||
}
|
||||
|
||||
// When the "Refine" action is selected, gets the appropriate refinements for a node
|
||||
function clickRefine(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
highlightSelectedAction(actName);
|
||||
pushUndoClearRedo();
|
||||
if (selectedNode) {
|
||||
refPageCounter = 0;
|
||||
var node = getNodeFromAbstract(abstractTree, selectedNode, "0");
|
||||
if (node.type == "String") {
|
||||
var newType = prompt('Enter a String','String');
|
||||
if (!newType) { newType = "AutoString" }
|
||||
myAbstract.addType(newType,[], "String");
|
||||
for (var i = 0, j = myConcrete.length; i < j; i++) {
|
||||
myConcrete[i].concreteSyntax.addRule(newType, function(cs){ return new Arr(new Str(newType));});
|
||||
}
|
||||
node.name = newType;
|
||||
abstractTree = insertNode(abstractTree, selectedNode, "0", node);
|
||||
document.getElementById("actFrame").innerHTML = showActions();
|
||||
document.getElementById("refFrame").innerHTML = "";
|
||||
clearHotKeys();
|
||||
concludeAction();
|
||||
}
|
||||
else {
|
||||
document.getElementById("refFrame").innerHTML = showRefinements(selectedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the className of actName to "selected" and grays out the other selections
|
||||
function highlightSelectedAction(actName) {
|
||||
graySelections(actName);
|
||||
document.getElementById(actName).className = "selected";
|
||||
drawTree();
|
||||
}
|
||||
|
||||
// Grays out all actions except one
|
||||
function graySelections(except) {
|
||||
var refs = document.getElementById("actFrame").getElementsByTagName("tr");
|
||||
for (var i = 0, j = refs.length; i < j; i++) {
|
||||
if (refs[i].id != except) { refs[i].className = "closed"; }
|
||||
}
|
||||
}
|
||||
|
||||
// Pushes the abstract tree into the undo array and clears the redo array
|
||||
function pushUndoClearRedo() {
|
||||
undoArray.push(new state(selectedNode, abstractTree, collapseBuffer));
|
||||
redoArray.length = 0;
|
||||
}
|
||||
|
||||
// Gets the refinements to display
|
||||
function showRefinements(nodeName) {
|
||||
var refs = getAvailableRefinements(nodeName);
|
||||
var pages = 0;
|
||||
if (refs.length > 9) { pages = Math.floor(refs.length / 9); }
|
||||
var upperLimit;
|
||||
if (pages != refPageCounter) { upperLimit = (9 * refPageCounter) + 9; }
|
||||
else { upperLimit = refs.length; }
|
||||
var refinements = "<table class='refinement'>";
|
||||
var keyPos = 0;
|
||||
refinements += ref_wrapToHtml("ref", "genRefRandom", "refinement", "", keyPos, "Choose at random");
|
||||
keys["" + keyPos] = mkRefHotKey("genRefRandom");
|
||||
keyPos++;
|
||||
for (var i = (9 * refPageCounter), j = upperLimit; i < j; i++) {
|
||||
refinements += ref_wrapToHtml("ref", refs[i], "refinement", "", keyPos, "");
|
||||
keys["" + keyPos] = mkRefHotKey(refs[i]);
|
||||
keyPos++;
|
||||
}
|
||||
if (pages > refPageCounter) {
|
||||
refinements += ref_wrapNextRefsToHtml("nextRefs", "Next", "refinement", "+", "Next Refinements");
|
||||
keys["107"] = mkRefNextRefsHotKey("Next");
|
||||
}
|
||||
if (0 < refPageCounter) {
|
||||
refinements += ref_wrapNextRefsToHtml("nextRefs", "Previous", "refinement", "-", "Previous Refinements");
|
||||
keys["109"] = mkRefNextRefsHotKey("Previous");
|
||||
}
|
||||
refinements += "</table>";
|
||||
return refinements;
|
||||
}
|
||||
|
||||
// Gets the available refinements for a node
|
||||
function getAvailableRefinements(nodeName) {
|
||||
var node = getNodeFromAbstract(abstractTree, nodeName, "0");
|
||||
var metaType = node.type;
|
||||
var refinements = new Array();
|
||||
for (var fun in myAbstract.types) {
|
||||
if (myAbstract.types[fun].cat == metaType) {
|
||||
refinements[refinements.length] = fun;
|
||||
}
|
||||
}
|
||||
return refinements;
|
||||
}
|
||||
|
||||
// Creates an HTML representation of a Refinement/Wrap
|
||||
function ref_wrapToHtml(funct, name, className, arg, hotKeyPos, caption) {
|
||||
var ref_wrapHtml = "<tr id='" + funct + name + "' class=" + className + " onclick='" + funct +
|
||||
"Click(\"" + name + "\"" + arg + ")'><td class='" + className + "'>";
|
||||
if (caption) { ref_wrapHtml += caption; }
|
||||
else { ref_wrapHtml += overl(name) + " : " + refArgsToHtml(name) + myAbstract.getCat(name); }
|
||||
ref_wrapHtml += "</td><td class='hotKey'>(" + hotKeyPos + ")</td></tr>";
|
||||
return ref_wrapHtml
|
||||
}
|
||||
|
||||
|
||||
// Creates the function to be used by a "numeric" hot key
|
||||
function mkRefHotKey(refName) {
|
||||
return function() { if (document.getElementById("ref" + refName)) { refClick(refName); } }
|
||||
}
|
||||
|
||||
// Creates an HTML representation of a Refinement/Wrap
|
||||
function ref_wrapNextRefsToHtml(funct, name, className, hotKeyPos, caption) {
|
||||
var ref_wrapHtml = "<tr id='" + funct + name + "' class=" + className + " onclick='" + funct +
|
||||
"Click(\"" + name + "\")'><td class='" + className + "'>";
|
||||
ref_wrapHtml += caption;
|
||||
ref_wrapHtml += "</td><td class='hotKey'>(" + hotKeyPos + ")</td></tr>";
|
||||
return ref_wrapHtml
|
||||
}
|
||||
|
||||
// Creates the function to be used by a "+" hot key
|
||||
function mkRefNextRefsHotKey(refName) {
|
||||
return function() { if (document.getElementById("nextRefs" + refName)) { nextRefsClick(refName); } }
|
||||
}
|
||||
|
||||
// Creates a string representation of the arguments of a refinement
|
||||
function refArgsToHtml(fun) {
|
||||
var args = "";
|
||||
for (var i = 0, j = myAbstract.types[fun].args.length; i < j; i++) {
|
||||
args += myAbstract.types[fun].args[i] + " -> ";
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
// Gets the type of a meta variable
|
||||
function getMetaType(absNode, route, currRoute) {
|
||||
if (route == currRoute && absNode.isMeta()) {
|
||||
return absNode.type;
|
||||
}
|
||||
else {
|
||||
for (var i = 0, j = absNode.args.length; i < j; i++) {
|
||||
var found = getMetaType(absNode.args[i], route, currRoute + "-" + i);
|
||||
if (found) { return found };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When the "Undo" action is selected, undoes the last action
|
||||
function clickUndo(actName) {
|
||||
if (document.getElementById(actName).className == "action" && undoArray.length) {
|
||||
highlightSelectedAction(actName);
|
||||
redoArray.push(new state(selectedNode, abstractTree, collapseBuffer));
|
||||
var prevState = undoArray.pop();
|
||||
selectedNode = prevState.selectedNode;
|
||||
abstractTree = myAbstract.copyTree(prevState.tree);
|
||||
collapseBuffer = prevState.collapseBuffer;
|
||||
if (abstractTree.isComplete()) { selectedNode = "0"; }
|
||||
abstractTree = myAbstract.annotate(abstractTree, myAbstract.startcat);
|
||||
myTree = treeFromAbstract(abstractTree, "0");
|
||||
nodeClick(selectedNode);
|
||||
}
|
||||
}
|
||||
|
||||
// When the "Redo" action is selected, redoes the last action
|
||||
function clickRedo(actName) {
|
||||
if (document.getElementById(actName).className == "action" && redoArray.length) {
|
||||
highlightSelectedAction(actName);
|
||||
undoArray.push(new state(selectedNode, abstractTree, collapseBuffer));
|
||||
var nextState = redoArray.pop();
|
||||
selectedNode = nextState.selectedNode;
|
||||
abstractTree = myAbstract.copyTree(nextState.tree);
|
||||
collapseBuffer = nextState.collapseBuffer;
|
||||
abstractTree = myAbstract.annotate(abstractTree, myAbstract.startcat);
|
||||
myTree = treeFromAbstract(abstractTree, "0");
|
||||
nodeClick(selectedNode);
|
||||
}
|
||||
}
|
||||
|
||||
// When the "Copy" action is selected, copies the selected node to the clipboard
|
||||
function clickCopy(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
highlightSelectedAction(actName);
|
||||
if (selectedNode) {
|
||||
clipBoard = myAbstract.copyTree(getNodeFromAbstract(abstractTree, selectedNode, "0"));
|
||||
document.getElementById("clipboardFrame").innerHTML = clipBoard.name + " : " +
|
||||
myAbstract.getCat(clipBoard.name);
|
||||
nodeClick(selectedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When the "Cut" action is selected, deletes the selected node and copies it to the clipboard
|
||||
function clickCut(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
highlightSelectedAction(actName);
|
||||
pushUndoClearRedo();
|
||||
if (selectedNode) {
|
||||
clipBoard = myAbstract.copyTree(getNodeFromAbstract(abstractTree, selectedNode, "0"));
|
||||
document.getElementById("clipboardFrame").innerHTML = clipBoard.name + " : " +
|
||||
myAbstract.getCat(clipBoard.name);
|
||||
abstractTree = deleteNode(abstractTree, selectedNode, "0");
|
||||
concludeAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Annotates the abstract tree, creates a tree from the abstract tree and selects the next meta variable
|
||||
function concludeAction() {
|
||||
abstractTree = myAbstract.annotate(abstractTree, myAbstract.startcat);
|
||||
myTree = treeFromAbstract(abstractTree, "0");
|
||||
selectNextMeta();
|
||||
}
|
||||
|
||||
// Selects the next meta variable available
|
||||
function selectNextMeta() {
|
||||
nodeClick(selectedNode);
|
||||
if (!abstractTree.isComplete()) {
|
||||
var pathToNextMeta = "";
|
||||
var nodePos = getNavPos(selectedNode);
|
||||
while (1) {
|
||||
if (nodePos == navigationControlString.length) { nodePos = 0; }
|
||||
var node = getNode(navigationControlString[nodePos], myTree);
|
||||
if (node.caption == "?") { pathToNextMeta = node.name; break; }
|
||||
nodePos++;
|
||||
}
|
||||
expandAscendants(pathToNextMeta);
|
||||
nodeClick(pathToNextMeta);
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the first meta variable from an abstract tree
|
||||
function getNextMetaFromAbstract(node, route) {
|
||||
if (node.isMeta()) { return route; }
|
||||
for (var i = 0, j = node.args.length; i < j; i++) {
|
||||
var found = getNextMetaFromAbstract(node.args[i], route + "-" + i);
|
||||
if (found) { return found; }
|
||||
}
|
||||
}
|
||||
|
||||
// Expands the ascendants of a given node
|
||||
function expandAscendants(nodeName) {
|
||||
var nodePath = nodeName.split("-");
|
||||
var currAscendant = nodePath.shift();
|
||||
while (nodePath.length > 0) {
|
||||
var node = getNode(currAscendant, myTree);
|
||||
if (node.collapsed) {
|
||||
myTree = expandCollapse(myTree, currAscendant);
|
||||
}
|
||||
currAscendant += "-" + nodePath.shift();
|
||||
}
|
||||
}
|
||||
|
||||
// When the "Paste" action is selected, pastes the contents of the clipboard into the selected node
|
||||
function clickPaste(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
highlightSelectedAction(actName);
|
||||
pushUndoClearRedo();
|
||||
if (selectedNode) {
|
||||
abstractTree = insertNode(abstractTree, selectedNode, "0", myAbstract.copyTree(clipBoard));
|
||||
concludeAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inserts a node into a tree
|
||||
function insertNode(absNode, route, currRoute, node) {
|
||||
if (route == currRoute) {
|
||||
return node;
|
||||
}
|
||||
else {
|
||||
for (var i = 0, j = absNode.args.length; i < j; i++) {
|
||||
absNode.setArg(i, insertNode(absNode.args[i], route, currRoute + "-" + i, node));
|
||||
}
|
||||
return absNode;
|
||||
}
|
||||
}
|
||||
|
||||
// When the "Delete" action is selected, deletes the selected node
|
||||
function clickDelete(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
highlightSelectedAction(actName);
|
||||
pushUndoClearRedo();
|
||||
if (selectedNode) {
|
||||
abstractTree = deleteNode(abstractTree, selectedNode, "0");
|
||||
abstractTree = myAbstract.annotate(abstractTree, myAbstract.startcat);
|
||||
myTree = treeFromAbstract(abstractTree, "0");
|
||||
nodeClick(selectedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Deletes a node from a tree
|
||||
function deleteNode(absNode, route, currRoute) {
|
||||
if (route == currRoute) {
|
||||
return new Fun("?");
|
||||
}
|
||||
else {
|
||||
for (var i = 0, j = absNode.args.length; i < j; i++) {
|
||||
absNode.setArg(i, deleteNode(absNode.args[i], route, currRoute + "-" + i));
|
||||
}
|
||||
return absNode;
|
||||
}
|
||||
}
|
||||
|
||||
// When the "Replace" action is selected, replaces the selected node with another refinement
|
||||
function clickReplace(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
highlightSelectedAction(actName);
|
||||
pushUndoClearRedo();
|
||||
if (selectedNode) {
|
||||
abstractTree = deleteNode(abstractTree, selectedNode, "0");
|
||||
abstractTree = myAbstract.annotate(abstractTree, myAbstract.startcat);
|
||||
myTree = treeFromAbstract(abstractTree, "0");
|
||||
drawTree();
|
||||
document.getElementById("refFrame").innerHTML = showRefinements(selectedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When the "Wrap" action is selected, wraps around the selected node with another refinement
|
||||
function clickWrap(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
highlightSelectedAction(actName);
|
||||
pushUndoClearRedo();
|
||||
var node = getNode(selectedNode, myTree);
|
||||
if (selectedNode) {
|
||||
refPageCounter = 0;
|
||||
var wrappers = getWrappers(node.caption);
|
||||
document.getElementById("refFrame").innerHTML = wrappers;
|
||||
if (wrappers.length <= 31) {
|
||||
alert("No wrappers available");
|
||||
document.getElementById("actFrame").innerHTML = showActions();
|
||||
nodeClick(selectedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the wrappers to display
|
||||
function getWrappers(nodeCaption) {
|
||||
var nodeType = myAbstract.types[nodeCaption].cat;
|
||||
var availWrappers = getAvailableWrappers(nodeType);
|
||||
var pages = Math.floor(availWrappers.length / 9);
|
||||
var upperLimit;
|
||||
if (pages != refPageCounter) { upperLimit = (9 * refPageCounter) + 9; }
|
||||
else { upperLimit = availWrappers.length - (9 * refPageCounter); }
|
||||
var wrappers = "<table class='wrapper'>";
|
||||
var keyPos = 0;
|
||||
for (var i = (9 * refPageCounter), j = (9 * refPageCounter) + upperLimit; i < j; i++) {
|
||||
wrappers += ref_wrapToHtml("wrap", availWrappers[i][0], "wrapper", ", " + availWrappers[i][1], keyPos, "");
|
||||
keys["" + keyPos] = mkWrapHotKey(availWrappers[i][0], availWrappers[i][1]);
|
||||
keyPos++;
|
||||
}
|
||||
if (pages > (9 * refPageCounter)) {
|
||||
refinements += ref_wrapNextRefsToHtml("nextWraps", "Next", "wrapper", "+", "Next Wrappers");
|
||||
keys["107"] = mkWrapNextRefsHotKey("Next");
|
||||
}
|
||||
if (0 < (9 * refPageCounter)) {
|
||||
refinements += ref_wrapNextRefsToHtml("nextWraps", "Previous", "wrapper", "-", "Previous Wrappers");
|
||||
keys["109"] = mkWrapNextRefsHotKey("Previous");
|
||||
}
|
||||
wrappers += "</table>";
|
||||
return wrappers;
|
||||
}
|
||||
|
||||
// Gets the available wrappers for a node
|
||||
function getAvailableWrappers(nodeType) {
|
||||
var wrappers = new Array();
|
||||
for (var fun in myAbstract.types) {
|
||||
for (var i = 0, j = myAbstract.types[fun].args.length; i < j; i++) {
|
||||
if (myAbstract.types[fun].args[i] == nodeType && myAbstract.types[fun].cat == nodeType) {
|
||||
wrappers[wrappers.length] = new Array(fun, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return wrappers;
|
||||
}
|
||||
|
||||
// Creates the function to be used by a "numeric" hot key
|
||||
function mkWrapHotKey(refName, argPos) {
|
||||
return function() { if (document.getElementById("wrap" + refName)) { wrapClick(refName, argPos); } }
|
||||
}
|
||||
|
||||
// Creates the function to be used by a "-" hot key
|
||||
function mkWrapNextRefsHotKey(refName) {
|
||||
return function() { if (document.getElementById("nextWraps" + refName)) { nextRefsClick(refName); } }
|
||||
}
|
||||
|
||||
// When the "RandomNode" action is selected, refines the node at random
|
||||
function clickRandomNode(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
highlightSelectedAction(actName);
|
||||
pushUndoClearRedo();
|
||||
if (selectedNode) {
|
||||
var tempTree = myAbstract.copyTree(abstractTree);
|
||||
abstractTree = myAbstract.copyTree(getNodeFromAbstract(abstractTree, selectedNode, "0"));
|
||||
fillSubTree()
|
||||
abstractTree = insertNode(tempTree, selectedNode, "0", myAbstract.copyTree(abstractTree));
|
||||
concludeAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Refines the sub tree
|
||||
function fillSubTree() {
|
||||
while (!abstractTree.isComplete()) {
|
||||
var nodeToRefine = getNextMetaFromAbstract(abstractTree, "0");
|
||||
if (nodeToRefine) {
|
||||
var refs = getAvailableRefinements(nodeToRefine);
|
||||
// FIX THIS ASAP!!!!
|
||||
if (refs.length == 0) {
|
||||
var node = getNodeFromAbstract(abstractTree, nodeToRefine, "0");
|
||||
if (node.type == "String") {
|
||||
var newType = "AutoString";
|
||||
myAbstract.addType(newType,[], "String");
|
||||
for (var i = 0, j = myConcrete.length; i < j; i++) {
|
||||
myConcrete[i].concreteSyntax.addRule(newType, function(cs){ return new Arr(new Str(newType));});
|
||||
}
|
||||
node.name = newType;
|
||||
abstractTree = insertNode(abstractTree, nodeToRefine, "0", node);
|
||||
abstractTree = myAbstract.annotate(abstractTree, myAbstract.startcat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var selectedRef = refs[Math.floor(refs.length * Math.random())];
|
||||
abstractTree = refineAbstractTree(abstractTree, nodeToRefine, "0", selectedRef);
|
||||
abstractTree = myAbstract.annotate(abstractTree, myAbstract.startcat);
|
||||
}
|
||||
/*
|
||||
var selectedRef = refs[Math.floor(refs.length * Math.random())];
|
||||
abstractTree = refineAbstractTree(abstractTree, nodeToRefine, "0", selectedRef);
|
||||
abstractTree = myAbstract.annotate(abstractTree, myAbstract.startcat);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When the "RandomTree" action is selected, refines the tree at random
|
||||
function clickRandomTree(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
highlightSelectedAction(actName);
|
||||
pushUndoClearRedo();
|
||||
fillSubTree();
|
||||
concludeAction();
|
||||
}
|
||||
}
|
||||
|
||||
// If a node is selected and is of type meta, it refines the node with a type refName
|
||||
function refClick(refName) {
|
||||
if (selectedNode) {
|
||||
if (refName == "genRefRandom") {
|
||||
var refs = getAvailableRefinements(selectedNode);
|
||||
refName = refs[Math.floor(refs.length * Math.random())];
|
||||
}
|
||||
abstractTree = refineAbstractTree(abstractTree, selectedNode, "0", refName);
|
||||
document.getElementById("actFrame").innerHTML = showActions();
|
||||
document.getElementById("refFrame").innerHTML = "";
|
||||
clearHotKeys();
|
||||
concludeAction();
|
||||
}
|
||||
}
|
||||
|
||||
// If a refinement is selected, a node has the property "selected" set and the node is a meta variable,
|
||||
// it refines node. Returns the refined abstract tree
|
||||
function refineAbstractTree(absNode, route, currRoute, refName) {
|
||||
if (route == currRoute && absNode.isMeta()) {
|
||||
return createRefinement(refName);
|
||||
}
|
||||
else {
|
||||
for (var i = 0, j = absNode.args.length; i < j; i++) {
|
||||
absNode.setArg(i, refineAbstractTree(absNode.args[i], route, currRoute + "-" + i, refName));
|
||||
}
|
||||
return absNode;
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a Fun of type refName object with the appropriate number of meta arguments
|
||||
function createRefinement(refName) {
|
||||
var newRef = new Fun(refName);
|
||||
for (var i = 0, j = myAbstract.types[refName].args.length; i < j; i++) {
|
||||
newRef.setArg(i, new Fun("?"));
|
||||
}
|
||||
return newRef;
|
||||
}
|
||||
|
||||
// Creates a tree from an abstract tree
|
||||
function treeFromAbstract(abstractNode, name) {
|
||||
var node = new treeNode(name, abstractNode.name);
|
||||
if (node.caption == "?") {
|
||||
node.cat = abstractNode.type; }
|
||||
else { node.cat = myAbstract.getCat(node.caption); }
|
||||
if (wasCollapsed(node.name)) { node.collapsed = true; }
|
||||
for (var i = 0, j = abstractNode.args.length; i < j; i++) {
|
||||
node.addChild(i, treeFromAbstract(abstractNode.args[i], name + "-" + i));
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Wraps a refinement around a node
|
||||
function wrapClick(refName, argPos) {
|
||||
if (selectedNode) {
|
||||
var tempNode = createRefinement(refName);
|
||||
tempNode.setArg(argPos, myAbstract.copyTree(getNodeFromAbstract(abstractTree, selectedNode, "0")));
|
||||
abstractTree = insertNode(abstractTree, selectedNode, "0", tempNode);
|
||||
document.getElementById("actFrame").innerHTML = showActions();
|
||||
document.getElementById("refFrame").innerHTML = "";
|
||||
clearHotKeys();
|
||||
concludeAction();
|
||||
}
|
||||
}
|
||||
|
||||
// Handler for the escape key
|
||||
function clickEsc() {
|
||||
if ((document.getElementById("actRefine").className == "selected" ||
|
||||
document.getElementById("actReplace").className == "selected" ||
|
||||
document.getElementById("actWrap").className == "selected") && undoArray.length) {
|
||||
var prevState = undoArray.pop();
|
||||
selectedNode = prevState.selectedNode;
|
||||
abstractTree = myAbstract.copyTree(prevState.tree);
|
||||
collapseBuffer = prevState.collapseBuffer;
|
||||
abstractTree = myAbstract.annotate(abstractTree, myAbstract.startcat);
|
||||
myTree = treeFromAbstract(abstractTree, "0");
|
||||
document.getElementById("actFrame").innerHTML = showActions();
|
||||
if (selectedNode) { nodeClick(selectedNode) }
|
||||
}
|
||||
}
|
||||
|
||||
// If there are over ten refinements available shows only the selected nine
|
||||
function nextRefsClick(refName) {
|
||||
if (refName == "Next") { refPageCounter++; } else { refPageCounter--; }
|
||||
clearHotKeys();
|
||||
document.getElementById("refFrame").innerHTML = showRefinements(selectedNode);
|
||||
}
|
||||
|
||||
|
||||
// show overloaded name: ignore prefix ovr*_
|
||||
function overl(name){
|
||||
var nam = "";
|
||||
if (name[0] + name[1] + name[2]=="ovr") {
|
||||
i = 5 ;
|
||||
while (name[i] != '_') {++i}
|
||||
for (j = i+1 ; j != name.length ; ++j){ nam += name[j] ;}
|
||||
}
|
||||
else nam = name ;
|
||||
return nam;
|
||||
}
|
||||
|
||||
Fun.prototype.printOverl = function () { return this.showOverl(0); } ;
|
||||
Fun.prototype.showOverl = function (prec) {
|
||||
if (this.isMeta()) {
|
||||
return '?';
|
||||
|
||||
} else {
|
||||
var s = overl(this.name);
|
||||
var cs = this.args;
|
||||
for (var i in cs) {
|
||||
s += " " + cs[i].showOverl(1);
|
||||
}
|
||||
if (prec > 0 && cs.length > 0) {
|
||||
s = "(" + s + ")" ;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
};
|
||||
42
demos/resource-api/editor.html
Normal file
42
demos/resource-api/editor.html
Normal file
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||
<script type="text/javascript" src="gflib.js"></script>
|
||||
<script type="text/javascript" src="grammar.js"></script>
|
||||
<script type="text/javascript" src="grammarReference.js"></script>
|
||||
<script type="text/javascript" src="code.js"></script>
|
||||
<title>Syntax Editor for GF Resource Grammar Library</title>
|
||||
</head>
|
||||
<body onload="nodeClick('0', '?')" onkeydown="hotKeys(event)">
|
||||
<h2>Syntax Editor for GF Resource Grammar Library</h2>
|
||||
<div id="wrapper">
|
||||
<div id="absFrame">
|
||||
</div>
|
||||
<div id="conFrame">
|
||||
</div>
|
||||
<div id="actFrame">
|
||||
</div>
|
||||
<div id="refFrame">
|
||||
</div>
|
||||
<div id="messageFrame">
|
||||
</div>
|
||||
<div id="clipboardFrame">
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
|
||||
Languages shown: English, Russian, Swedish.
|
||||
|
||||
<p>
|
||||
|
||||
Example: <i>I love you</i> is obtained by <tt>r7 r3 r+7 r2 r+++3 r+7 r9</tt>
|
||||
|
||||
<p>
|
||||
|
||||
More information: <a href="../../lib/resource/doc/synopsis.html">resource synopsis</a>.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
BIN
demos/resource-api/empty.png
Normal file
BIN
demos/resource-api/empty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 161 B |
333
demos/resource-api/gflib.js
Normal file
333
demos/resource-api/gflib.js
Normal file
@@ -0,0 +1,333 @@
|
||||
|
||||
/* Extension to the String object */
|
||||
|
||||
String.prototype.tag = "";
|
||||
String.prototype.setTag = function (tag) { this.tag = tag; };
|
||||
|
||||
/* Abstract syntax trees */
|
||||
function Fun(name) {
|
||||
this.name = name;
|
||||
this.args = copy_arguments(arguments, 1);
|
||||
}
|
||||
Fun.prototype.print = function () { return this.show(0); } ;
|
||||
Fun.prototype.show = function (prec) {
|
||||
if (this.isMeta()) {
|
||||
if (isUndefined(this.type)) {
|
||||
return '?';
|
||||
} else {
|
||||
var s = '?:' + this.type;
|
||||
if (prec > 0) {
|
||||
s = "(" + s + ")" ;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
} else {
|
||||
var s = this.name;
|
||||
var cs = this.args;
|
||||
for (var i in cs) {
|
||||
s += " " + cs[i].show(1);
|
||||
}
|
||||
if (prec > 0 && cs.length > 0) {
|
||||
s = "(" + s + ")" ;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
};
|
||||
Fun.prototype.getArg = function (i) {
|
||||
return this.args[i];
|
||||
};
|
||||
Fun.prototype.setArg = function (i,c) {
|
||||
this.args[i] = c;
|
||||
};
|
||||
Fun.prototype.isMeta = function() {
|
||||
return this.name == '?';
|
||||
} ;
|
||||
Fun.prototype.isComplete = function() {
|
||||
if (this.isMeta()) {
|
||||
return false;
|
||||
} else {
|
||||
for (var i in this.args) {
|
||||
if (!this.args[i].isComplete()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
/* Concrete syntax terms */
|
||||
|
||||
function Arr() { this.arr = copy_arguments(arguments, 0); }
|
||||
Arr.prototype.tokens = function() { return this.arr[0].tokens(); };
|
||||
Arr.prototype.sel = function(i) { return this.arr[i.toIndex()]; };
|
||||
Arr.prototype.setTag = function(tag) {
|
||||
for (var i = 0, j = this.arr.length; i < j; i++) {
|
||||
this.arr[i].setTag(tag);
|
||||
}
|
||||
};
|
||||
|
||||
function Seq() { this.seq = copy_arguments(arguments, 0); }
|
||||
Seq.prototype.tokens = function() {
|
||||
var xs = new Array();
|
||||
for (var i in this.seq) {
|
||||
var ys = this.seq[i].tokens();
|
||||
for (var j in ys) {
|
||||
xs.push(ys[j]);
|
||||
}
|
||||
}
|
||||
return xs;
|
||||
};
|
||||
Seq.prototype.setTag = function(tag) {
|
||||
for (var i = 0, j = this.seq.length; i < j; i++) {
|
||||
this.seq[i].setTag(tag);
|
||||
}
|
||||
};
|
||||
|
||||
function Variants() { this.variants = copy_arguments(arguments, 0); }
|
||||
Variants.prototype.tokens = function() { return this.variants[0].tokens(); };
|
||||
Variants.prototype.sel = function(i) { return this.variants[0].sel(i); };
|
||||
Variants.prototype.toIndex = function() { return this.variants[0].toIndex(); };
|
||||
Variants.prototype.setTag = function(tag) {
|
||||
for (var i = 0, j = this.variants.length; i < j; i++) {
|
||||
this.variants[i].setTag(tag);
|
||||
}
|
||||
};
|
||||
|
||||
function Rp(index,value) { this.index = index; this.value = value; }
|
||||
Rp.prototype.tokens = function() { return new Array(this.index.tokens()); };
|
||||
Rp.prototype.sel = function(i) { return this.value.arr[i.toIndex()]; };
|
||||
Rp.prototype.toIndex = function() { return this.index.toIndex(); };
|
||||
Rp.prototype.setTag = function(tag) { this.index.setTag(tag) };
|
||||
|
||||
function Suffix(prefix,suffix) {
|
||||
this.prefix = new String(prefix);
|
||||
if (prefix.tag) { this.prefix.tag = prefix.tag; }
|
||||
this.suffix = suffix;
|
||||
};
|
||||
Suffix.prototype.tokens = function() {
|
||||
var xs = this.suffix.tokens();
|
||||
for (var i in xs) {
|
||||
xs[i] = new String(this.prefix + xs[i]);
|
||||
xs[i].setTag(this.prefix.tag);
|
||||
}
|
||||
return xs;
|
||||
};
|
||||
Suffix.prototype.sel = function(i) { return new Suffix(this.prefix, this.suffix.sel(i)); };
|
||||
Suffix.prototype.setTag = function(tag) { if (!this.prefix.tag) { this.prefix.setTag(tag); } };
|
||||
|
||||
function Meta() { }
|
||||
Meta.prototype.tokens = function() {
|
||||
var newString = new String("?");
|
||||
newString.setTag(this.tag);
|
||||
return new Array(newString);
|
||||
};
|
||||
Meta.prototype.toIndex = function() { return 0; };
|
||||
Meta.prototype.sel = function(i) { return this; };
|
||||
Meta.prototype.setTag = function(tag) { if (!this.tag) { this.tag = tag; } };
|
||||
|
||||
function Str(value) { this.value = value; }
|
||||
Str.prototype.tokens = function() {
|
||||
var newString = new String(this.value);
|
||||
newString.setTag(this.tag);
|
||||
return new Array(newString);
|
||||
};
|
||||
Str.prototype.setTag = function(tag) { if (!this.tag) { this.tag = tag; } };
|
||||
|
||||
function Int(value) { this.value = value; }
|
||||
Int.prototype.tokens = function() {
|
||||
var newString = new String(this.value.toString());
|
||||
newString.setTag(this.tag);
|
||||
return new Array(newString);
|
||||
};
|
||||
Int.prototype.toIndex = function() { return this.value; };
|
||||
Int.prototype.setTag = function(tag) { if (!this.tag) { this.tag = tag; } };
|
||||
|
||||
/* Type annotation */
|
||||
|
||||
function Abstract(startcat) {
|
||||
this.types = new Array();
|
||||
this.startcat = startcat;
|
||||
}
|
||||
Abstract.prototype.addType = function(fun, args, cat) {
|
||||
this.types[fun] = new Type(args, cat);
|
||||
} ;
|
||||
Abstract.prototype.getArgs = function(fun) {
|
||||
return this.types[fun].args;
|
||||
}
|
||||
Abstract.prototype.getCat = function(fun) {
|
||||
return this.types[fun].cat;
|
||||
};
|
||||
Abstract.prototype.annotate = function(tree, type) {
|
||||
if (tree.name == '?') {
|
||||
tree.type = type;
|
||||
} else {
|
||||
var typ = this.types[tree.name];
|
||||
for (var i in tree.args) {
|
||||
this.annotate(tree.args[i], typ.args[i]);
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
} ;
|
||||
/* Hack to get around the fact that our SISR doesn't build real Fun objects. */
|
||||
Abstract.prototype.copyTree = function(x) {
|
||||
var t = new Fun(x.name);
|
||||
if (!isUndefined(x.type)) {
|
||||
t.type = x.type;
|
||||
}
|
||||
var cs = x.args;
|
||||
if (!isUndefined(cs)) {
|
||||
for (var i in cs) {
|
||||
t.setArg(i, this.copyTree(cs[i]));
|
||||
}
|
||||
}
|
||||
return t;
|
||||
} ;
|
||||
Abstract.prototype.parseTree = function(str, type) {
|
||||
return this.annotate(this.parseTree_(str.match(/[\w\']+|\(|\)|\?|\:/g), 0), type);
|
||||
} ;
|
||||
Abstract.prototype.parseTree_ = function(tokens, prec) {
|
||||
if (tokens.length == 0 || tokens[0] == ")") { return null; }
|
||||
var t = tokens.shift();
|
||||
if (t == "(") {
|
||||
var tree = this.parseTree_(tokens, 0);
|
||||
tokens.shift();
|
||||
return tree;
|
||||
} else if (t == '?') {
|
||||
var tree = this.parseTree_(tokens, 0);
|
||||
return new Fun('?');
|
||||
} else {
|
||||
var tree = new Fun(t);
|
||||
if (prec == 0) {
|
||||
var c, i;
|
||||
for (i = 0; (c = this.parseTree_(tokens, 1)) !== null; i++) {
|
||||
tree.setArg(i,c);
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
} ;
|
||||
|
||||
function Type(args, cat) {
|
||||
this.args = args;
|
||||
this.cat = cat;
|
||||
}
|
||||
|
||||
/* Linearization */
|
||||
|
||||
function Concrete(abstr) {
|
||||
this.abstr = abstr;
|
||||
this.rules = new Array();
|
||||
}
|
||||
Concrete.prototype.rule = function (name, cs) { return this.rules[name](cs); };
|
||||
Concrete.prototype.addRule = function (name, f) { this.rules[name] = f; };
|
||||
Concrete.prototype.lindef = function (cat, v) { return this.rules[cat]([new Str(v)]); } ;
|
||||
Concrete.prototype.linearize = function (tree) {
|
||||
return this.unlex(this.linearizeToTerm(tree).tokens());
|
||||
};
|
||||
Concrete.prototype.linearizeToTerm = function (tree) {
|
||||
if (tree.isMeta()) {
|
||||
if (isUndefined(tree.type)) {
|
||||
return new Meta();
|
||||
} else {
|
||||
return this.lindef(tree.type, tree.name);
|
||||
}
|
||||
} else {
|
||||
var cs = new Array();
|
||||
for (var i in tree.args) {
|
||||
cs.push(this.linearizeToTerm(tree.args[i]));
|
||||
}
|
||||
var newTerm = this.rule(tree.name, cs);
|
||||
return newTerm;
|
||||
}
|
||||
};
|
||||
Concrete.prototype.unlex = function (ts) {
|
||||
if (ts.length == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var noSpaceAfter = /^[\(\-\[]/;
|
||||
var noSpaceBefore = /^[\.\,\?\!\)\:\;\-\]]/;
|
||||
|
||||
var s = "";
|
||||
for (var i = 0; i < ts.length; i++) {
|
||||
var t = ts[i];
|
||||
var after = i < ts.length-1 ? ts[i+1] : null;
|
||||
s += t;
|
||||
if (after != null && !t.match(noSpaceAfter)
|
||||
&& !after.match(noSpaceBefore)) {
|
||||
s += " ";
|
||||
}
|
||||
}
|
||||
return s;
|
||||
};
|
||||
Concrete.prototype.tagAndLinearize = function (tree) {
|
||||
// return this.tagAndLinearizeToTerm(tree, "0").tokens();
|
||||
var treeTerms = this.tagAndLinearizeToTerm(tree, "0");
|
||||
var treeTokens = treeTerms.tokens();
|
||||
return treeTokens;
|
||||
};
|
||||
Concrete.prototype.tagAndLinearizeToTerm = function (tree, route) {
|
||||
if (tree.isMeta()) {
|
||||
if (isUndefined(tree.type)) {
|
||||
var newMeta = new Meta();
|
||||
newMeta.setTag(route);
|
||||
return newMeta;
|
||||
} else {
|
||||
var newTerm = this.lindef(tree.type, tree.name);
|
||||
newTerm.setTag(route);
|
||||
return newTerm;
|
||||
}
|
||||
} else {
|
||||
var cs = new Array();
|
||||
for (var i in tree.args) {
|
||||
cs.push(this.tagAndLinearizeToTerm(tree.args[i], route + "-" + i));
|
||||
}
|
||||
var newTerm = this.rule(tree.name, cs);
|
||||
newTerm.setTag(route);
|
||||
return newTerm;
|
||||
}
|
||||
};
|
||||
|
||||
/* Utilities */
|
||||
|
||||
/* from Remedial JavaScript by Douglas Crockford, http://javascript.crockford.com/remedial.html */
|
||||
function isString(a) { return typeof a == 'string'; }
|
||||
function isArray(a) { return a && typeof a == 'object' && a.constructor == Array; }
|
||||
function isUndefined(a) { return typeof a == 'undefined'; }
|
||||
function isBoolean(a) { return typeof a == 'boolean'; }
|
||||
function isNumber(a) { return typeof a == 'number' && isFinite(a); }
|
||||
function isFunction(a) { return typeof a == 'function'; }
|
||||
|
||||
function dumpObject (obj) {
|
||||
if (isUndefined(obj)) {
|
||||
return "undefined";
|
||||
} else if (isString(obj)) {
|
||||
return '"' + obj.toString() + '"'; // FIXME: escape
|
||||
} else if (isBoolean(obj) || isNumber(obj)) {
|
||||
return obj.toString();
|
||||
} else if (isArray(obj)) {
|
||||
var x = "[";
|
||||
for (var i in obj) {
|
||||
x += dumpObject(obj[i]);
|
||||
if (i < obj.length-1) {
|
||||
x += ",";
|
||||
}
|
||||
}
|
||||
return x + "]";
|
||||
} else {
|
||||
var x = "{";
|
||||
for (var y in obj) {
|
||||
x += y + "=" + dumpObject(obj[y]) + ";" ;
|
||||
}
|
||||
return x + "}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function copy_arguments(args, start) {
|
||||
var arr = new Array();
|
||||
for (var i = 0; i < args.length - start; i++) {
|
||||
arr[i] = args[i + start];
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
16670
demos/resource-api/grammar.js
Normal file
16670
demos/resource-api/grammar.js
Normal file
File diff suppressed because one or more lines are too long
10
demos/resource-api/grammarReference.js
Normal file
10
demos/resource-api/grammarReference.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// Grammar Reference
|
||||
function concreteReference(concreteSyntax, concreteSyntaxName) {
|
||||
this.concreteSyntax = concreteSyntax;
|
||||
this.concreteSyntaxName = concreteSyntaxName;
|
||||
}
|
||||
var myAbstract = OverLang ;
|
||||
var myConcrete = new Array();
|
||||
myConcrete.push(new concreteReference(OverLangEng,"OverLangEng"));
|
||||
myConcrete.push(new concreteReference(OverLangRus,"OverLangRus"));
|
||||
myConcrete.push(new concreteReference(OverLangSwe,"OverLangSwe"));
|
||||
21
demos/resource-api/index.html
Normal file
21
demos/resource-api/index.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Index of /~aarne/GF/demos/overl</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<H1>Index of /~aarne/GF/demos/overl</H1>
|
||||
<PRE><IMG SRC="/icons/blank.gif" ALT=" "> <A HREF="?N=D">Name</A> <A HREF="?M=A">Last modified</A> <A HREF="?S=A">Size</A> <A HREF="?D=A">Description</A>
|
||||
<HR>
|
||||
<IMG SRC="/icons/back.gif" ALT="[DIR]"> <A HREF="/~aarne/GF/demos/">Parent Directory</A> 20-Dec-2007 23:44 -
|
||||
<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="code.js">code.js</A> 20-Dec-2007 22:46 33k
|
||||
<IMG SRC="/icons/text.gif" ALT="[TXT]"> <A HREF="editor.html">editor.html</A> 29-Oct-2007 09:58 1k
|
||||
<IMG SRC="/icons/image2.gif" ALT="[IMG]"> <A HREF="empty.png">empty.png</A> 04-Oct-2007 10:45 1k
|
||||
<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="gflib.js">gflib.js</A> 20-Dec-2007 22:40 9k
|
||||
<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="grammar.js">grammar.js</A> 20-Dec-2007 23:16 3.4M
|
||||
<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="grammarReference.js">grammarReference.js</A> 20-Dec-2007 23:16 1k
|
||||
<IMG SRC="/icons/image2.gif" ALT="[IMG]"> <A HREF="minus.png">minus.png</A> 04-Oct-2007 10:46 1k
|
||||
<IMG SRC="/icons/image2.gif" ALT="[IMG]"> <A HREF="plus.png">plus.png</A> 04-Oct-2007 10:46 1k
|
||||
<IMG SRC="/icons/text.gif" ALT="[TXT]"> <A HREF="style.css">style.css</A> 29-Oct-2007 10:05 3k
|
||||
</PRE><HR>
|
||||
</BODY></HTML>
|
||||
BIN
demos/resource-api/minus.png
Normal file
BIN
demos/resource-api/minus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 201 B |
BIN
demos/resource-api/plus.png
Normal file
BIN
demos/resource-api/plus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 229 B |
198
demos/resource-api/style.css
Normal file
198
demos/resource-api/style.css
Normal file
@@ -0,0 +1,198 @@
|
||||
body {
|
||||
font-family:arial,helvetica,sans-serif;
|
||||
font-size:12px;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
width:600px;
|
||||
height:520px;
|
||||
margin:auto 50px;
|
||||
border:1px solid gray;
|
||||
padding:10px;
|
||||
|
||||
}
|
||||
|
||||
#absFrame {
|
||||
width:180px;
|
||||
height:250px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#conFrame {
|
||||
width:366px;
|
||||
height:250px;
|
||||
margin-left:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
white-space: normal;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#actFrame {
|
||||
width:180px;
|
||||
height:170px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#refFrame {
|
||||
width:366px;
|
||||
height:170px;
|
||||
margin-left:10px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#messageFrame {
|
||||
width:366px;
|
||||
height:15px;
|
||||
margin-top:10px;
|
||||
margin-right:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#clipboardFrame {
|
||||
width:180px;
|
||||
height:15px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#tree {
|
||||
left: -10px;
|
||||
top: -10px;
|
||||
width: 180px;
|
||||
height: 250px;
|
||||
margin: 0px;
|
||||
padding: 10px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
ul {
|
||||
position: relative;
|
||||
list-style: none;
|
||||
margin-left: 20px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
li {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
img.tree-menu {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
a.tree:link, a.tree:visited, a.tree:active {
|
||||
color: black;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.tree:hover {
|
||||
color: blue;
|
||||
background-color: white;
|
||||
text-decoration: underline;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeSelected:link, a.treeSelected:visited, a.treeSelected:active {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeSelected:hover {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: underline;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
table.action, table.refinement, table.wrapper {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
border-style: none;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0px;
|
||||
}
|
||||
|
||||
tr.selected {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
tr.unavailable, tr.closed {
|
||||
color: silver;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
tr.unavailable:hover {
|
||||
color: silver;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
tr.action, tr.refinement, tr.wrapper {
|
||||
color: black;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
tr.action:hover, tr.refinement:hover, tr.wrapper:hover {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
td.action {
|
||||
width: 220px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
td.refinement, td.wrapper {
|
||||
width: 515px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
td.hotKey {
|
||||
width: 30px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 40px;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
span.normal {
|
||||
color: black;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
span.selected {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: none;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
i ExamplesDan.gf
|
||||
i ExamplesEng.gf
|
||||
i ExamplesFin.gf
|
||||
i ExamplesFre.gf
|
||||
i ExamplesGer.gf
|
||||
i ExamplesIta.gf
|
||||
i ExamplesNor.gf
|
||||
i ExamplesRus.gf
|
||||
i ExamplesSpa.gf
|
||||
i ExamplesSwe.gf
|
||||
pm -printer=gfcc | wf examples.gfcc
|
||||
gt | tb | wf examples.txt
|
||||
@@ -155,7 +155,7 @@ gfdoc:
|
||||
mv ../prelude/*.html doc/gfdoc
|
||||
|
||||
gf3:
|
||||
export GF_LIB_PATH=..; $(MAKE) -e gf3prelude gf3present gf3alltenses
|
||||
export GF_LIB_PATH=..; $(MAKE) -e gf3prelude gf3present gf3alltenses gf3mathematical
|
||||
|
||||
gf3prelude:
|
||||
$(GFNew) ../src/*.gf
|
||||
@@ -216,7 +216,7 @@ gf3mathematical:
|
||||
$(GFNew) mathematical/MathematicalFre.gf
|
||||
$(GFNew) mathematical/MathematicalSwe.gf
|
||||
$(GFNew) mathematical/MathematicalFin.gf
|
||||
mv mathematical/*.gfc ../mathematical
|
||||
mv mathematical/*.gfo ../mathematical
|
||||
|
||||
gf3langs:
|
||||
mv ../present/LangSpa.gfo tmpLangSpa.gfo
|
||||
@@ -229,6 +229,10 @@ gf3langs:
|
||||
# mv tmpLangSpa.gfo ../alltenses/LangSpa.gfo
|
||||
|
||||
|
||||
overljs:
|
||||
gfc --make -js -jsref api/toplevel/OverLangEng.gf api/toplevel/OverLangSwe.gf api/toplevel/OverLangRus.gf +RTS -K100M
|
||||
mv grammar.js grammarReference.js ../../js/overl
|
||||
|
||||
clean:
|
||||
-rm -f */*.gfc */*.gfr */*.gf~ ../*/*.gfc ../*/*.gfr ../*/*.gf~ ../*/langs.gfcm ../compiled.tgz
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ fun ovrld70_mkNP : DConj -> ListNP -> NP ;
|
||||
fun ovrld71_mkDet : Quant -> Ord -> Det ;
|
||||
fun ovrld72_mkDet : Quant -> Det ;
|
||||
fun ovrld73_mkDet : Quant -> Num -> Ord -> Det ;
|
||||
fun ovrld74_mkDet : Quant -> Det ;
|
||||
fun ovrld75_mkDet : Quant -> Det ;
|
||||
----fun ovrld74_mkDet : Quant -> Det ;
|
||||
----fun ovrld75_mkDet : Quant -> Det ;
|
||||
fun ovrld76_mkDet : Quant -> Num -> Det ;
|
||||
fun ovrld77_mkDet : Num -> Det ;
|
||||
fun ovrld78_mkDet : Int -> Det ;
|
||||
@@ -87,8 +87,8 @@ fun ovrld81_defSgDet : Det ;
|
||||
fun ovrld82_defPlDet : Det ;
|
||||
fun ovrld83_indefSgDet : Det ;
|
||||
fun ovrld84_indefPlDet : Det ;
|
||||
fun ovrld85_mkQuantSg : Quant -> Quant ;
|
||||
fun ovrld86_mkQuantPl : Quant -> Quant ;
|
||||
----fun ovrld85_mkQuantSg : Quant -> Quant ;
|
||||
----fun ovrld86_mkQuantPl : Quant -> Quant ;
|
||||
fun ovrld87_defQuant : Quant ;
|
||||
fun ovrld88_indefQuant : Quant ;
|
||||
fun ovrld89_massQuant : Quant ;
|
||||
|
||||
@@ -1,282 +1,3 @@
|
||||
concrete OverGrammarEng of OverGrammar = StructuralEng,NumeralEng,ConjunctionEng[ListS,ListNP,ListAP,ListAdv] ** open GrammarEng in {
|
||||
lincat ImpForm = {p : PImpForm ; s : Str} ;
|
||||
lincat Punct = {p : PPunct ; s : Str} ;
|
||||
param PImpForm = IFSg | IFPl | IFPol ;
|
||||
param PPunct = PFullStop | PExclMark | PQuestMark ;
|
||||
oper mkUttImp : PImpForm -> Str -> Pol -> Imp -> Utt = \f,s,p,i -> {s = s ++ (case f of {
|
||||
IFSg => UttImpSg p i ; IFPl => UttImpPl p i ; IFPol => UttImpPol p i}).s ; lock_Utt = <>} ;
|
||||
oper mkPhrPunct : Phr -> PPunct -> Str -> Text -> Text = \p,f,s,t -> {s = s ++ (case f of {
|
||||
PFullStop => TFullStop p t ; PExclMark => TExclMark p t ; PQuestMark => TQuestMark p t}).s ;
|
||||
lock_Text = <>} ;
|
||||
lin ovrld0_mkAP = PositA ;
|
||||
lin ovrld1_mkAP = ComparA ;
|
||||
lin ovrld2_mkAP = ComplA2 ;
|
||||
lin ovrld3_mkAP = ReflA2 ;
|
||||
lin ovrld4_mkAP = \ap,s -> SentAP ap (EmbedS s) ;
|
||||
lin ovrld5_mkAP = \ap,s -> SentAP ap (EmbedQS s) ;
|
||||
lin ovrld6_mkAP = \ap,s -> SentAP ap (EmbedVP s) ;
|
||||
lin ovrld7_mkAP = \x,y -> AdAP x (PositA y) ;
|
||||
lin ovrld8_mkAP = AdAP ;
|
||||
lin ovrld9_mkAP = \c,x,y -> ConjAP c (BaseAP x y) ;
|
||||
lin ovrld10_mkAP = \c,x,y -> DConjAP c (BaseAP x y) ;
|
||||
lin ovrld11_mkAP = \c,xy -> ConjAP c xy ;
|
||||
lin ovrld12_mkAP = \c,xy -> DConjAP c xy ;
|
||||
lin ovrld13_mkAdv = PositAdvAdj ;
|
||||
lin ovrld14_mkAdv = PrepNP ;
|
||||
lin ovrld15_mkAdv = ComparAdvAdj ;
|
||||
lin ovrld16_mkAdv = ComparAdvAdjS ;
|
||||
lin ovrld17_mkAdv = AdAdv ;
|
||||
lin ovrld18_mkAdv = SubjS ;
|
||||
lin ovrld19_mkAdv = \c,x,y -> ConjAdv c (BaseAdv x y) ;
|
||||
lin ovrld20_mkAdv = \c,x,y -> DConjAdv c (BaseAdv x y) ;
|
||||
lin ovrld21_mkAdv = \c,xy -> ConjAdv c xy ;
|
||||
lin ovrld22_mkAdv = \c,xy -> DConjAdv c xy ;
|
||||
lin ovrld23_mkCl = PredVP ;
|
||||
lin ovrld24_mkCl = \s,v -> PredVP s (UseV v) ;
|
||||
lin ovrld25_mkCl = \s,v,o -> PredVP s (ComplV2 v o) ;
|
||||
lin ovrld26_mkCl = \s,v,o,i -> PredVP s (ComplV3 v o i) ;
|
||||
lin ovrld27_mkCl = \s,v,vp -> PredVP s (ComplVV v vp) ;
|
||||
lin ovrld28_mkCl = \s,v,p -> PredVP s (ComplVS v p) ;
|
||||
lin ovrld29_mkCl = \s,v,q -> PredVP s (ComplVQ v q) ;
|
||||
lin ovrld30_mkCl = \s,v,q -> PredVP s (ComplVA v q) ;
|
||||
lin ovrld31_mkCl = \s,v,n,q -> PredVP s (ComplV2A v n q) ;
|
||||
lin ovrld32_mkCl = ImpersCl ;
|
||||
lin ovrld33_mkCl = CleftNP ;
|
||||
lin ovrld34_mkCl = CleftAdv ;
|
||||
lin ovrld35_mkCl = \y -> ExistNP (DetCN (DetSg (IndefArt) NoOrd) (UseN y)) ;
|
||||
lin ovrld36_mkCl = \y -> ExistNP (DetCN (DetSg (IndefArt) NoOrd) y) ;
|
||||
lin ovrld37_mkCl = ExistNP ;
|
||||
lin ovrld38_mkCl = \x,y -> PredVP x (UseComp (CompAP y)) ;
|
||||
lin ovrld39_mkCl = \x,y -> PredVP x (UseComp (CompAP (PositA y))) ;
|
||||
lin ovrld40_mkCl = \x,y,z -> PredVP x (UseComp (CompAP (ComparA y z))) ;
|
||||
lin ovrld41_mkCl = \x,y,z -> PredVP x (UseComp (CompAP (ComplA2 y z))) ;
|
||||
lin ovrld42_mkCl = \x,y -> PredVP x (UseComp (CompNP y)) ;
|
||||
lin ovrld43_mkCl = \x,y -> PredVP x (UseComp (CompNP (DetCN (DetSg (IndefArt) NoOrd) y))) ;
|
||||
lin ovrld44_mkCl = \x,y -> PredVP x (UseComp (CompNP (DetCN (DetSg (IndefArt) NoOrd) (UseN y)))) ;
|
||||
lin ovrld45_mkCl = \x,y -> PredVP x (UseComp (CompAdv y)) ;
|
||||
lin ovrld46_mkCl = \v -> ImpersCl (UseV v) ;
|
||||
lin ovrld47_genericCl = GenericCl ;
|
||||
lin ovrld48_mkNP = DetCN ;
|
||||
lin ovrld49_mkNP = \d,n -> DetCN d (UseN n) ;
|
||||
lin ovrld50_mkNP = \d,n -> DetCN (DetPl (IndefArt) d NoOrd) n ;
|
||||
lin ovrld51_mkNP = \d,n -> DetCN (DetPl (IndefArt) d NoOrd) (UseN n) ;
|
||||
lin ovrld52_mkNP = \q,n -> DetCN (DetSg q NoOrd) n ;
|
||||
lin ovrld53_mkNP = \q,n -> DetCN (DetSg q NoOrd) (UseN n) ;
|
||||
--lin ovrld54_mkNP = \q,n -> DetCN (DetPl q NoNum NoOrd) n ;
|
||||
--lin ovrld55_mkNP = \q,n -> DetCN (DetPl q NoNum NoOrd) (UseN n) ;
|
||||
lin ovrld56_mkNP = \p,n -> DetCN (DetSg ((PossPron p)) NoOrd) n ;
|
||||
lin ovrld57_mkNP = \p,n -> DetCN (DetSg ((PossPron p)) NoOrd) (UseN n) ;
|
||||
lin ovrld58_mkNP = \d,n -> DetCN (DetPl (IndefArt) (NumNumeral d) NoOrd) n ;
|
||||
lin ovrld59_mkNP = \d,n -> DetCN (DetPl (IndefArt) (NumNumeral d) NoOrd) (UseN n) ;
|
||||
lin ovrld60_mkNP = \d,n -> DetCN (DetPl (IndefArt) (NumInt d) NoOrd) n ;
|
||||
lin ovrld61_mkNP = \d,n -> DetCN (DetPl (IndefArt) (NumInt d) NoOrd) (UseN n) ;
|
||||
lin ovrld62_mkNP = UsePN ;
|
||||
lin ovrld63_mkNP = UsePron ;
|
||||
lin ovrld64_mkNP = PredetNP ;
|
||||
lin ovrld65_mkNP = PPartNP ;
|
||||
lin ovrld66_mkNP = AdvNP ;
|
||||
lin ovrld67_mkNP = \c,x,y -> ConjNP c (BaseNP x y) ;
|
||||
lin ovrld68_mkNP = \c,x,y -> DConjNP c (BaseNP x y) ;
|
||||
lin ovrld69_mkNP = \c,xy -> ConjNP c xy ;
|
||||
lin ovrld70_mkNP = \c,xy -> DConjNP c xy ;
|
||||
lin ovrld71_mkDet = DetSg ;
|
||||
lin ovrld72_mkDet = \q -> DetSg q NoOrd ;
|
||||
lin ovrld73_mkDet = DetPl ;
|
||||
lin ovrld74_mkDet = \q -> DetPl q NoNum NoOrd ;
|
||||
lin ovrld75_mkDet = \q -> DetSg (q) NoOrd ;
|
||||
lin ovrld76_mkDet = \q,nu -> DetPl (q) nu NoOrd ;
|
||||
lin ovrld77_mkDet = \n -> DetPl (IndefArt) n NoOrd ;
|
||||
lin ovrld78_mkDet = \n -> DetPl (IndefArt) (NumInt n) NoOrd ;
|
||||
lin ovrld79_mkDet = \d -> DetPl (IndefArt) (NumNumeral d) NoOrd ;
|
||||
lin ovrld80_mkDet = \p -> DetSg ((PossPron p)) NoOrd ;
|
||||
lin ovrld81_defSgDet = DetSg (DefArt) NoOrd ;
|
||||
lin ovrld82_defPlDet = DetPl (DefArt) NoNum NoOrd ;
|
||||
lin ovrld83_indefSgDet = DetSg (IndefArt) NoOrd ;
|
||||
lin ovrld84_indefPlDet = DetPl (IndefArt) NoNum NoOrd ;
|
||||
lin ovrld85_mkQuantSg q = q ; ----SgQuant ;
|
||||
lin ovrld86_mkQuantPl q = q ; ----PlQuant ;
|
||||
lin ovrld87_defQuant = DefArt ;
|
||||
lin ovrld88_indefQuant = IndefArt ;
|
||||
lin ovrld89_massQuant = MassDet ;
|
||||
lin ovrld90_mkNum = NumNumeral ;
|
||||
lin ovrld91_mkNum = NumInt ;
|
||||
lin ovrld92_mkNum = \d -> NumNumeral (num (pot2as3 (pot1as2 (pot0as1 (pot0 d))))) ;
|
||||
lin ovrld93_mkNum = AdNum ;
|
||||
lin ovrld94_noNum = NoNum ;
|
||||
lin ovrld95_n1_Numeral = num (pot2as3 (pot1as2 (pot0as1 pot01))) ;
|
||||
lin ovrld96_n2_Numeral = num (pot2as3 (pot1as2 (pot0as1 (pot0 n2)))) ;
|
||||
lin ovrld97_n3_Numeral = num (pot2as3 (pot1as2 (pot0as1 (pot0 n3)))) ;
|
||||
lin ovrld98_n4_Numeral = num (pot2as3 (pot1as2 (pot0as1 (pot0 n4)))) ;
|
||||
lin ovrld99_n5_Numeral = num (pot2as3 (pot1as2 (pot0as1 (pot0 n5)))) ;
|
||||
lin ovrld100_n6_Numeral = num (pot2as3 (pot1as2 (pot0as1 (pot0 n6)))) ;
|
||||
lin ovrld101_n7_Numeral = num (pot2as3 (pot1as2 (pot0as1 (pot0 n7)))) ;
|
||||
lin ovrld102_n8_Numeral = num (pot2as3 (pot1as2 (pot0as1 (pot0 n8)))) ;
|
||||
lin ovrld103_n9_Numeral = num (pot2as3 (pot1as2 (pot0as1 (pot0 n9)))) ;
|
||||
lin ovrld104_n10_Numeral = num (pot2as3 (pot1as2 pot110)) ;
|
||||
lin ovrld105_n20_Numeral = num (pot2as3 (pot1as2 (pot1 n2))) ;
|
||||
lin ovrld106_n100_Numeral = num (pot2as3 (pot2 pot01)) ;
|
||||
lin ovrld107_n1000_Numeral = num (pot3 (pot1as2 (pot0as1 pot01))) ;
|
||||
lin ovrld108_mkAdN = AdnCAdv ;
|
||||
lin ovrld109_mkOrd = OrdNumeral ;
|
||||
lin ovrld110_mkOrd = OrdInt ;
|
||||
lin ovrld111_mkOrd = \d -> OrdNumeral (num (pot2as3 (pot1as2 (pot0as1 (pot0 d))))) ;
|
||||
lin ovrld112_mkOrd = OrdSuperl ;
|
||||
lin ovrld113_noOrd = NoOrd ;
|
||||
lin ovrld114_mkCN = UseN ;
|
||||
lin ovrld115_mkCN = ComplN2 ;
|
||||
lin ovrld116_mkCN = \f,x -> ComplN2 (ComplN3 f x) ;
|
||||
lin ovrld117_mkCN = UseN2 ;
|
||||
lin ovrld118_mkCN = UseN3 ;
|
||||
lin ovrld119_mkCN = AdjCN ;
|
||||
lin ovrld120_mkCN = \x,y -> AdjCN x (UseN y) ;
|
||||
lin ovrld121_mkCN = \x,y -> AdjCN y x ;
|
||||
lin ovrld122_mkCN = \x,y -> AdjCN y (UseN x) ;
|
||||
lin ovrld123_mkCN = \x,y -> AdjCN (PositA x) y ;
|
||||
lin ovrld124_mkCN = \x,y -> AdjCN (PositA x) (UseN y) ;
|
||||
lin ovrld125_mkCN = RelCN ;
|
||||
lin ovrld126_mkCN = \x,y -> RelCN (UseN x) y ;
|
||||
lin ovrld127_mkCN = AdvCN ;
|
||||
lin ovrld128_mkCN = \x,y -> AdvCN (UseN x) y ;
|
||||
lin ovrld129_mkCN = \cn,s -> SentCN cn (EmbedS s) ;
|
||||
lin ovrld130_mkCN = \cn,s -> SentCN cn (EmbedQS s) ;
|
||||
lin ovrld131_mkCN = \cn,s -> SentCN cn (EmbedVP s) ;
|
||||
lin ovrld132_mkCN = ApposCN ;
|
||||
lin ovrld133_mkCN = \x,y -> ApposCN (UseN x) y ;
|
||||
lin ovrld134_mkPhr = PhrUtt ;
|
||||
lin ovrld135_mkPhr = \u,v -> PhrUtt NoPConj u v ;
|
||||
lin ovrld136_mkPhr = \u,v -> PhrUtt u v NoVoc ;
|
||||
lin ovrld137_mkPhr = \u -> PhrUtt NoPConj u NoVoc ;
|
||||
lin ovrld138_mkPhr = \s -> PhrUtt NoPConj (UttS s) NoVoc ;
|
||||
lin ovrld139_mkPhr = \s -> PhrUtt NoPConj (UttS (UseCl TPres ASimul PPos s)) NoVoc ;
|
||||
lin ovrld140_mkPhr = \s -> PhrUtt NoPConj (UttQS s) NoVoc ;
|
||||
lin ovrld141_mkPhr = \s -> PhrUtt NoPConj (UttImpSg PPos s) NoVoc ;
|
||||
lin ovrld142_mkPConj = PConjConj ;
|
||||
lin ovrld143_noPConj = NoPConj ;
|
||||
lin ovrld144_mkVoc = VocNP ;
|
||||
lin ovrld145_noVoc = NoVoc ;
|
||||
lin ovrld146_positivePol = PPos ;
|
||||
lin ovrld147_negativePol = PNeg ;
|
||||
lin ovrld148_simultaneousAnt = ASimul ;
|
||||
lin ovrld149_anteriorAnt = AAnter ; --# notpresent
|
||||
lin ovrld150_presentTense = TPres ;
|
||||
lin ovrld151_pastTense = TPast ; --# notpresent
|
||||
lin ovrld152_futureTense = TFut ; --# notpresent
|
||||
lin ovrld153_conditionalTense = TCond ; --# notpresent
|
||||
lin ovrld154_singularImpForm = {p= IFSg; s= []} ;
|
||||
lin ovrld155_pluralImpForm = {p= IFPl; s= []} ;
|
||||
lin ovrld156_politeImpForm = {p= IFPol; s= []} ;
|
||||
lin ovrld157_mkUtt = UttS ;
|
||||
lin ovrld158_mkUtt = \c -> UttS (UseCl TPres ASimul PPos c) ;
|
||||
lin ovrld159_mkUtt = UttQS ;
|
||||
lin ovrld160_mkUtt = \f -> mkUttImp f.p f.s ;
|
||||
lin ovrld161_mkUtt = \f -> mkUttImp f.p f.s PPos ;
|
||||
lin ovrld162_mkUtt = UttImpSg ;
|
||||
lin ovrld163_mkUtt = UttImpSg PPos ;
|
||||
lin ovrld164_mkUtt = UttIP ;
|
||||
lin ovrld165_mkUtt = UttIAdv ;
|
||||
lin ovrld166_mkUtt = UttNP ;
|
||||
lin ovrld167_mkUtt = UttAdv ;
|
||||
lin ovrld168_mkUtt = UttVP ;
|
||||
lin ovrld169_lets_Utt = ImpPl1 ;
|
||||
lin ovrld170_mkQCl = QuestCl ;
|
||||
lin ovrld171_mkQCl = QuestVP ;
|
||||
lin ovrld172_mkQCl = QuestSlash ;
|
||||
lin ovrld173_mkQCl = \ip,np,v -> QuestSlash ip (SlashV2 np v) ;
|
||||
lin ovrld174_mkQCl = QuestIAdv ;
|
||||
lin ovrld175_mkQCl = \p,ip -> QuestIAdv (PrepIP p ip) ;
|
||||
lin ovrld176_mkQCl = \a -> QuestIComp (CompIAdv a) ;
|
||||
lin ovrld177_mkQCl = ExistIP ;
|
||||
lin ovrld178_mkIP = IDetCN ;
|
||||
lin ovrld179_mkIP = \i -> IDetCN i NoNum ;
|
||||
lin ovrld180_mkIP = \i,n -> IDetCN i n NoOrd ;
|
||||
lin ovrld181_mkIP = \i,n -> IDetCN i NoNum NoOrd (UseN n) ;
|
||||
lin ovrld182_mkIP = AdvIP ;
|
||||
lin ovrld183_mkIAdv = PrepIP ;
|
||||
lin ovrld184_mkRCl = RelCl ;
|
||||
lin ovrld185_mkRCl = RelVP ;
|
||||
lin ovrld186_mkRCl = RelSlash ;
|
||||
lin ovrld187_mkRCl = \rp,np,v2 -> RelSlash rp (SlashV2 np v2) ;
|
||||
lin ovrld188_which_RP = IdRP ;
|
||||
lin ovrld189_mkRP = FunRP ;
|
||||
lin ovrld190_mkSlash = SlashV2 ;
|
||||
lin ovrld191_mkSlash = SlashVVV2 ;
|
||||
lin ovrld192_mkSlash = AdvSlash ;
|
||||
lin ovrld193_mkSlash = SlashPrep ;
|
||||
lin ovrld194_mkImp = ImpVP ;
|
||||
lin ovrld195_mkImp = \v -> ImpVP (UseV v) ;
|
||||
lin ovrld196_mkImp = \v,np -> ImpVP (ComplV2 v np) ;
|
||||
lin ovrld197_mkS = UseCl TPres ASimul PPos ;
|
||||
lin ovrld198_mkS = \t -> UseCl t ASimul PPos ;
|
||||
lin ovrld199_mkS = \a -> UseCl TPres a PPos ;
|
||||
lin ovrld200_mkS = \p -> UseCl TPres ASimul p ;
|
||||
lin ovrld201_mkS = \t,a -> UseCl t a PPos ;
|
||||
lin ovrld202_mkS = \t,p -> UseCl t ASimul p ;
|
||||
lin ovrld203_mkS = \a,p -> UseCl TPres a p ;
|
||||
lin ovrld204_mkS = UseCl ;
|
||||
lin ovrld205_mkS = \c,x,y -> ConjS c (BaseS x y) ;
|
||||
lin ovrld206_mkS = \c,x,y -> DConjS c (BaseS x y) ;
|
||||
lin ovrld207_mkS = \c,xy -> ConjS c xy ;
|
||||
lin ovrld208_mkS = \c,xy -> DConjS c xy ;
|
||||
lin ovrld209_mkS = AdvS ;
|
||||
lin ovrld210_mkQS = UseQCl TPres ASimul PPos ;
|
||||
lin ovrld211_mkQS = \t -> UseQCl t ASimul PPos ;
|
||||
lin ovrld212_mkQS = \a -> UseQCl TPres a PPos ;
|
||||
lin ovrld213_mkQS = \p -> UseQCl TPres ASimul p ;
|
||||
lin ovrld214_mkQS = \t,a -> UseQCl t a PPos ;
|
||||
lin ovrld215_mkQS = \t,p -> UseQCl t ASimul p ;
|
||||
lin ovrld216_mkQS = \a,p -> UseQCl TPres a p ;
|
||||
lin ovrld217_mkQS = UseQCl ;
|
||||
lin ovrld218_mkQS = \x -> UseQCl TPres ASimul PPos (QuestCl x) ;
|
||||
lin ovrld219_mkRS = UseRCl TPres ASimul PPos ;
|
||||
lin ovrld220_mkRS = \t,c -> UseRCl t ASimul PPos c ;
|
||||
lin ovrld221_mkRS = \a,c -> UseRCl TPres a PPos c ;
|
||||
lin ovrld222_mkRS = \p,c -> UseRCl TPres ASimul p c ;
|
||||
lin ovrld223_mkRS = \t,a,c -> UseRCl t a PPos c ;
|
||||
lin ovrld224_mkRS = \t,p,c -> UseRCl t ASimul p c ;
|
||||
lin ovrld225_mkRS = \a,p,c -> UseRCl TPres a p c ;
|
||||
lin ovrld226_mkRS = UseRCl ;
|
||||
lin ovrld227_emptyText = TEmpty ;
|
||||
lin ovrld228_fullStopPunct = {p= PFullStop; s= []} ;
|
||||
lin ovrld229_questMarkPunct = {p= PQuestMark; s= []} ;
|
||||
lin ovrld230_exclMarkPunct = {p= PExclMark; s= []} ;
|
||||
lin ovrld231_mkText = \p,f -> mkPhrPunct p f.p f.s ;
|
||||
lin ovrld232_mkText = \p,f -> mkPhrPunct p f.p f.s TEmpty ;
|
||||
lin ovrld233_mkText = \x -> TFullStop x TEmpty ;
|
||||
lin ovrld234_mkText = \u -> TFullStop (PhrUtt NoPConj u NoVoc) TEmpty ;
|
||||
lin ovrld235_mkText = \s -> TFullStop (PhrUtt NoPConj (UttS s) NoVoc) TEmpty ;
|
||||
lin ovrld236_mkText = \c -> TFullStop (PhrUtt NoPConj (UttS (UseCl TPres ASimul PPos c)) NoVoc) TEmpty ;
|
||||
lin ovrld237_mkText = \q -> TQuestMark (PhrUtt NoPConj (UttQS q) NoVoc) TEmpty ;
|
||||
lin ovrld238_mkText = \i -> TExclMark (PhrUtt NoPConj (UttImpSg PPos i) NoVoc) TEmpty ;
|
||||
lin ovrld239_mkText = \p,i -> TExclMark (PhrUtt NoPConj (UttImpSg p i) NoVoc) TEmpty ;
|
||||
lin ovrld240_mkText = TFullStop ;
|
||||
lin ovrld241_mkVP = UseV ;
|
||||
lin ovrld242_mkVP = ComplV2 ;
|
||||
lin ovrld243_mkVP = ComplV3 ;
|
||||
lin ovrld244_mkVP = ComplVV ;
|
||||
lin ovrld245_mkVP = ComplVS ;
|
||||
lin ovrld246_mkVP = ComplVQ ;
|
||||
lin ovrld247_mkVP = ComplVA ;
|
||||
lin ovrld248_mkVP = ComplV2A ;
|
||||
lin ovrld249_mkVP = \a -> UseComp (CompAP (PositA a)) ;
|
||||
lin ovrld250_mkVP = \y,z -> (UseComp (CompAP (ComparA y z))) ;
|
||||
lin ovrld251_mkVP = \y,z -> (UseComp (CompAP (ComplA2 y z))) ;
|
||||
lin ovrld252_mkVP = \a -> UseComp (CompAP a) ;
|
||||
lin ovrld253_mkVP = \a -> UseComp (CompNP a) ;
|
||||
lin ovrld254_mkVP = \y -> (UseComp (CompNP (DetCN (DetSg (IndefArt) NoOrd) y))) ;
|
||||
lin ovrld255_mkVP = \y -> (UseComp (CompNP (DetCN (DetSg (IndefArt) NoOrd) (UseN y)))) ;
|
||||
lin ovrld256_mkVP = \a -> UseComp (CompAdv a) ;
|
||||
lin ovrld257_mkVP = AdvVP ;
|
||||
lin ovrld258_mkVP = AdVVP ;
|
||||
lin ovrld259_reflexiveVP = ReflV2 ;
|
||||
lin ovrld260_passiveVP = PassV2 ;
|
||||
lin ovrld261_passiveVP = \v,np -> (AdvVP (PassV2 v) (PrepNP by8agent_Prep np)) ;
|
||||
lin ovrld262_progressiveVP = ProgrVP ;
|
||||
lin ovrld263_mkListS = BaseS ;
|
||||
lin ovrld264_mkListS = ConsS ;
|
||||
lin ovrld265_mkListAP = BaseAP ;
|
||||
lin ovrld266_mkListAP = ConsAP ;
|
||||
lin ovrld267_mkListAdv = BaseAdv ;
|
||||
lin ovrld268_mkListAdv = ConsAdv ;
|
||||
lin ovrld269_mkListNP = BaseNP ;
|
||||
lin ovrld270_mkListNP = ConsNP ;
|
||||
}
|
||||
concrete OverGrammarEng of OverGrammar =
|
||||
StructuralEng,NumeralEng,ConjunctionEng[ListS,ListNP,ListAP,ListAdv] **
|
||||
OverGrammarI with (Grammar = GrammarEng) ;
|
||||
|
||||
@@ -84,8 +84,8 @@ lin ovrld70_mkNP = \c,xy -> DConjNP c xy ;
|
||||
lin ovrld71_mkDet = DetSg ;
|
||||
lin ovrld72_mkDet = \q -> DetSg q NoOrd ;
|
||||
lin ovrld73_mkDet = DetPl ;
|
||||
lin ovrld74_mkDet = \q -> DetPl q NoNum NoOrd ;
|
||||
lin ovrld75_mkDet = \q -> DetSg (q) NoOrd ;
|
||||
----lin ovrld74_mkDet = \q -> DetPl q NoNum NoOrd ;
|
||||
----lin ovrld75_mkDet = \q -> DetSg (q) NoOrd ;
|
||||
lin ovrld76_mkDet = \q,nu -> DetPl (q) nu NoOrd ;
|
||||
lin ovrld77_mkDet = \n -> DetPl (IndefArt) n NoOrd ;
|
||||
lin ovrld78_mkDet = \n -> DetPl (IndefArt) (NumInt n) NoOrd ;
|
||||
@@ -95,8 +95,8 @@ lin ovrld81_defSgDet = DetSg (DefArt) NoOrd ;
|
||||
lin ovrld82_defPlDet = DetPl (DefArt) NoNum NoOrd ;
|
||||
lin ovrld83_indefSgDet = DetSg (IndefArt) NoOrd ;
|
||||
lin ovrld84_indefPlDet = DetPl (IndefArt) NoNum NoOrd ;
|
||||
lin ovrld85_mkQuantSg q = q ; ----SgQuant ;
|
||||
lin ovrld86_mkQuantPl q = q ; ----PlQuant ;
|
||||
----lin ovrld85_mkQuantSg q = q ; ----SgQuant ;
|
||||
----lin ovrld86_mkQuantPl q = q ; ----PlQuant ;
|
||||
lin ovrld87_defQuant = DefArt ;
|
||||
lin ovrld88_indefQuant = IndefArt ;
|
||||
lin ovrld89_massQuant = MassDet ;
|
||||
|
||||
@@ -116,7 +116,7 @@ lin
|
||||
without_Prep = { s = "без" ; c = Gen};
|
||||
youPl_Pron = pronVu;
|
||||
yes_Phr = ss ["Да ."] ;
|
||||
youSg_Pron = pronVu;
|
||||
youSg_Pron = pronTu;
|
||||
youPol_Pron = pronVu;
|
||||
|
||||
--- NoDet = nikakojDet ** {n = Sg; g = PNoGen; c= Nom} ;
|
||||
|
||||
Reference in New Issue
Block a user