/**
 * Created by uetsujitomoya on 2017/09/04.
 */

import Node from "../js/defineNodeClass.js";
import Arrow from "../js/defineArrowClass.js"

let createNodeAndArrowArray=(sentenceArray)=>{
    let arrowArray=[]
    let nodeArray=[]
    //KNP_sentence_array.forEach((sentence)=>{
    for(let sentenceNum=0;sentenceNum<sentenceArray.length;sentenceNum++){
        let sentence=sentenceArray[sentenceNum]
        console.log(sentence)

        let containsVerbArray = {
            value: 'verb_array' in sentence ? sentence.verb_array : 'No'
        }

        if(containsVerbArray.value=='No'){continue}

        sentence.verb_array.forEach((verb)=>{

            if(existsObject(verb)){
                let isNewArrow=true
                for(let tempNodeNum=0;tempNodeNum<nodeArray.length;tempNodeNum++){
                    if ( isSameArrow ( arrowArray[tempNodeNum] , verb ) ) {
                        nodeArray[tempNodeNum].addNodeStrokeWidth()
                        isNewArrow=false
                        break
                    }
                }
                if(isNewArrow){
                    arrowArray.push(new Arrow(verb))
                }
            }else if(existsSubject(verb)){
                let isNewNode=true
                for(let tempNodeNum=0;tempNodeNum<nodeArray.length;tempNodeNum++){
                    if ( isSameNode ( nodeArray[tempNodeNum] , verb ) ) {
                        nodeArray[tempNodeNum].addNodeStrokeWidth()
                        isNewNode=false
                        break
                    }
                }
                if(isNewNode){
                    nodeArray.push(new Node(verb))
                }
            }
        })
    }

    console.log(nodeArray)
    console.log(arrowArray)
}

let isSameArrow=(node,verb)=>{
    if ( (node.subject==verb.subject) && (node.object==verb.object)){
        return true
    }else{
        return false
    }
}

let existsObject=(verb)=>{
    if(verb.object=='null'){
        return false
    }else{
        return true
    }

}

let existsSubject=(verb)=>{
    if(verb.subject='null'){
        return false
    }else{
        return true
    }
}

//let isNewNode=()=>{



//let isNewArrow=()=>{



let createNode=()=>{


}

let createArrow=()=>{

}
/*
class Node{
    constructor(){
        this.xml
        this.y;
        this.r;
        this.strokeColor
    }
}
class Arrow{
    constructor(){

    }
}*/

export {createNodeAndArrowArray}
@@ -738,36 +738,37 @@
     for(let temp
-Node
+Arrow
 Num=0;tempNodeNu
@@ -753,36 +753,37 @@
 pArrowNum=0;temp
-Node
+Arrow
 Num%3CnodeArray.le
@@ -783,36 +783,37 @@
 rray.length;temp
-Node
+Arrow
 Num++)%7B%0A        
@@ -850,36 +850,37 @@
  arrowArray%5Btemp
-Node
+Arrow
 Num%5D , verb ) ) 
@@ -915,36 +915,37 @@
 deArray%5Btemp
-Node
+Arrow
 Num%5D.add
 NodeStrokeWi
@@ -924,36 +924,37 @@
 empArrowNum%5D.add
-Node
+Arrow
 StrokeWidth()%0A  
@@ -1785,20 +1785,21 @@
 eArrow=(
-node
+arrow
 ,verb)=%3E
@@ -1810,20 +1810,21 @@
   if ( (
-node
+arrow
 .subject
@@ -1847,14 +1847,143 @@
 && (
-node.o
+arrow.object==verb.object))%7B%0A        return true%0A    %7Delse%7B%0A        return false%0A    %7D%0A%7D%0A%0Alet isSameNode=(node,verb)=%3E%7B%0A    if (node.su
 bjec
@@ -1986,32 +1986,32 @@
 bject==verb.
-o
+su
 bject)
-)
 %7B%0A        re

add :isSameNode