Examples of Decision


Examples of gannuWSD.testing.Decision

   boolean osd;
   @Override
  public Decision disambiguate(AmbiguousWord target, ArrayList<AmbiguousWord> window) throws Exception
  {
    ArrayList<Sense> senses=target.getSenses();
    Decision decision=new Decision(target,window);
    int i;
    if (!osd || this.current.isOneSensePerDiscourse(target.getLemma()))
    {   
      int index=this.current.getMFS(target.getLemma());
      for(i=0;i<senses.size();i++)
      {
        ArrayList<String> dwords=new ArrayList<String>();
        if (index==i&&index>=0)
          decision.setSense(i, 1.0, dwords);
        else
          decision.setSense(i, 0.0, dwords);
      }
    }
    decision.calculateAnswer();
    return decision;
  }
View Full Code Here

Examples of gannuWSD.testing.Decision

  }
   @Override
  public Decision disambiguate(AmbiguousWord target, ArrayList<AmbiguousWord> window) throws Exception
  {
    ArrayList<Sense> senses=target.getSenses();
    Decision decision=new Decision(target,window);
    int i;
    for(i=0;i<senses.size();i++)
    {
      ArrayList<String> dwords=new ArrayList<String>();
      decision.setSense(i, 1.0/((double)(i+2)), dwords);
     
    }
    decision.calculateAnswer();
    return decision;
  }
View Full Code Here

Examples of gannuWSD.testing.Decision

  public Decision disambiguate(AmbiguousWord target,
      ArrayList<AmbiguousWord> window) throws Exception{
   
    if(this.classifier==null)
      this.classifier=this.getValue("classifier");
    Decision decision=new Decision(target,window);
        
      if(target.getSenses().size()>1)
    {
        Instances ins=this.loadFilteredInstances(target);
      System.out.println("Trying "+target.getIndex());
      Classifier cModel=null;
      String Evaluator=this.getValue("evaluator");
      String Search=this.getValue("search");
      if(Evaluator==null)
        Evaluator="";
      if(Search==null)
        Search="";
      File f=new File("data/weka/"+this.classifier+"@"+Dictionary.normalizeLemmaforFile(target.getLemma())+"@"+Evaluator+"@"+Search+".csf");
      if(f.exists())
      {
        cModel=(Classifier)Util.loadObject(f);
      }
      else
      {
        cModel = (Classifier)Class.forName(this.classifier).newInstance();       
             cModel.buildClassifier(ins);
             Util.writeObject(f, cModel);
      }
      //Instantiate the classifier
        Instance base=ins.firstInstance();
      Instance sample=new Instance(base.numAttributes());
      sample.setDataset(ins);
      int c[]=new int[base.numAttributes()];
      for(int i=0;i<base.numAttributes();i++)
      {
        c[i]=0;
      }
      for(int i=0;i<base.numAttributes();i++)
      {
        Attribute att=base.attribute(i);       
        for(AmbiguousWord word:window)
         {
           if(word.getLemma().equals(att.name()))
           {
             c[i]++; 
           }
         }
      }
      for(int i=0;i<base.numAttributes();i++)
      {
        sample.setValue(i, ((double)c[i]));
      }
     
      double []w=cModel.distributionForInstance(sample);
      for(int j=0;j<target.getSenses().size();j++)
      {
        ArrayList<String> dwords=new ArrayList<String>(window.size());
        for(AmbiguousWord word:window)
        {
          if(this.overlap(target.getSenses().get(j), word.getLemma()))
            dwords.add(word.getLemma());
        }
        decision.setSense(j, w[j], dwords);
      }
    }
    else
       decision.setSense(0, 0.1, new ArrayList<String>());
    decision.calculateAnswer();
    return decision;
  }
View Full Code Here

Examples of gannuWSD.testing.Decision

   @Override
  public Decision disambiguate(AmbiguousWord target, ArrayList<AmbiguousWord> window) throws Exception
  {
      System.out.print(".");
    ArrayList<Sense> senses=target.getSenses();
    Decision decision=new Decision(target,window);
    int i;
    for(i=0;i<senses.size();i++)
    {
      ArrayList<String> dwords=new ArrayList<String>();
      double w=0.0;
      for(AmbiguousWord winWord:window)
      {
        if(winWord.getSenses().size()>0)
        {
          for(Sense s:winWord.getSenses())
          {
            w+=this.scoring.calculateOverlap(senses.get(i).getBagOfWords(), s.getSynonyms(), dwords);
          }
        }
        else
        {
          if(senses.get(i).getBagOfWords().contains(winWord.getLemma()))
          {
            w+=1.0;
            dwords.add(winWord.getLemma());
          }
        }
 
      }
      dwords.trimToSize();
        decision.setSense(i, w, dwords);     
    }
    decision.calculateAnswer();   
     return decision;
  }
View Full Code Here

Examples of gannuWSD.testing.Decision

      for(SkipFilter skip:this.skipFilters)
        ban=ban&&skip.shouldITry(targetWord);
      if(targetWord.getSenses().size()>0)
      {
        ArrayList<AmbiguousWord> window= this.getWindow(target, document);       
        Decision d=new Decision(targetWord,window);
        d.calculateAnswer();
        if(ban)
        {
          d=this.disambiguate(targetWord, window);
          String t="true";
          if(t.equals(this.getValue("asFilter")))
          {
            for(int x=0;x<d.getSenseCount();x++)
            {
              if(d.getWeights()[x]>0.0)
              {
                d.getWeights()[x]=1.0;
              }
            }
            d.calculateAnswer();
          }
         
          if(d.isAttempted())
          {
            if(t.equals(this.getValue("asVoting")))
            {
              Decision d2=tie.disambiguate(targetWord, window);
              //normalize the weigths
              d.normalizeWeigths();
              if(d2.isAttempted())
              {
                d2.normalizeWeigths();
                for(int x=0;x<d.getSenseCount();x++)
                  d.getWeights()[x]+=d2.getWeights()[x];
                d.calculateAnswer();
              }
            } 
            else
            {
View Full Code Here

Examples of nexj.core.meta.workflow.Decision

    */
   protected Step loadQueue(Element queueElement, final Assignment assignment)
   {
      final Lookup eventMap = new HashTab();
      final Fork fork = new Fork();
      final Decision decision = new Decision();

      fork.setActivity(assignment.getActivity());
      decision.setActivity(assignment.getActivity());

      XMLUtil.forEachChildElement(queueElement, null,
         m_helper.new ElementHandler("queueEvent")
      {
         private boolean m_bTimer;

         protected String getName(Element eventElement)
         {
            return XMLUtil.getStringAttr(eventElement, "name");
         }

         public void handleElement(Element eventElement, String sEventName)
         {
            Node child = eventElement.getFirstChild();
            String sElement = eventElement.getNodeName();
            Concurrent activity = new Concurrent();
            Branch branch = null;

            activity.setFork(fork);

            if (sElement.equals("TimerEvent"))
            {
               if (m_bTimer)
               {
                  throw new MetadataException("err.meta.workflow.multipleQueueTimers",
                     new Object[]{assignment.getName()});
               }

               Timeout timeout = new Timeout();

               timeout.setActivity(activity);
               timeout.setValue(m_helper.parse(XMLUtil.getReqStringAttr(eventElement, "value"),
                  false, activity.getFlow().getPosMap(), null, m_metadata.getGlobalEnvironment()));
               activity.addStep(timeout);

               Wait wait = new Wait(timeout);

               timeout.setNext(wait);
               activity.addStep(wait);

               m_bTimer = true;
            }
            else if (sElement.equals("ClassEvent"))
            {
               AutoCompletion completion = new AutoCompletion(assignment);

               loadWorkflowHandler(eventElement, completion, activity.getFlow());
               activity.addStep(completion);
            }
            else if (sElement.equals("ManualEvent"))
            {
               Object condition = m_helper.parse(XMLUtil.getStringAttr(eventElement, "condition"),
                  false, assignment.getActivity().getFlow().getPosMap(),
                  Boolean.TRUE, m_metadata.getGlobalEnvironment());
               boolean bTarget = loadTarget(eventElement, assignment, condition, sEventName, false);
               Element first = XMLUtil.findFirstElement(child);

               if (first != null && first.getNodeName().equals("UIAction"))
               {
                  loadTarget(first, assignment, condition, sEventName, bTarget);
                  child = first.getNextSibling();
               }

               if (assignment.getManualCompletion() == null)
               {
                  ManualCompletion completion = new ManualCompletion(assignment);

                  activity.addStep(completion);
               }
               else
               {
                  activity = null;
               }
            }
            else if (sElement.equals("ProcessEvent"))
            {
               branch = new Branch();
               decision.addBranch(branch);

               assignment.setSemaphore(true);

               Semaphore semaphore = new Semaphore(assignment.getName() + ":Semaphore", assignment);

               semaphore.setActivity(activity);
               activity.addStep(semaphore);

               Block block = new Block();

               block.setActivity(branch);
               branch.addStep(block);
               loadActivity(child, block.getContainedActivity());
               block.setCleanupCode(semaphore.getExitCode());
            }
            else
            {
               throw new MetadataException("err.meta.workflow.invalidQueueElement",
                  new Object[]{sElement, assignment.getName()});
            }

            if (eventMap.put(sEventName, Boolean.TRUE) != null)
            {
               throw new MetadataException("err.meta.workflow.queueEventDup",
                  new Object[]{sEventName, assignment.getName()});
            }

            Variable var = assignment.getActivity().getFlow().findVariable(assignment.getName());

            if (var == null)
            {
               var = new Variable(assignment.getName());
               assignment.getActivity().getFlow().addVariable(var);
            }

            if (activity != null)
            {
               Object code;

               if (activity.getStep(0) instanceof ManualCompletion)
               {
                  // ((:state'bind ('<assignment>'targetFunction)) '() (:flow'getToken <step>))
                  code =
                     Pair.list(
                        Pair.list(Symbol._STATE, Pair.quote(Symbol.BIND),
                           Pair.list(Pair.quote(assignment), Pair.quote(Symbol.TARGETFUNCTION))),
                        null,
                        Pair.list(Symbol._FLOW, Pair.quote(Symbol.GETTOKEN), Pair.quote(activity.getStep(0))));
               }
               else
               {
                  code = sEventName;
               }

               Script script = new Script();

               script.setBody(Pair.list(Pair.list(Symbol.SET, var.getSymbol(), code)));
               activity.addStep(script);
               fork.addConcurrent(activity);
            }

            if (branch == null)
            {
               branch = new Branch();
               decision.addBranch(branch);
               loadActivity(child, branch);
            }

            branch.setCondition(Pair.list(Symbol.EQUAL_P, var.getSymbol(), sEventName));
         }
      });

      if (fork.getConcurrentCount() == 0)
      {
         throw new MetadataException("err.meta.workflow.eventlessQueue",
            new Object[]{assignment.getName()});
      }

      if (fork.getConcurrentCount() == 1)
      {
         Activity activity = fork.getConcurrent(0);

         if (activity.getStep(0) instanceof Timeout)
         {
            activity.addStep(new Completion(assignment));
         }

         if (decision.getBranchCount() > 1)
         {
            for (int i = 0; i != activity.getStepCount(); ++i)
            {
               assignment.getActivity().addStep(activity.getStep(i));
            }

            return decision;
         }

         if (decision.getBranch(0).getStepCount() != 0)
         {
            for (int i = 0; i != activity.getStepCount(); ++i)
            {
               assignment.getActivity().addStep(activity.getStep(i));
            }

            activity = decision.getBranch(0);

            for (int i = 0; i != activity.getStepCount() - 1; ++i)
            {
               assignment.getActivity().addStep(activity.getStep(i));
            }
View Full Code Here

Examples of org.apache.commons.collections.Trie.Cursor.Decision

            final Cursor<? super K, ? super V> cursor,
            final Reference<Map.Entry<K, V>> reference) {

        if (h.bitIndex <= bitIndex) {
            if (!h.isEmpty()) {
                final Decision decision = cursor.select(h);
                switch(decision) {
                    case REMOVE:
                        throw new UnsupportedOperationException("Cannot remove during select");
                    case EXIT:
                        reference.set(h);
View Full Code Here

Examples of org.ardverk.collection.Cursor.Decision

      final K key, final Cursor<? super K, ? super V> cursor,
      final Reference<Map.Entry<K, V>> reference) {

    if (h.bitIndex <= bitIndex) {
      if (!h.isEmpty()) {
        Decision decision = cursor.select(h);
        switch(decision) {
          case REMOVE:
            throw new UnsupportedOperationException(
                "Cannot remove during select");
          case EXIT:
View Full Code Here

Examples of org.drools.jpdl.core.node.Decision

            }
            node = newNode;
        } else if (jPDLnode instanceof org.jbpm.graph.node.Decision) {
            org.jbpm.graph.node.Decision jPDLdecision =
                    (org.jbpm.graph.node.Decision) jPDLnode;
            Decision newNode = new Decision();
            newNode.setDecisionConditions(jPDLdecision.getDecisionConditions());
            // TODO: unable to access decisionDelegation
            // TODO: unable to access decisionExpression
            node = newNode;
        } else if (jPDLnode instanceof org.jbpm.graph.node.ProcessState) {
            org.jbpm.graph.node.ProcessState jPDLprocessState =
                    (org.jbpm.graph.node.ProcessState) jPDLnode;
            ProcessState newNode = new ProcessState();
            ProcessDefinition subProcessDefinition =
                    jPDLprocessState.getSubProcessDefinition();
            if (subProcessDefinition != null) {
                newNode.setSubProcessName(subProcessDefinition.getName());
                // TODO: parse sub process definition as well
            }
            // TODO: unable to access subProcessName
            // TODO: unable to access variableAccesses
            node = newNode;
        } else if (jPDLnode instanceof org.jbpm.graph.def.SuperState) {
            org.jbpm.graph.def.SuperState jPDLsuperState =
                    (org.jbpm.graph.def.SuperState) jPDLnode;
            SuperState newNode = new SuperState();
            List<org.jbpm.graph.def.Node> nodes = jPDLsuperState.getNodes();
            Map<org.jbpm.graph.def.Node, Node> mapping = new HashMap<org.jbpm.graph.def.Node, Node>();
            for (org.jbpm.graph.def.Node nodeInsideSuperState : nodes) {
                JpdlNode nodeToAdd = classifyNode(processDefinition, nodeInsideSuperState, swimlaneContext);
                if (nodeToAdd == null) {
                    throw new IllegalArgumentException(
                            "Unknown node type: " + jPDLnode.getClass().getName() + " " + jPDLnode);
                }
                setDefaultNodeProperties(nodeInsideSuperState, (JpdlNode) nodeToAdd);
                nodeToAdd.setId(++nodeId);
                mapping.put(nodeInsideSuperState, nodeToAdd);
                newNode.addNode(nodeToAdd);
            }
            generateConnections(mapping);
            node = newNode;
        } else if (jPDLnode instanceof org.jbpm.graph.node.TaskNode) {
            org.jbpm.graph.node.TaskNode jPDLtaskNode =
                    (org.jbpm.graph.node.TaskNode) jPDLnode;
            TaskNode newNode = new TaskNode();
            Set<Task> tasks = jPDLtaskNode.getTasks();
            newNode.setTasks(tasks);
            newNode.setSignal(jPDLtaskNode.getSignal());
            newNode.setCreateTasks(jPDLtaskNode.getCreateTasks());
            newNode.setEndTasks(jPDLtaskNode.isEndTasks());
            for (Task task : tasks) {
                org.jbpm.taskmgmt.def.Swimlane jPDLswimlane = task.getSwimlane();
                if (jPDLswimlane != null) {
                    String swimlaneName = jPDLswimlane.getName();
                    if (swimlaneContext.getSwimlane(swimlaneName) == null) {
View Full Code Here

Examples of org.elasticsearch.cluster.routing.allocation.decider.Decision

    }

    public static RerouteExplanation readFrom(StreamInput in) throws IOException {
        String commandName = in.readString();
        AllocationCommand command = AllocationCommands.lookupFactorySafe(commandName).readFrom(in);
        Decision decisions = Decision.readFrom(in);
        return new RerouteExplanation(command, decisions);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.