19 package org.turro.elephant.entities.db;
21 import java.util.ArrayList;
22 import java.util.HashSet;
23 import java.util.List;
25 import javax.persistence.Column;
26 import javax.persistence.ElementCollection;
27 import javax.persistence.Entity;
28 import javax.persistence.FetchType;
29 import javax.persistence.GeneratedValue;
30 import javax.persistence.GenerationType;
31 import javax.persistence.Id;
32 import org.turro.string.Strings;
33 import org.turro.elephant.db.ElephantPU;
34 import org.turro.elephant.db.SQLHelper;
35 import org.turro.elephant.db.WhereClause;
36 import org.turro.jpa.Dao;
37 import org.turro.sql.SQLUtil;
44 public class Synonyms implements java.io.Serializable {
47 @GeneratedValue(strategy=GenerationType.IDENTITY)
48 @Column(name=
"IDENTIFIER")
51 @ElementCollection(fetch=FetchType.EAGER)
52 private Set<String> words =
new HashSet<>();
73 return words.isEmpty();
77 return String.join(
",", words);
83 ArrayList<Synonyms> synonyms =
new ArrayList<>();
84 if(!Strings.isBlank(phrase)) {
85 for(String word : phrase.split(
"\\s+")) {
96 public static List<Synonyms>
getSynonyms(String word,
int max) {
106 wc.
addClause(
"select s from Synonyms s");
110 return max == 0 ? dao.getResultList(wc) : dao.getResultList(wc, max);
static String convertToLike(String value)
void addClause(String clause)
void addNamedValue(String name, Object value)
static List< Synonyms > getSynonyms(Dao dao, String word, int max)
static List< Synonyms > getSynonyms(String word)
static List< Synonyms > getSynonyms(String word, int max)
void setWords(Set< String > words)
static List< Synonyms > getSynonymsByWords(String phrase)
static List< Synonyms > getSynonyms(Dao dao, String word)
static final int MAX_SYNONIMS