Example #1
0
 public Tagset filterPrefix(String prefix, boolean positive, boolean removePrefix) {
   if (prefix == null) {
     throw new IllegalArgumentException("prefix == null");
   }
   Tagset set = new Tagset();
   for (Tag tag : this) {
     if (tag.normalizedValue().startsWith(prefix) == positive) {
       if (positive && removePrefix) {
         String str = tag.normalizedValue().substring(prefix.length());
         if (str.length() != 0) set.add(str);
       } else {
         set.add(tag);
       }
     }
   }
   return set;
 }
Example #2
0
 public static Tagset parseTags(String tags) {
   Tagset set = new Tagset();
   for (String tag : tags.split("[\\n\\r\\s,]+")) {
     if (tag.length() != 0) {
       set.add(tag);
     }
   }
   return set;
 }
Example #3
0
 public Tagset(Tag... tags) {
   this();
   for (Tag tag : tags) {
     add(tag);
   }
 }
Example #4
0
 public Tagset(String... tags) {
   this();
   for (String tag : tags) {
     add(tag);
   }
 }
Example #5
0
 public void addAllStrings(Collection<? extends String> c) {
   for (String str : c) add(str);
 }