csv recipe to create an arff file


josemlv@...
 

Hi, i hope someone can help me.

 
I want to create an ARFF file. I have used the groovy recipe to create a CSV, but the ouput file prints each  feature for a same type in a different line.
The format i would like  is

Type x, feature x, feature y, feature z
Type y, eature x, feature y, feature z

Thanks in advance


Jan Dedek
 

Given  features: "feature x", "feature y", "feature z"

new File(scriptParams.outputFile).withWriterAppend{ out ->
  (doc.getNamedAnnotationSets() + [Default:(doc.getAnnotations())]).each{ setName, set ->
    set.each{ anno ->
      if( anno.getFeatures() ) {
        def f = anno.getFeatures()
        out.write(/"${doc.getName()}","${setName}",${anno.getId()},"${anno.getType()}",${anno.start()},${anno.end()},/)
        out.writeLine(/"${f.get('feature x')}","${f.get('feature y')}" ,"${f.get('feature z')}"/))
      }
      else
        out.writeLine(/"${doc.getName()}","${setName}",${anno.getId()},"${anno.getType()}",${anno.start()},${anno.end()},,,/)        
    }
  }
}




so 28. 7. 2018 v 0:06 odesílatel <josemlv@...> napsal:
>
> Hi, i hope someone can help me.
>
>  
> I want to create an ARFF file. I have used the groovy recipe to create a CSV, but the ouput file prints each  feature for a same type in a different line.
> The format i would like  is
>
> Type x, feature x, feature y, feature z
> Type y, eature x, feature y, feature z
>
> Thanks in advance
>