Package ca.uwo.csd.ai.nlp.common

Examples of ca.uwo.csd.ai.nlp.common.SparseVector$Element


    @Override
    public double evaluate(svm_node x, svm_node y) {                       
        if (!(x.data instanceof SparseVector) || !(y.data instanceof SparseVector)) {
            throw new RuntimeException("Could not find sparse vectors in svm_nodes");
        }       
        SparseVector v1 = (SparseVector) x.data;
        SparseVector v2 = (SparseVector) y.data;
                       
        return v1.dot(v2);
    }   
View Full Code Here


    public double evaluate(svm_node x, svm_node y) {                       
        if (!(x.data instanceof SparseVector) || !(y.data instanceof SparseVector)) {
            throw new RuntimeException("svm_nodes should contain sparse vectors.");
        }
       
        SparseVector v1 = (SparseVector) x.data;
        SparseVector v2 = (SparseVector) y.data;
        double result = 0.0;
        int i = 0;
        int j = 0;       
       
        while (i < v1.size() && j < v2.size()) {
            Element e1 = v1.get(i);
            Element e2 = v2.get(j);
           
            if (e1.index == e2.index) {
                double d = e1.value - e2.value;
                result += d * d;
                i++;
                j++;
            } else if (e1.index < e2.index) {
                result += e1.value * e1.value;
                i++;
            } else {
                result += e2.value * e2.value;
                j++;
            }           
        }
       
        while (i < v1.size()) {
            Element e1 = v1.get(i);
            result += e1.value * e1.value;
            i++;
        }
       
        while (j < v2.size()) {
            Element e2 = v2.get(j);
            result += e2.value * e2.value;
            j++;
        }
       
        //System.out.println("score: " + result);
View Full Code Here

                System.err.println("Error in line " + lineCount);
                System.exit(-1);
            }
           
            labels.add(Double.parseDouble(tokens[0]));           
            SparseVector vector = new SparseVector(tokens.length - 1);
           
            for (int i = 1; i < tokens.length; i++) {
                String[] fields = tokens[i].split(":");
                if (fields.length < 2) {
                    System.err.println("Inappropriate file format: " + fileName);
                    System.err.println("Error in line " + lineCount);
                    System.exit(-1);
                }
                int index = Integer.parseInt(fields[0]);
                double value = Double.parseDouble(fields[1]);
                vector.add(index, value);
            }
           
            vectors.add(vector);
        }               
       
View Full Code Here

    /**
     * @see org.andromda.metafacades.uml.EventFacade#getTransition()
     */
    protected java.lang.Object handleGetTransition()
    {
        Element owner = this.metaObject.getOwner();
        if (owner instanceof Transition)
        {
            return owner;
        }
        return null;
View Full Code Here

    /**
     * @see org.andromda.metafacades.uml.EventFacade#getState()
     */
    protected java.lang.Object handleGetState()
    {
        Element owner = this.metaObject.getOwner();
        if (owner instanceof State)
        {
            return owner;
        }
        return null;
View Full Code Here

    /**
     * @see org.andromda.metafacades.uml.FrontEndController#getUseCase()
     */
    protected java.lang.Object handleGetUseCase()
    {
        Element owner = (Classifier)this.metaObject;
        while (!(owner == null || owner instanceof UseCase))
        {
            owner = owner.getOwner();
        }
        return owner;
    }
View Full Code Here

    /**
     * @see org.andromda.metafacades.uml.ActivityGraphFacade#getUseCase()
     */
    protected java.lang.Object handleGetUseCase()
    {
        Element owner = (this.metaObject).getOwner();
        if (owner instanceof UseCase)
        {
            return owner;
        }

View Full Code Here

    {
        // TODO: What should this method return ?
      // As I've seen in uml1.4 impl, it should return the statemachine which this element is the context for.
      // Let's say for UML2: Return the owner if the latter is a StateMachine
      StateMachine stateMachine = null;
        Element owner = this.metaObject.getOwner();
        if(owner instanceof StateMachine)
        {
          stateMachine = (StateMachine) owner;
        }
        return stateMachine;
View Full Code Here

    /**
     * @see org.andromda.metafacades.uml.GuardFacade#getTransition()
     */
    protected java.lang.Object handleGetTransition()
    {
        Element owner = this.metaObject.getOwner();
        if (owner instanceof Transition)
        {
            return owner;
        }
        return null;
View Full Code Here

    /**
     * @see org.andromda.metafacades.uml.StateVertexFacade#getStateMachine()
     */
    protected java.lang.Object handleGetStateMachine()
    {
        Element owner = this.metaObject;
        while (!(owner instanceof StateMachine))
        {
            owner = owner.getOwner();
        }
        return owner;
    }
View Full Code Here

TOP

Related Classes of ca.uwo.csd.ai.nlp.common.SparseVector$Element

Copyright © 2018 www.massapicom. 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.