package ever.simpleCooking; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import ever.pipeline.AbstractLocalInputAnalyzer; import ever.pipeline.Case; import ever.pipeline.Sentence; import ever.workflowRepresentation.EmptyProductException; import ever.workflowRepresentation.NotAProductException; import ever.workflowRepresentation.Sequence; import ever.workflowRepresentation.SimpleFacet; import ever.workflowRepresentation.SimpleProduct; import ever.workflowRepresentation.Task; import ever.workflowRepresentation.Workflow; import ever.workflowRepresentation.WorkflowElement; /** * This analyzer searches for cases where two verbs at the beginning of sentence are seperated by an "and". That results in two task in sequence * @author Pol Schumacher, Wirtschaftsinformatik, Institut fuer Informatik, Goethe Universitaet Frankfurt Input workflow must be flat */ public class LocalPrepAndAtTheBeginning extends AbstractLocalInputAnalyzer { @Override public Case analyze(Case c) { Workflow wf = c.getWf(); Sequence seq = null; ArrayList taskList = new ArrayList(); if (wf == null) { wf = new Workflow(); seq = new Sequence(null,null); } else { seq = (Sequence) wf.getTopSequence(); } ArrayList senList = c.getSentences(); for (int i = 0; i < senList.size(); i++) { Sentence s = senList.get(i); taskList = new ArrayList(); if (s.getClauseList().size() < 3) continue; if (s.getRaw().contains(" and ") & s.getClauseList().get(0).getWholeTyp() .equals("VP SEGMENT (ACTIVE_VERB):") & s.getClauseList().get(1).getValue().equals("and ")) { Task t = new Task(wf.getTopSequence(),s, s.getClauseList().get(0) .getValue().toLowerCase()); SimpleFacet sourceSentence = new SimpleFacet("SourceSentence", s.getRaw()); t.addFacet(sourceSentence); t.addFacet(new SimpleFacet("Test", "and at beginning")); taskList.add(t); } if (s.getRaw().contains(" and ") & s.getClauseList().get(2).getWholeTyp() .equals("VP SEGMENT (ACTIVE_VERB):") & s.getClauseList().get(1).getValue().equals("and ")) { Task t = new Task(wf.getTopSequence(),s, s.getClauseList().get(2) .getValue().toLowerCase()); SimpleFacet sourceSentence = new SimpleFacet("SourceSentence", s.getRaw()); t.addFacet(sourceSentence); taskList.add(t); } if (taskList.size() == 0) continue; // Put new task on the right position in sequence for (Task t : taskList) { ArrayList list = s.getRelatedElem(); if (list.size() == 0) { if (senList.indexOf(s) > 0) { // Get index of last task of the previous sentence int index = super.getNextRelated(senList, s, seq); seq.putElementAt(t, index + 1); } else { seq.addWfElement(t); } } else { try { int index = super.getWfePosition(s, list, t, seq); seq.putElementAt(t,index); } catch (Exception e) { e.printStackTrace(); } } s.addRelWfElement(t); senList.set(i, s); } } wf.setTopSequence(seq); c.setWf(wf); return c; } @Override public HashMap analyze(HashMap c) { // TODO Auto-generated method stub // throw new NotImplementedException(); return null; } @Override public void analyze() { // throw new NotImplementedException(); } }