Add in whitelist sub-tagging. Add a template example file.

master
sigonasr2 5 years ago
parent 062d0a6b80
commit 2a0f8b3ba8
  1. BIN
      Tagger/Tagger.jar
  2. 31
      Tagger/src/PixivManager.java
  3. 22
      Tagger/src/imageTag.java
  4. 4
      Tagger/whitelist_template.txt

Binary file not shown.

@ -33,8 +33,9 @@ public class PixivManager {
skippedItems.delete();
folder.mkdirs();
File outputTest = new File("TAG_DATA.txt");
FileWriter fwOutput;
BufferedWriter bwOutput;
outputTest.delete();
FileWriter fwOutput,fwOutput2;
BufferedWriter bwOutput,bwOutput2;
try {
fwOutput = new FileWriter(outputTest,true);
bwOutput = new BufferedWriter(fwOutput);
@ -96,7 +97,7 @@ public class PixivManager {
ENTag = translationObj.getString("en");
}
} else
if (tag.has("tag") && /*romaji.length()==0 &&*/ !tag.getString("tag").matches(".*[ぁ-んァ-ン一-龯]")) {
if (tag.has("tag") /*&& romaji.length()==0 */&& !tag.getString("tag").matches(".*[ぁ-んァ-ン一-龯]")) {
hasEnglishTag=true;
ENTag = tag.getString("tag");
}
@ -115,8 +116,12 @@ public class PixivManager {
insertedTag = romaji;
tagSubmitted=true;
}*/
//insertedTag is the tag that will be used for the image.
insertedTag = ConvertTag(insertedTag.trim().toLowerCase());
if (tagSubmitted) {
if (imageTag.tag_whitelist.size()==0 || imageTag.tag_whitelist.containsKey(insertedTag.toLowerCase())) {
if (imageTag.tag_whitelist.size()==0 || imageTag.tag_whitelist.containsKey(insertedTag.trim().toLowerCase())) {
if (imageTag.taglist.containsKey(s)) {
List<String> tags = imageTag.taglist.get(s);
tags.add(insertedTag);
@ -172,19 +177,26 @@ public class PixivManager {
Set s = sorted.entrySet();
Iterator i = s.iterator();
File tagFile = new File("SORTED_TAGS.txt");
FileWriter fw;
File tagFile2 = new File("RAW_TAGS.txt");
FileWriter fw,fw2;
try {
fw = new FileWriter(tagFile);
fw2 = new FileWriter(tagFile2);
BufferedWriter bw = new BufferedWriter(fw);
BufferedWriter bw2 = new BufferedWriter(fw2);
while (i.hasNext()) {
Map.Entry m = (Map.Entry)i.next();
String key = (String)m.getKey();
Integer value = (Integer)m.getValue();
bw.write(key+" - "+value);
bw.newLine();
bw2.write(key);
bw2.newLine();
}
bw.close();
bw2.close();
fw.close();
fw2.close();
} catch (IOException e1) {
e1.printStackTrace();
}
@ -207,6 +219,15 @@ public class PixivManager {
}
private String ConvertTag(String insertedTag) {
if (imageTag.subtaglist.containsKey(insertedTag.trim().toLowerCase())) {
System.out.println(" Converting subtag "+insertedTag.trim().toLowerCase()+"->"+imageTag.subtaglist.get(insertedTag.trim().toLowerCase()));
return imageTag.subtaglist.get(insertedTag.trim().toLowerCase());
}
return insertedTag;
}
public static <K, V extends Comparable<V>> Map<K, V>
sortByValues(final Map<K, V> map) {
Comparator<K> valueComparator =

@ -28,6 +28,7 @@ public class imageTag {
public static List<String> pixiv_image_list = new ArrayList<String>();
public static List<File> pixiv_rawimage_list = new ArrayList<File>();
public static HashMap<String,List<String>> taglist = new HashMap<String,List<String>>();
public static HashMap<String,String> subtaglist = new HashMap<String,String>();
public static Map<String,Integer> tagCounter = new TreeMap<String,Integer>();
public static void main(String[] args) {
@ -60,10 +61,23 @@ public class imageTag {
try {
s = br.readLine();
while (s!=null) {
String newtag = s.trim().toLowerCase();
tag_whitelist.put(newtag,true);
System.out.println("Read in whitelisted tag: "+newtag);
s=br.readLine();
String[] split = s.split(":");
if (split.length>0) {
String newtag = split[0].trim().toLowerCase();
tag_whitelist.put(newtag,true);
System.out.println("Read in whitelisted tag: "+newtag);
for (int i=1;i<split.length;i++) {
String subtag = split[i].trim().toLowerCase();
subtaglist.put(subtag, newtag);
System.out.println(" Subtag: "+subtag);
}
s=br.readLine();
} else {
String newtag = s.trim().toLowerCase();
tag_whitelist.put(newtag,true);
System.out.println("Read in whitelisted tag: "+newtag);
s=br.readLine();
}
}
} catch (IOException e) {
e.printStackTrace();

@ -0,0 +1,4 @@
League of Legends:League_of_Legends:LoL:lol:LOL:LeagueofLegends:leagueoflegends:league_of_legends:League_of_legends:LeagueOfLegends
Touhou Project:Touhou
Ahri
fox ears
Loading…
Cancel
Save