// Path: src/main/java/it/uniud/ailab/dcore/annotation/Annotable.java
// public abstract class Annotable {
//     
//     /**
//      * The list of annotation.
//      */
//     private final Map<String,Annotation> annotations = new HashMap<>();
//     
//     /**
//      * The identifier or the annotated object.
//      */
//     private final String identifier;
//     
//     /**
//      * Generate an Annotable object.
//      * 
//      * @param identifier the identifier of the object.
//      */
//     protected Annotable(String identifier) {
//         this.identifier = identifier;
//     }
//     
//     /**
//      * Get the identifier of the object.
//      * 
//      * @return the identifier of the object.
//      */
//     public String getIdentifier() {
//         return identifier;
//     }
//     
//     /**
//      * Adds an annotation to the object. If there's an annotation with the same
//      * identifier, it will be overwritten.
//      * 
//      * @param ann the annotation to add.
//      */
//     public void addAnnotation(Annotation ann) {
//         annotations.put(ann.getAnnotator(),ann);
//     }
//     
//     /**
//      * Get the annotation specified with the specified annotator.
//      * 
//      * @param annotator the annotator to search
//      * @return the annotation requested, {@code null} if not found.
//      */
//     public Annotation getAnnotation(String annotator) {
//         return annotations.get(annotator);
//     }
//     
//     /**
//      * Get all the annotations stored in the object.
//      * 
//      * @return all the annotations.
//      */
//     public Annotation[] getAnnotations() {
//         return annotations.values().toArray(new Annotation[annotations.size()]);
//     }
//     
//     /**
//      * Check if the Annotable contains the specified annotation.
//      * 
//      * @param annotator the identifier of the annotation to search
//      * @return true if the annotator has been annotated by the 
//      * annotator provided as input, false otherwise.
//      */
//     public boolean hasAnnotation(String annotator) {
//         return annotations.containsKey(annotator);
//     }
// }
// 
// Path: src/main/java/it/uniud/ailab/dcore/utils/ListUtils.java
// public class ListUtils {
// 
//     /**
//      * Return the most common element in a list. If there are two or more 
//      * most common elements in a list, return the first one encountered.
//      * 
//      * @param <T> the type of the elements of the list
//      * @param list the list to analyze
//      * @return the most common element
//      */
//     public static <T> T mostCommon(List<T> list) {
//         Map<T, Integer> map = new HashMap<>();
// 
//         for (T t : list) {
//             Integer val = map.get(t);
//             map.put(t, val == null ? 1 : val + 1);
//         }
// 
//         Entry<T, Integer> max = null;
// 
//         for (Entry<T, Integer> e : map.entrySet()) {
//             if (max == null || e.getValue() > max.getValue()) {
//                 max = e;
//             }
//         }
// 
//         return max == null? null : max.getKey();
//     }
//     
// }


import com.fasterxml.jackson.annotation.JsonIgnore;
import it.uniud.ailab.dcore.annotation.Annotable;
import it.uniud.ailab.dcore.utils.ListUtils;
import java.util.ArrayList;
import java.util.List;
    public String getSurface() {
        return ListUtils.mostCommon(surfaces);
    }
    
    /**
     * Returns all the surfaces of the gram. Note: may contain 
     * duplicates.
     * 
     * @return all the surfaces of the gram.
     */
    @JsonIgnore
    public List<String> getSurfaces() {
        return surfaces;
    }
    
    /**
     * Adds an appearance of the gram; in other words, adds the component in
     * which the gram appears to the list of the appearances.
     *
     * @param component the component in which the gram appears
     */
    public void addAppaerance(DocumentComponent component) {
        appareances.add(component);
    }

    /**
     * Gets all the components in which the gram appears.
     *
     * @return all the components in which the gram appears.
     */
// Path: src/main/java/it/uniud/ailab/dcore/annotation/Annotable.java
// public abstract class Annotable {
//     
//     /**
//      * The list of annotation.
//      */
//     private final Map<String,Annotation> annotations = new HashMap<>();
//     
//     /**
//      * The identifier or the annotated object.
//      */
//     private final String identifier;
//     
//     /**
//      * Generate an Annotable object.
//      * 
//      * @param identifier the identifier of the object.
//      */
//     protected Annotable(String identifier) {
//         this.identifier = identifier;
//     }
//     
//     /**
//      * Get the identifier of the object.
//      * 
//      * @return the identifier of the object.
//      */
//     public String getIdentifier() {
//         return identifier;
//     }
//     
//     /**
//      * Adds an annotation to the object. If there's an annotation with the same
//      * identifier, it will be overwritten.
//      * 
//      * @param ann the annotation to add.
//      */
//     public void addAnnotation(Annotation ann) {
//         annotations.put(ann.getAnnotator(),ann);
//     }
//     
//     /**
//      * Get the annotation specified with the specified annotator.
//      * 
//      * @param annotator the annotator to search
//      * @return the annotation requested, {@code null} if not found.
//      */
//     public Annotation getAnnotation(String annotator) {
//         return annotations.get(annotator);
//     }
//     
//     /**
//      * Get all the annotations stored in the object.
//      * 
//      * @return all the annotations.
//      */
//     public Annotation[] getAnnotations() {
//         return annotations.values().toArray(new Annotation[annotations.size()]);
//     }
//     
//     /**
//      * Check if the Annotable contains the specified annotation.
//      * 
//      * @param annotator the identifier of the annotation to search
//      * @return true if the annotator has been annotated by the 
//      * annotator provided as input, false otherwise.
//      */
//     public boolean hasAnnotation(String annotator) {
//         return annotations.containsKey(annotator);
//     }
// }
// 
// Path: src/main/java/it/uniud/ailab/dcore/utils/ListUtils.java
// public class ListUtils {
// 
//     /**
//      * Return the most common element in a list. If there are two or more 
//      * most common elements in a list, return the first one encountered.
//      * 
//      * @param <T> the type of the elements of the list
//      * @param list the list to analyze
//      * @return the most common element
//      */
//     public static <T> T mostCommon(List<T> list) {
//         Map<T, Integer> map = new HashMap<>();
// 
//         for (T t : list) {
//             Integer val = map.get(t);
//             map.put(t, val == null ? 1 : val + 1);
//         }
// 
//         Entry<T, Integer> max = null;
// 
//         for (Entry<T, Integer> e : map.entrySet()) {
//             if (max == null || e.getValue() > max.getValue()) {
//                 max = e;
//             }
//         }
// 
//         return max == null? null : max.getKey();
//     }
//     
// }


// Path: src/main/java/it/uniud/ailab/dcore/persistence/Gram.java
import com.fasterxml.jackson.annotation.JsonIgnore;
import it.uniud.ailab.dcore.annotation.Annotable;
import it.uniud.ailab.dcore.utils.ListUtils;
import java.util.ArrayList;
import java.util.List;

    public String getSurface() {
        return ListUtils.mostCommon(surfaces);
    }
    
    /**
     * Returns all the surfaces of the gram. Note: may contain 
     * duplicates.
     * 
     * @return all the surfaces of the gram.
     */
    @JsonIgnore
    public List<String> getSurfaces() {
        return surfaces;
    }
    
    /**
     * Adds an appearance of the gram; in other words, adds the component in
     * which the gram appears to the list of the appearances.
     *
     * @param component the component in which the gram appears
     */
    public void addAppaerance(DocumentComponent component) {
        appareances.add(component);
    }

    /**
     * Gets all the components in which the gram appears.
     *
     * @return all the components in which the gram appears.
     */
    @JsonIgnore