package org.studiorailgun.ai.linguistics;

import java.util.List;
import java.util.stream.Collectors;

import org.studiorailgun.Globals;
import org.studiorailgun.ai.knowledge.Node;
import org.studiorailgun.ai.knowledge.Relation;
import org.studiorailgun.ai.knowledge.types.RelationTypes;

/**
 * Queries related to the linguistic concept of a name
 */
public class NameQuery {
    
    /**
     * Gets the names of a given node
     */
    public static List<Node> getNames(Node node){
        List<Relation> relations = Globals.web.getRelationsOfChildNode(node);
        return relations.stream().filter(relation -> relation.getName().equals(RelationTypes.NAME_OF)).map(relation -> relation.getParent()).collect(Collectors.toList());
    }

}
