Skip to content

Commit

Permalink
Dev branch commit. Ontology now gets rebuilt when tokens are added, w…
Browse files Browse the repository at this point in the history
…ithout checking grammar. Changed compatibleTypes in FeatureStructureSet.java.
  • Loading branch information
Sean Trott committed Sep 14, 2015
1 parent bec20f9 commit b02ee91
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 73 deletions.
1 change: 1 addition & 0 deletions compling.core/source/compling/context/ContextModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ else if (ontFile.getName().endsWith("." + instFileExtension)) {
}
}
ontologySpec.append(defs).append(insts);
System.out.println(ontologySpec.toString());
instantiate(new BufferedReader(new InputStreamReader(new StringBufferInputStream(ontologySpec.toString()),
charSet)), "ontology definitions");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,13 @@ private boolean compatibleTypes(TypeConstraint thatType) {
return true;
} else if (thisType != null && thatType == null) {
return true;
} else if (thisType.typeSystem != thatType.typeSystem) {
} else if (! thisType.typeSystem.getName().equals(thatType.typeSystem.getName())) {
return false;
}
//else if (thisType.typeSystem != thatType.typeSystem) {
// System.out.println("Type systems featurestructureset line 416-----------------");
// return false;
// }
else { // now that both slots have compatible type systems
// Check if either slot is "negated" type: e.g., slot constrained to be anything BUT a type
if (thatType.negated() || thisType.negated()) {
Expand All @@ -433,8 +437,21 @@ private boolean compatibleTypes(TypeConstraint thatType) {
return false;
}
} catch (TypeSystemException tse) {
throw new GrammarException(tse + ".\nThis.typeSystem=" + thisType.getTypeSystem().getName()
+ " and thatType.typeSystem=" + thatType.getTypeSystem().getName());
try {
if (thatType.typeSystem.subtype(thisType.type, thatType.type)) {
// this type is more specific
return true;
} else if (thatType.typeSystem.subtype(thatType.type, thisType.type)) {
// that type is more specific
typeConstraint = thatType;
return true;
} else {
return false;
}
} catch (TypeSystemException e) {
throw new GrammarException(tse + ".\n" + thisType.getType() +".typeSystem=" + thisType.getTypeSystem().getName()
+ " and " + thatType.getType() + ".typeSystem=" + thatType.getTypeSystem().getName());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public Set<N> getChildren(String type) {
return children.containsKey(type) ? children.get(type) : new HashSet<N>();
}


public Set<N> getParents(TypeSystemNode typeSystemNode) {
HashSet<N> parents = new HashSet<N>();
for (String parent : typeSystemNode.getParents()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ public PriorityQueue<List<T>> getBestPartialParses(Utterance<Word, String> utter

constructionInput = new ArrayList<ArrayList<Construction>>();
morphToken = new ArrayList<ArrayList<MorphTokenPair>>();


for (int i = 0; i < utterance.size(); i++) {
try {
Expand Down Expand Up @@ -1522,7 +1523,7 @@ private <T> PriorityQueue<T> prune(PriorityQueue<T> queue, int maxBeamWidth, int
T p = queue.next();
prunedQueue.add(p, score);
i++;
if (i >= maxBeamWidth || score > bestScore + beamSize) {
if (i >= maxBeamWidth || score > (bestScore + beamSize)) {
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public SlotConnectionTracker(LCPGrammarWrapper g, CloneTable ct, UnifyTable ut,
setup(g, ct, ut, sct, ctsct, cect, clct);

// TODO: 1. Build the list of all the roles here!
// TODO: 2. Memoize getRules
// TODO: 2. Memoize getRules (DONE)

for (int i = 1; i < MAXDIST; i++) {
// System.out.println("-----------------------------------------------------------------------------------------------------\n"+"i="+i+"\n----");
Expand Down
21 changes: 1 addition & 20 deletions compling.gui/ecgeditor.product
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,11 @@
<plugin id="org.eclipse.core.expressions"/>
<plugin id="org.eclipse.core.filebuffers"/>
<plugin id="org.eclipse.core.filesystem"/>
<plugin id="org.eclipse.core.filesystem.aix.ppc" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.aix.ppc64" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.hpux.ia64" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.java7" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.linux.ppc" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.linux.ppc64" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.linux.ppc64le" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.linux.x86" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.linux.x86_64" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.macosx" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.solaris.sparc" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.win32.x86" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.win32.x86_64" fragment="true"/>
<plugin id="org.eclipse.core.jobs"/>
<plugin id="org.eclipse.core.net"/>
<plugin id="org.eclipse.core.net.linux.x86" fragment="true"/>
<plugin id="org.eclipse.core.net.linux.x86_64" fragment="true"/>
<plugin id="org.eclipse.core.net.win32.x86" fragment="true"/>
<plugin id="org.eclipse.core.net.win32.x86_64" fragment="true"/>
<plugin id="org.eclipse.core.resources"/>
<plugin id="org.eclipse.core.resources.win32.x86" fragment="true"/>
<plugin id="org.eclipse.core.resources.win32.x86_64" fragment="true"/>
<plugin id="org.eclipse.core.runtime"/>
<plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/>
<plugin id="org.eclipse.core.variables"/>
Expand Down Expand Up @@ -107,6 +90,7 @@
<plugin id="org.eclipse.equinox.ds"/>
<plugin id="org.eclipse.equinox.event"/>
<plugin id="org.eclipse.equinox.launcher"/>
<plugin id="org.eclipse.equinox.launcher.cocoa.macosx.x86_64" fragment="true"/>
<plugin id="org.eclipse.equinox.p2.core"/>
<plugin id="org.eclipse.equinox.p2.engine"/>
<plugin id="org.eclipse.equinox.p2.metadata"/>
Expand All @@ -116,10 +100,7 @@
<plugin id="org.eclipse.equinox.registry"/>
<plugin id="org.eclipse.equinox.security"/>
<plugin id="org.eclipse.equinox.security.macosx" fragment="true"/>
<plugin id="org.eclipse.equinox.security.win32.x86" fragment="true"/>
<plugin id="org.eclipse.equinox.security.win32.x86_64" fragment="true"/>
<plugin id="org.eclipse.equinox.util"/>
<plugin id="org.eclipse.equinox.weaving.hook" fragment="true"/>
<plugin id="org.eclipse.help"/>
<plugin id="org.eclipse.jface"/>
<plugin id="org.eclipse.jface.databinding"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ public class AnalysisEditor extends MultiPageEditorPart implements IModelChange
private AnalysisOutline outline;
private AnalysisHtmlBuilder htmlBuilder;

private Text annotationText;

private AnnotatedAnalysis annotationTool;

private interface IViewType {
public int TRANSCRIPT = 0;
public int HTML = 1;
public int ANNOTATION = 2;
// public int ALTERNATE = 1;
// public int GRAPHICAL = 2;
}



public AnalysisEditor() {
Expand All @@ -58,6 +64,20 @@ public void print() {
if (0 <= b && b < browsers.size())
browsers.get(b).execute("javascript:print()");
}

protected void createAnnotationPage() {
Browser b = new Browser(getContainer(), SWT.NONE);
annotationTool = new AnnotatedAnalysis();
annotationText = new Text(getContainer(), SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
IAnalyzerEditorInput input = (IAnalyzerEditorInput) getEditorInput();
Analysis first = input.getParses().iterator().next().getAnalyses().iterator().next();
String text = annotationTool.getAnnotatedText(input.getSentence().getText(), first);
annotationText.setText(text);
addPage(IViewType.ANNOTATION, annotationText);
b.setText(text);
//addPage(IViewType.ANNOTATION, b);
setPageText(IViewType.ANNOTATION, "Annotation");
}

protected void createRawTextViewPage() {
transcript = new Text(getContainer(), SWT.BORDER | SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.H_SCROLL
Expand Down Expand Up @@ -93,51 +113,7 @@ protected void crateBrowserPages() {



// protected void createHtmlViewPage() {
// alternate = new Text(getContainer(), SWT.BORDER | SWT.READ_ONLY |
// SWT.MULTI
// | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL);
// alternate.setLayoutData(new FillLayout(SWT.HORIZONTAL | SWT.VERTICAL));
// alternate.setBackground(alternate.getDisplay().getSystemColor(SWT.COLOR_WHITE));
// alternate.setForeground(alternate.getDisplay().getSystemColor(SWT.COLOR_BLACK));
// alternate.setText(getHtmlText());
// addPage(ViewType.ALTERNATE, alternate);
// setPageText(ViewType.ALTERNATE, "HTML Output");
// }

// protected void createHtmlBrowserPages(Analysis analysis, IAnalyzerEditorInput input) {
// Browser browser = new Browser(getContainer(), SWT.NONE);
// browser.setLayoutData(new FillLayout(SWT.HORIZONTAL | SWT.VERTICAL));
// FeatureStructureFormatter formatter = new HtmlFeatureStructureFormatter(emitter);
//
// browser.setText(getHtmlText(formatter, analysis, input));
// browsers.add(browser);
// // browser.setText("<p>cacca</p>");
// addPage(IViewType.HTML, browser);
// setPageText(IViewType.HTML, "SemSpec");
// }

// protected void createGraphicalViewPage() {
// graph = new Graph(getContainer(), SWT.NONE);
//
// GraphContainer c = new GraphContainer(graph, SWT.NONE, "What is this?");
//
// GraphNode n1 = new GraphNode(c, SWT.NONE, "Paper");
// GraphNode n2 = new GraphNode(c, SWT.NONE, "Rock");
// GraphNode n3 = new GraphNode(graph, SWT.NONE, "Scissors");
//
// // c.setLayoutAlgorithm(new SpringLayoutAlgorithm(), true);
//
// new GraphConnection(graph, SWT.NONE, n1, n2);
// new GraphConnection(graph, SWT.NONE, n2, n3);
// new GraphConnection(graph, SWT.NONE, n3, n1);
//
// graph.setLayoutAlgorithm(new SpringLayoutAlgorithm(
// LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
//
// addPage(ViewType.GRAPHICAL, graph);
// setPageText(ViewType.GRAPHICAL, "Graphical Output");
// }


@Override
public void setFocus() {
Expand All @@ -146,6 +122,8 @@ public void setFocus() {
transcript.setFocus();
else if (page <= browsers.size())
browsers.get(page - 1).setFocus();
else if (page == IViewType.ANNOTATION)
annotationText.setFocus();
else
Log.logInfo("!!! no active page");
}
Expand Down Expand Up @@ -187,6 +165,7 @@ protected void createPages() {
register();
createRawTextViewPage();
crateBrowserPages();
//createAnnotationPage();
updateTitle();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ private void rebuildOntology() {
try {
contextModel = buildContextModel(gatherer);
getGrammar().setContextModel(contextModel);
//getGrammar().update();
TypeSystem ts = getGrammar().getOntologyTypeSystem();
System.out.println(getGrammar().getOntologyTypeSystem().getCanonicalTypeConstraint("green"));
} catch (CoreException e) {
e.printStackTrace();
broadcastError("Problem rebuilding ontology...");
}

}


Expand Down Expand Up @@ -237,8 +239,8 @@ private void addOntologyItem(String value, String parent, String ontologyFile) {
throw new IOException();
}
System.out.println(tempFile);
PrefsManager.getDefault().checkGrammar();
//rebuildOntology();
//PrefsManager.getDefault().checkGrammar();
rebuildOntology();
} catch (IOException problem) {
broadcastError("Something went wrong with modifying the ontology file " + ontologyFile + " with type " + value
+ "and parent " + parent + ".");
Expand Down

0 comments on commit b02ee91

Please sign in to comment.