Skip to content

Commit

Permalink
Added Unknown word exception...
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Trott committed Aug 1, 2016
1 parent 76aa865 commit d3d3c60
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 20 deletions.
22 changes: 22 additions & 0 deletions compling.core/source/compling/parser/UnknownWordException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package compling.parser;

public class UnknownWordException extends ParserException {




public boolean isUnknown() {
return true;
}

private static final long serialVersionUID = -349091335193012818L; // is this okay? (ST)

public UnknownWordException() {
super();
}

public UnknownWordException(String message) {
super(message);
}

}
17 changes: 17 additions & 0 deletions compling.core/source/compling/parser/ecgparser/ECGAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,18 @@ public AnalyzerPrefs getPrefs() {
@SuppressWarnings({ "unchecked", "rawtypes" })
public ECGAnalyzer(Grammar ecgGrammar, AnalyzerPrefs prefs) throws IOException {




preferences = prefs;

//ecgGrammar.buildTokenAndMorpher();

grammar = new LCPGrammarWrapper(ecgGrammar);




mappingReader = new MappingReader(grammar);
//tokenReader = new ECGTokenReader(grammar);
//ecgmorph = new ECGMorph(grammar, tokenReader);
Expand Down Expand Up @@ -237,6 +243,17 @@ public ArrayList<String> getLexicon() {
return lexicon;
}

public ArrayList<String> getUtterances() {
UtteranceGenerator generator = new UtteranceGenerator(grammar);
return generator.generateUtterances("Utterance");
}

public ArrayList<String> getUtterances(String type) {
UtteranceGenerator generator = new UtteranceGenerator(grammar);
return generator.generateUtterances(type);
}


/** Reads token file into Parser again. Needs to be done when you want new tokens in lexicon. */
public void reloadTokens() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
<alwaysOnActionSet id="org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo"/>
<alwaysOnActionSet id="compling.gui.grammargui.actions.fileActionSet"/>
<show_view_action id="compling.gui.grammargui.views.GrammarTreeView"/>
<show_view_action id="compling.gui.grammargui.views.lexicon"/>
<show_view_action id="compling.gui.grammargui.views.tokenView"/>
<show_view_action id="compling.gui.grammargui.views.contentView"/>
<show_view_action id="compling.gui.grammargui.views.constructionHierarchy"/>
<show_view_action id="compling.gui.grammargui.views.schemaHierarchy"/>
Expand All @@ -69,19 +71,17 @@
<show_view_action id="compling.gui.grammargui.views.ontologyHierarchy"/>
<show_view_action id="compling.gui.grammargui.views.Analyzer"/>
<show_view_action id="org.eclipse.ui.console.ConsoleView"/>
<show_view_action id="org.eclipse.ui.views.BookmarkView"/>
<show_view_action id="org.eclipse.ui.views.ProblemView"/>
<show_view_action id="compling.gui.grammargui.views.commonExplorer"/>
<show_view_action id="org.eclipse.ui.views.ContentOutline"/>
<show_view_action id="compling.gui.grammargui.views.lexicon"/>
<show_view_action id="compling.gui.grammargui.views.tokenView"/>
<hide_toolbar_item_id id="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"/>
<view id="compling.gui.grammargui.views.GrammarTreeView"/>
<view id="compling.gui.grammargui.views.commonExplorer"/>
<view id="org.eclipse.ui.views.ContentOutline"/>
<view id="compling.gui.grammargui.views.analyzer2"/>
<view id="org.eclipse.ui.views.ProblemView"/>
<view id="org.eclipse.ui.console.ConsoleView"/>
<view id="compling.gui.grammargui.views.lexicon"/>
<fastViewBars/>
<layout>
<mainWindow>
Expand Down
1 change: 1 addition & 0 deletions compling.gui/ecgeditor.product
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
<plugin id="org.eclipse.ui.cocoa" fragment="true"/>
<plugin id="org.eclipse.ui.console"/>
<plugin id="org.eclipse.ui.editors"/>
<plugin id="org.eclipse.ui.editors.source"/>
<plugin id="org.eclipse.ui.forms"/>
<plugin id="org.eclipse.ui.ide"/>
<plugin id="org.eclipse.ui.navigator"/>
Expand Down
10 changes: 1 addition & 9 deletions compling.gui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,7 @@
id="compling.gui.grammargui.views.tokenView"
name="Token Adder">
</view>

<view
allowMultiple="false"
category="compling.gui.grammargui.categories.token"
class="compling.gui.grammargui.ui.views.GrammarGrapher"
icon="icons/latticeIcon.ico"
id="compling.gui.grammargui.views.grammarGrapher"
name="Grapher">
</view>


<view
allowMultiple="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;


import compling.gui.grammargui.model.IAnalyzerEditorInput;
import compling.gui.grammargui.model.IModelChangedListener;
import compling.gui.grammargui.ui.actions.PrintAction;
Expand Down Expand Up @@ -96,8 +95,15 @@ protected void createRawTextViewPage() {
transcript.setForeground(transcript.getDisplay().getSystemColor(SWT.COLOR_BLACK));

IAnalyzerEditorInput input = (IAnalyzerEditorInput) getEditorInput();

transcript.setText(input.getText());
long startTime = System.nanoTime();
String parseText = input.getText();
long endTime = System.nanoTime();
long duration = (endTime - startTime) / 1000000000;
String timeString = String.format("Time: %s second(s)", duration);
String finalTranscript = timeString + "\n" + parseText;
//transcript.setText(input.getText());
transcript.setText(finalTranscript);

addPage(IViewType.TRANSCRIPT, transcript);
setPageText(IViewType.TRANSCRIPT, "Text Output");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import compling.ontology.OWLTypeSystemNode;
import compling.parser.ecgparser.ECGTokenReader;
import compling.parser.ecgparser.LCPGrammarWrapper;
import compling.parser.ecgparser.UtteranceGenerator;
import compling.parser.ecgparser.ECGTokenReader.ECGToken;


Expand Down Expand Up @@ -330,8 +331,13 @@ protected void openEditorFor(TypeSystemNode node) throws PartInitException {

@Override
public void createPartControl(Composite parent) {
wrapper = new LCPGrammarWrapper(getGrammar());
wrapper = new LCPGrammarWrapper(getGrammar());

initializeData();

//UtteranceGenerator generator = new UtteranceGenerator(wrapper);
//generator.generateUtterances("VP");


final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
final ScrolledForm form = toolkit.createScrolledForm(parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ protected IStatus run(IProgressMonitor monitor) {
int failures = 0;
long startTime = System.nanoTime();
long analyzerTime = 0;
try {
//try {
long startupTimeOne = System.nanoTime();
ECGAnalyzer analyzer = new ECGAnalyzer(PrefsManager.getDefault().getGrammar());

ECGAnalyzer analyzer = PrefsManager.getDefault().getAnalyzer();//new ECGAnalyzer(PrefsManager.getDefault().getGrammar());
long startupTimeTwo = System.nanoTime();
analyzerTime = (startupTimeTwo - startupTimeOne) / 1000000000;

Expand All @@ -137,11 +138,12 @@ protected IStatus run(IProgressMonitor monitor) {
}
reportProgress(monitor, ++step, failures);
}
}
//}
/*
catch (IOException e) {
Log.logError(e, "Major problem while instantiating Analyzer");
return new JobStatus(IStatus.ERROR, this, "Problem initializing Analyzer object.");
}
} */
long endTime = System.nanoTime();

long duration = (endTime - startTime) / 1000000000;
Expand Down

0 comments on commit d3d3c60

Please sign in to comment.