2018-05-10 19:21:15 +02:00
|
|
|
package org.gcube.data.analysis.nlphub.legacy;
|
2018-02-20 08:39:31 +01:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2018-05-11 19:03:43 +02:00
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2018-02-20 08:39:31 +01:00
|
|
|
import com.google.gson.JsonArray;
|
|
|
|
import com.google.gson.JsonObject;
|
|
|
|
|
|
|
|
public class NerAnnotationData {
|
2018-05-11 19:03:43 +02:00
|
|
|
private static final Logger logger = LoggerFactory.getLogger(NerAnnotationData.class);
|
|
|
|
|
2018-02-20 08:39:31 +01:00
|
|
|
private String name;
|
|
|
|
private ArrayList<NerEntity> nerEntities;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class constructor; require the name of the annotation
|
|
|
|
* @param name
|
|
|
|
*/
|
|
|
|
public NerAnnotationData(String name) {
|
2018-05-11 19:03:43 +02:00
|
|
|
logger.debug("NerAnnotationData: "+name);
|
2018-02-20 08:39:31 +01:00
|
|
|
this.name = name;
|
|
|
|
nerEntities = new ArrayList<>();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* add a new NerEntity to the collection
|
|
|
|
* @param entity
|
|
|
|
*/
|
|
|
|
public void addNerEntity(NerEntity entity) {
|
|
|
|
nerEntities.add(entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* build the proper Json object.
|
|
|
|
* @return JsonObject
|
|
|
|
*/
|
|
|
|
public JsonObject toJson() {
|
|
|
|
JsonObject json = new JsonObject();
|
|
|
|
JsonArray entities = new JsonArray();
|
|
|
|
for(NerEntity e : nerEntities) {
|
|
|
|
entities.add(e.toJson());
|
|
|
|
}
|
|
|
|
json.add(name,entities);
|
|
|
|
return json;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArrayList<NerEntity> getNerEntities() {
|
|
|
|
return nerEntities;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setNerEntities(ArrayList<NerEntity> nerEntities) {
|
|
|
|
this.nerEntities = nerEntities;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
public static void main(String[] args) {
|
|
|
|
NerEntity ne1 = new NerEntity(11, 22);
|
|
|
|
ne1.addProperty("type", "scalar");
|
|
|
|
ne1.addProperty("unit", "hours");
|
|
|
|
|
|
|
|
NerEntity ne2 = new NerEntity(33, 44);
|
|
|
|
ne2.addProperty("type", "scalar");
|
|
|
|
ne2.addProperty("unit", "minutes");
|
|
|
|
|
|
|
|
NerAnnotationData nad = new NerAnnotationData("Measure");
|
|
|
|
nad.addNerEntity(ne1);
|
|
|
|
nad.addNerEntity(ne2);
|
|
|
|
|
|
|
|
System.out.println(nad.toJson().toString());
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
}
|