id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
384bfe0e-1552-4e3d-9f4f-f9c059b6f400 | public double tenFoldCrossValidation() {
System.out.println("Start 10-fold cross validation");
double[] output;
double error = 0;
double[] results = new double[22];
for (int i = 0; i < patterns.size(); i++) {
for (int j = 0; j < patterns.size()-1; j++) {
network.setInput(patterns.get(j).getInput());
network.activateNetwork();
output = network.getOutput();
patterns.get(j).setResult(output);
network.applyBackpropagation(patterns.get(j).getOutput());
}
network.setInput(patterns.get(patterns.size()-1).getInput());
network.activateNetwork();
results[i] = 1.0/2.0 * Math.pow(network.getOutput()[0] - patterns.get(patterns.size()-1).getOutput()[0], 2);
System.out.println("Sample - " + i + " : " + results[i]);
lastElemToStart();
}
for (double d: results) {
error += d;
}
System.out.println("Stop 10-fold cross validation");
return error/results.length;
} |
ace4bada-c76d-4591-9fc1-dd07fb3f8532 | private void lastElemToStart() {
List<Pattern> newList = new LinkedList<Pattern>();
newList.add(patterns.get(patterns.size()-1));
newList.addAll(patterns.subList(0, patterns.size()-1));
patterns.clear();
patterns.addAll(newList);
} |
80f1f6f4-d0f8-4632-bf7e-7a06a80ac4bb | public Connection(Neuron fromN, Neuron toN) {
this.from = fromN;
this.to = toN;
this.id = counter;
counter++;
} |
aeb83c35-fb63-45af-afa0-fa2d751102d0 | public double getWeight() {
return weight;
} |
f8d549f5-6675-4536-b42e-3bc5f214414a | public void setWeight(double w) {
weight = w;
} |
ab2b7287-779f-4513-9761-18802134b1d0 | public void setDeltaWeight(double w) {
prevDeltaWeight = deltaWeight;
deltaWeight = w;
} |
5df22fd6-d654-4d50-8992-08691647b3aa | public double getPrevDeltaWeight() {
return prevDeltaWeight;
} |
e9b35a6b-2c6c-4320-86e5-e67b918d9d78 | public Neuron getFromNeuron() {
return from;
} |
ee494c71-afb2-469f-b1fb-2946e48040a6 | public Neuron getToNeuron() {
return to;
} |
e51a1ea5-040f-4666-a156-e4061e9ab706 | public ShowPanel() {
setTitle("Input Vector");
setSize(new Dimension(500, 520));
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setResizable(false);
setLocationRelativeTo(null);
img = new BufferedImage(500, 500, BufferedImage.TYPE_INT_RGB);
} |
c0f9dabc-081c-4ced-9447-0cebb5a6d3c6 | @Override
public void paint(Graphics g) {
super.paint(g);
g.drawImage(img, 0, 20, this);
} |
6d708c34-7191-474c-866b-201857a2875c | public void render(Vector<SOMVector> inputs) {
float fl = (float)Math.sqrt(inputs.size());
int qb = Math.round(fl);
if (fl > qb) qb += 1;
float cellWidth = img.getWidth() / qb;
float cellHeight = img.getHeight() / qb;
int imgW = img.getWidth();
int imgH = img.getHeight();
Graphics2D g2 = img.createGraphics();
g2.setColor(Color.BLACK);
g2.fillRect(0,0,imgW,imgH);
for (int x=0; x<qb; x++) {
for (int y=0; y<qb; y++) {
SOMVector vec = null;
if ((y+qb*x) < inputs.size()) vec = inputs.get(y+qb*x);
else vec = getNone();
Color c = new Color(vec.get(0), vec.get(1), vec.get(2));
g2.setColor(c);
g2.fillRect((int)(x*cellWidth), (int)(y*cellHeight),
(int)cellWidth +1 , (int)cellHeight +1);
}
}
g2.dispose();
repaint();
} |
a3a8cdfa-e83c-4896-bcef-5e001fa54bd6 | private SOMVector getNone() {
return new SOMVector(1f, 1f, 1f);
} |
9b873070-c403-4929-ac72-8f232bb7ffb1 | public LatticeRenderer(Vector<SOMVector> inputVect) {
setTitle("SOM Map");
setSize(new Dimension(size, size));
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setResizable(false);
setLocationRelativeTo(null);
this.inputVect = inputVect;
} |
c16c47e1-a218-4197-8ffd-66c60640e102 | @Override
public void paint(Graphics g) {
super.paint(g);
if (img != null) {
g.drawImage(img, 0, 0, this);
} else {
g.setColor(Color.WHITE);
g.fillRect(0, 0, size, size);
}
} |
d849517f-7c7d-44c4-8ecb-deccebb18fd3 | public void render(SOMLattice lattice, int iteration) {
float cellWidth = (float)getWidth() / (float)lattice.getWidth();
float cellHeight = (float)getHeight() / (float)lattice.getHeight();
int imgW = img.getWidth();
int imgH = img.getHeight();
graph.setColor(Color.BLACK);
graph.fillRect(0,0,imgW,imgH);
for (int x=0; x<lattice.getWidth(); x++) {
for (int y=0; y<lattice.getHeight(); y++) {
SOMVector vec = lattice.getNode(x,y).getVector();
if (closestMode) graph.setColor(closest(vec, inputVect));
else graph.setColor(new Color(vec.get(0), vec.get(1), vec.get(2)));
graph.fillRect((int)(x*cellWidth), (int)(y*cellHeight),
(int)cellWidth +1 , (int)cellHeight +1);
}
}
graph.setColor(Color.RED);
graph.drawString("Iteration: " + String.valueOf(iteration), 5, 15);
this.repaint();
} |
dd42c979-de21-4ff6-9d35-65df763be11f | private Color closest(SOMVector vec, Vector<SOMVector> inputs) { // for better visualization
SOMVector best = inputs.get(0);
double bestDist = vec.euclideanDist(best);
double dist;
for (int i = 0; i < inputs.size(); i++) {
dist = vec.euclideanDist(inputs.get(i));
if (dist < bestDist) {
bestDist = dist;
best = inputs.get(i);
}
}
return new Color(best.get(0), best.get(1), best.get(2));
} |
ab52c794-73be-4887-bf64-49cbf3282235 | public BufferedImage getImage() {
if (img == null) {
img = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
graph = img.createGraphics();
}
return img;
} |
341575ae-b982-4e35-a9be-a306615ff45c | public SOMLattice(int w, int h) {
width = w;
height = h;
matrix = new SOMNode[width][height];
for (int x=0; x<w; x++) {
for (int y=0; y<h; y++) {
matrix[x][y] = new SOMNode(3);
matrix[x][y].setX(x);
matrix[x][y].setY(y);
}
}
} |
bdf45c54-da5e-4054-b1b5-c9f110041f86 | public SOMNode getNode(int x, int y) {
return matrix[x][y];
} |
bf801e30-b925-42e0-8712-b0a68bdcca9b | public void setNode(int x, int y, SOMNode node) {
matrix[x][y] = node;
} |
36efcbd2-e21d-4e6e-a637-e63744f5e22a | public int getWidth() {
return width;
} |
ed1e52ac-73e6-4985-ba09-aa946a7c6574 | public int getHeight() {
return height;
} |
540ef90c-a71f-47d7-8931-57d26d97436c | public SOMNode[][] getMatrix() {
return matrix;
} |
f3cdc5a4-c04b-4803-b560-c8f223c912eb | public SOMNode getWinner(SOMVector inputVector) {
SOMNode bmu = matrix[0][0];
double bestDist = inputVector.euclideanDist(bmu.getVector());
double curDist;
for (int x=0; x<width; x++) {
for (int y=0; y<height; y++) {
curDist = inputVector.euclideanDist(matrix[x][y].getVector());
if (curDist < bestDist) {
bmu = matrix[x][y];
bestDist = curDist;
}
}
}
return bmu;
} |
a628b2bf-5ad3-47ff-8167-e69dd99e0028 | public BufferedImage use(BufferedImage src, Vector<SOMVector> inputVectors) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_RGB);
SOMVector tempVec = null;
if (closestType) {
for (int i = 0; i < getWidth(); i++) {
for (int j = 0; j < getHeight(); j++) {
SOMNode node = getNode(i, j);
node.setWeights(closestVect(node.getVector(), inputVectors));
setNode(i, j, node);
}
}
}
for (int i = 0; i < src.getWidth(); i++) {
for (int j = 0; j < src.getHeight(); j++) {
double percent = (i / (double)src.getWidth() * 100);
System.out.println(percent + " %");
Color c = new Color(src.getRGB(i, j));
tempVec = new SOMVector(scale(c.getRed()), scale(c.getGreen()), scale(c.getBlue()));
SOMNode winner = getWinner(tempVec);
SOMVector colorVector = winner.getVector();
Color resC = new Color(unscale(colorVector.get(0)), unscale(colorVector.get(1)),
unscale(colorVector.get(2)));
result.setRGB(i, j, resC.getRGB());
}
}
return result;
} |
cbfa0950-68c8-44d1-9819-51e4e37d4421 | public static SOMVector closestVect(SOMVector vec, Vector<SOMVector> inputs) { // end
SOMVector best = inputs.get(0);
double bestDist = vec.euclideanDist(best);
double dist;
for (int i = 0; i < inputs.size(); i++) {
dist = vec.euclideanDist(inputs.get(i));
if (dist < bestDist) {
bestDist = dist;
best = inputs.get(i);
}
}
return best;
} |
5468b61a-6596-44b1-8817-82e72f0a119b | private float scale(int val) {
return 1 - ((float)(255-val)/(float)255);
} |
184f74de-4834-4762-95f2-b1476d8f4a09 | private int unscale(double val) {
return (int)(255*val);
} |
47cda594-839b-4ade-923c-177f0a18b05b | public SOMVector() {} |
db4d67b0-2d70-4f3e-9aa2-8711a41b9a34 | public SOMVector(Float r, Float g, Float b) {
super();
addElement(r);
addElement(g);
addElement(b);
} |
18a9c6e0-1208-48f8-aaad-86f01fbacdeb | public SOMVector(Color c) {
super();
addElement(scale(c.getRed()));
addElement(scale(c.getGreen()));
addElement(scale(c.getBlue()));
} |
70f46e22-dda3-40a1-923d-99cb3bf8ebd3 | public double euclideanDist(SOMVector v2) { // euclidean dist ipt Vect - som vect
double summation = 0, temp;
for (int x=0; x<size(); x++) {
temp = elementAt(x).doubleValue() -
v2.elementAt(x).doubleValue();
temp *= temp;
summation += temp;
}
return summation;
} |
17e1cc29-2ace-410c-a5a6-e89142914f72 | public SOMVector minus(SOMVector vec) {
SOMVector result = new SOMVector();
result.addElement(get(0)-vec.get(0));
result.addElement(get(1)-vec.get(1));
result.addElement(get(2)-vec.get(2));
return result;
} |
66b1935f-0126-4b47-aaae-e209ab20a2f6 | @Override
public boolean equals(Object obj) {
SOMVector vec = (SOMVector)obj;
boolean thesame = true;
for (int i = 0; i < this.size(); i++) {
if (get(i).floatValue() != vec.get(i).floatValue()) {
thesame = false;
}
}
return thesame;
} |
be170a1f-5693-44d4-9b98-44c5457f0e67 | private static float scale(int val) {
return 1 - ((float)(255-val)/(float)255);
} |
697b52ec-539d-4964-bdc5-ac2419c09a6b | public SOMNode(int numWeights) {
weights = new SOMVector();
for (int x=0; x<numWeights; x++) {
weights.addElement(new Float(Math.random()*0.7));
}
this.furtherDeltaWeights = new SOMVector(0f, 0f, 0f);
} |
a7e82b97-a1b8-479b-9e6b-4ef4c3c08918 | public void setWeights(SOMVector weights) {
this.weights = weights;
} |
ceb3ece2-6050-4415-b967-028168709bbf | public void setX(int xpos) {
xp = xpos;
} |
f31e0a31-d957-49a3-9d1e-3eaaabcb0fc7 | public void setY(int ypos) {
yp = ypos;
} |
d03a7a72-7402-4f54-a18b-aafa402bfaee | public int getX() {
return xp;
} |
febe7523-1bb8-4bb7-ac43-3542c78a3c6e | public int getY() {
return yp;
} |
48e30486-0787-43db-83ac-853f8e0a9ebf | public double distanceTo(SOMNode n2) { // eucides distance som node - som node
int xleg, yleg;
xleg = getX() - n2.getX();
xleg *= xleg;
yleg = getY() - n2.getY();
yleg *= yleg;
return xleg + yleg;
} |
507c821e-aaff-4f2d-9502-1fb3860274b0 | public SOMVector getVector() {
return weights;
} |
910ef649-1a2d-48f4-82c0-974dee3f6788 | public void adjustWeights(SOMVector input, double learningRate, double distanceFalloff) {
SOMVector weightsTemp = (SOMVector)weights.clone();
double wt, vw;
for (int w=0; w<weights.size(); w++) {
wt = weights.elementAt(w).doubleValue();
vw = input.elementAt(w).doubleValue();
wt += distanceFalloff * learningRate * (vw - wt);
wt += SOMTrainer.MOMENTUM_COEFFICIENT * furtherDeltaWeights.elementAt(w).doubleValue();
if (wt > 1) wt = 1;
if (wt < 0) wt = 0;
weights.setElementAt(new Float(wt), w);
}
furtherDeltaWeights = weights.minus(weightsTemp);
} |
66b4e4b8-b9ea-4ce3-8596-8d757f525058 | @Override
public boolean equals(Object obj) {
SOMNode elem = (SOMNode)obj;
return getVector().equals(elem.getVector());
} |
868a46f7-570c-4cee-a4cf-d616bd375841 | public boolean isNeighboor(SOMNode n2) {
double dist = this.distanceTo(n2);
return dist <= 2;
} |
663401f9-4ac1-4848-948e-cdb42539cce0 | public SOMTrainer() {
this.running = false;
} |
122f21e1-6e15-4084-a0be-72fa2d0778b6 | private double getNeighborhoodRadius(double iteration) {
return LATTICE_RADIUS_MAX * Math.pow((1/LATTICE_RADIUS_MAX), iteration/NUM_ITERATIONS);
} |
7896470d-03bb-4916-a7d5-eb466b4faa2e | private double getDistanceFalloff(double distSq, double radius) { // nbh fct
double radiusSq = radius * radius;
return Math.exp(-(distSq)/(2 * radiusSq));
} |
1caa14fe-a758-465c-9d3f-0d0959b1fa75 | public void setTraining(SOMLattice latToTrain, Vector<SOMVector> in) {
lattice = latToTrain;
inputs = in;
this.renderer = new LatticeRenderer(in);
this.renderer.getImage();
} |
62d77266-1eb2-4b1f-ae5b-c8142035995f | public void start() {
if (lattice != null) {
runner = new Thread(this);
runner.setPriority(Thread.MAX_PRIORITY);
running = true;
renderer.setVisible(true);
runner.start();
}
} |
ce11afb5-c6e8-48f7-8fe7-553a1a532f0c | @Override
public void run() {
int lw = lattice.getWidth();
int lh = lattice.getHeight();
int xstart, ystart, xend, yend;
double dist, dFalloff;
LATTICE_RADIUS_MAX = Math.max(lw, lh)/2;
int iteration = 0;
double nbhRadius;
SOMNode bmu = null, temp = null;
SOMVector curInput = null;
double learningRate = START_LEARNING_RATE;
while (iteration < NUM_ITERATIONS && running) {
nbhRadius = getNeighborhoodRadius(iteration);
for (int i=0; i<inputs.size(); i++) {
curInput = inputs.elementAt(i);
bmu = lattice.getWinner(curInput);
// update weights in whole neighbourhood
xstart = (int)(bmu.getX() - nbhRadius - 1);
ystart = (int)(bmu.getY() - nbhRadius - 1);
xend = (int)(xstart + (nbhRadius * 2) + 1);
yend = (int)(ystart + (nbhRadius * 2) + 1);
if (xend > lw) xend = lw;
if (xstart < 0) xstart = 0;
if (yend > lh) yend = lh;
if (ystart < 0) ystart = 0;
for (int x=xstart; x<xend; x++) {
for (int y=ystart; y<yend; y++) {
temp = lattice.getNode(x,y);
dist = bmu.distanceTo(temp);
if (dist <= (nbhRadius * nbhRadius)) {
dFalloff = getDistanceFalloff(dist, nbhRadius);
temp.adjustWeights(curInput, learningRate, dFalloff);
}
}
}
}
iteration++;
Collections.shuffle(inputs);
learningRate = START_LEARNING_RATE * Math.exp(-(double)iteration/NUM_ITERATIONS); // desc
if (iteration % 50 == 0) {
renderer.render(lattice, iteration);
}
}
running = false;
JOptionPane.showMessageDialog(null, "Success",
"Map is trained!",
JOptionPane.INFORMATION_MESSAGE);
} |
1d755107-a352-4408-9c2f-e56039e3d62c | public void stop() {
if (runner != null) {
running = false;
while (runner.isAlive()) {};
}
} |
9fd8015f-8640-4ed4-bf73-48551dce15d1 | public SOMLattice getLattice() {
return lattice;
} |
d7294f41-fedd-4bd1-a5fc-6b8b7a17a644 | public HashMap<String, List<String>> extractFeatures(
HashMap<String, List<String>> tagged, String outputfolder) throws IOException {
System.out.println();
System.out.println("EXTRACT RELEVANT FEATURES");
InputStream inputStreamStopWords = getClass().getResourceAsStream("/genericStopWords.list");
BufferedReader br = null;
String currentLine;
List<String> stopWordsList = new ArrayList<String>();
try {
br = new BufferedReader(new InputStreamReader(inputStreamStopWords));
while ((currentLine = br.readLine()) != null) {
stopWordsList.add(currentLine);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
}
// System.out.println("SIZE STOP " + stopWordsList.size());
HashMap<String, List<String>> selected = new HashMap<String, List<String>>();
List<String> features = new ArrayList<String>();
List<String> niod_feats = new ArrayList<String>();
List<String> wl_feats = new ArrayList<String>();
List<String> yv_feats = new ArrayList<String>();
List<String> jmp_feats = new ArrayList<String>();
List<String> ba_feats = new ArrayList<String>();
List<String> ushmm_feats = new ArrayList<String>();
List<String> its_feats = new ArrayList<String>();
List<String> cegesoma_feats = new ArrayList<String>();
List<String> ifz_feats = new ArrayList<String>();
for (String key : tagged.keySet()) {
System.out.println("Extracting features from "+ key);
for (int i = 0; i < tagged.get(key).size(); i++) {
if (tagged.get(key).get(i).toLowerCase().matches("^[a-z].*")) {
String[] splitted = tagged.get(key).get(i).split("\t");
if (splitted[1].matches("NN.*")
|| splitted[1].matches("NP.*")|| splitted[1].equals("JJ")
|| splitted[1].matches("VV.*")) {
if (splitted[2].equals("<unknown>")) {
if (!stopWordsList.contains(splitted[0]) && (splitted[0].length()>2) && !(splitted[0].equals("\n"))) {
ClusterSynonyms clusterSyns = new ClusterSynonyms();
String feature = clusterSyns.substituteSynonym(splitted[0].toLowerCase());
if (key.equals("niod")) {
niod_feats.add(feature);
}
if (key.equals("wiener")) {
wl_feats.add(feature);
}
if (key.equals("yadvashem")) {
yv_feats.add(feature);
}
if (key.equals("jewishmuseumprag")) {
jmp_feats.add(feature);
}
if (key.equals("bundesarchiv")) {
ba_feats.add(feature);
}
if (key.equals("ushmm")) {
ushmm_feats.add(feature);
}
if (key.equals("its")) {
its_feats.add(feature);
}
if (key.equals("cegesoma")) {
cegesoma_feats.add(feature);
}
if (key.equals("ifz")) {
ifz_feats.add(feature);
}
}
// }
} else {
if (!stopWordsList.contains(splitted[2])&& (splitted[2].length()>2) && !(splitted[2].equals("\n"))) {
ClusterSynonyms clusterSyns = new ClusterSynonyms();
String feature = clusterSyns.substituteSynonym(splitted[2].toLowerCase());
if (key.equals("niod")) {
niod_feats.add(feature);
}
if (key.equals("wiener")) {
wl_feats.add(feature);
}
if (key.equals("yadvashem")) {
yv_feats.add(feature);
}
if (key.equals("jewishmuseumprag")) {
jmp_feats.add(feature);
}
if (key.equals("bundesarchiv")) {
ba_feats.add(feature);
}
if (key.equals("ushmm")) {
ushmm_feats.add(feature);
}
if (key.equals("its")) {
its_feats.add(feature);
}
if (key.equals("cegesoma")) {
cegesoma_feats.add(feature);
}
if (key.equals("ifz")) {
ifz_feats.add(feature);
}
}
}
}
}
}
}
// }
selected.put("niod", niod_feats);
selected.put("wiener", wl_feats);
selected.put("yadvashem", yv_feats);
selected.put("jewishmuseumprag", jmp_feats);
selected.put("bundesarchiv", ba_feats);
selected.put("ushmm", ushmm_feats);
selected.put("its", its_feats);
selected.put("cegesoma", cegesoma_feats);
selected.put("ifz", ifz_feats);
features.addAll(niod_feats);
features.addAll(wl_feats);
features.addAll(yv_feats);
features.addAll(jmp_feats);
features.addAll(ba_feats);
features.addAll(ushmm_feats);
features.addAll(its_feats);
features.addAll(cegesoma_feats);
features.addAll(ifz_feats);
// System.out.println("Features size begin " + features.size());
AuxiliaryMethods.removeDuplicates(features);
Collections.sort(features);
File featuresFile = new File(outputfolder + "features.txt");
FileWriter fw = new FileWriter(featuresFile.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
for (int i = 0; i < features.size(); i++) {
bw.write(features.get(i));
bw.newLine();
}
bw.close();
System.out.println("Dimensions of the vector space: " + features.size());
return selected;
} |
a52bad27-8d28-4cb7-8374-4c7ca6e3e248 | public List<String> tokenize(String toTokenize) {
toTokenize = toTokenize.replace("'", " '");
// System.out.println(toTokenize);
List<String> tokens = new ArrayList<String>();
BreakIterator bi = BreakIterator.getWordInstance();
bi.setText(toTokenize);
int begin = bi.first();
int end;
for (end = bi.next(); end != BreakIterator.DONE; end = bi.next()) {
String t = toTokenize.substring(begin, end);
if (t.trim().length() > 0) {
tokens.add(toTokenize.substring(begin, end));
}
begin = end;
}
if (end != -1) {
tokens.add(toTokenize.substring(end));
}
for (int i = 0; i < tokens.size(); i++) {
// System.out.println(tokens.get(i));
}
String tokenlist = AuxiliaryMethods.listToString(tokens);
tokenlist = tokenlist.replace("' s ", "'s ");
tokenlist = tokenlist.replace("' ll ", "'ll ");
tokenlist = tokenlist.replace("' m ", "'m ");
tokenlist = tokenlist.replace("' are ", "'are ");
tokenlist = tokenlist.replace("' re ", "'re ");
tokenlist = tokenlist.replace("dr .", "dr.");
tokenlist = tokenlist.replace("mr .", "mr.");
tokenlist = tokenlist.replace("mrs .", "mrs.");
tokenlist = tokenlist.replace("ms .", "ms.");
tokenlist = tokenlist.replace("Dr .", "Dr.");
tokenlist = tokenlist.replace("Mr .", "Mr.");
tokenlist = tokenlist.replace("Mrs .", "Mrs.");
tokenlist = tokenlist.replace("Ms .", "Ms.");
// System.out.println(tokenlist);
// for problems in pre-processing
tokenlist = tokenlist.replace("\"", " ");
tokenlist = tokenlist.replace("national sozialist", "nazi");
tokenlist = tokenlist.replace("National Sozialist", "Nazi");
tokenlist = tokenlist.replace("National sozialist", "Nazi");
tokenlist = tokenlist.replace("anti - ", "anti");
tokenlist = tokenlist.replace("anti-", "anti");
tokenlist = tokenlist.replace("Anti - ", "Anti");
tokenlist = tokenlist.replace("Anti-", "Anti");
/* tokenlist = tokenlist.replace("concentration camps", "KZ");
tokenlist = tokenlist.replace("Concentration camps", "KZ");
tokenlist = tokenlist.replace("Concentration Camps", "KZ");
tokenlist = tokenlist.replace("concentrations camps", "KZ");
tokenlist = tokenlist.replace("Concentrations camps", "KZ");
tokenlist = tokenlist.replace("Concentrations Camps", "KZ");
tokenlist = tokenlist.replace("concentration camp", "KZ");
tokenlist = tokenlist.replace("Concentration camp", "KZ");
tokenlist = tokenlist.replace("Concentration Camp", "KZ");
tokenlist = tokenlist.replace("concentrations camp", "KZ");
tokenlist = tokenlist.replace("Concentrations camp", "KZ");
tokenlist = tokenlist.replace("Concentrations Camp", "KZ");
*/
List<String> tokenList = asList(tokenlist.split(" "));
return tokenList;
} |
e83bb2c0-d854-409a-af43-d189a9cd46b9 | public HashMap<String, List<String>> tokenizeDescriptions(
HashMap<String, List<String>> filesContent) {
System.out.println();
System.out.println("Begin tokenization");
HashMap<String, List<String>> tokenLists = new HashMap<String, List<String>>();
List<String> niod_tokens = new ArrayList<String>();
List<String> wl_tokens = new ArrayList<String>();
List<String> yv_tokens = new ArrayList<String>();
List<String> jmp_tokens = new ArrayList<String>();
List<String> ba_tokens = new ArrayList<String>();
List<String> ushmm_tokens = new ArrayList<String>();
List<String> its_tokens = new ArrayList<String>();
List<String> cegesoma_tokens = new ArrayList<String>();
List<String> ifz_tokens = new ArrayList<String>();
EnglishTokenizer tokenizeInput = new EnglishTokenizer();
for (String key : filesContent.keySet()) {
System.out.println("Tokenizing texts of " + key);
for (int i = 0; i < filesContent.get(key).size(); i++) {
List<String> tokensFile = new ArrayList<String>();
List<String> tokensLine = tokenizeInput.tokenize(filesContent
.get(key).get(i));
tokensFile.addAll(tokensLine);
if (key.equals("niod")) {
niod_tokens.addAll(tokensFile);
}
if (key.equals("wiener")) {
wl_tokens.addAll(tokensFile);
}
if (key.equals("yadvashem")) {
yv_tokens.addAll(tokensFile);
}
if (key.equals("jewishmuseumprag")) {
jmp_tokens.addAll(tokensFile);
}
if (key.equals("bundesarchiv")) {
ba_tokens.addAll(tokensFile);
}
if (key.equals("ushmm")) {
ushmm_tokens.addAll(tokensFile);
}
if (key.equals("its")) {
its_tokens.addAll(tokensFile);
}
if (key.equals("cegesoma")) {
cegesoma_tokens.addAll(tokensFile);
}
if (key.equals("ifz")) {
ifz_tokens.addAll(tokensFile);
}
}
}
tokenLists.put("niod", niod_tokens);
tokenLists.put("wiener", wl_tokens);
tokenLists.put("yadvashem", yv_tokens);
tokenLists.put("jewishmuseumprag", jmp_tokens);
tokenLists.put("bundesarchiv", ba_tokens);
tokenLists.put("ushmm", ushmm_tokens);
tokenLists.put("its", its_tokens);
tokenLists.put("cegesoma", cegesoma_tokens);
tokenLists.put("ifz", ifz_tokens);
System.out.println("NIOD tokens: " + niod_tokens.size());
System.out.println("WIENER tokens: " + wl_tokens.size());
System.out.println("YV tokens: " + yv_tokens.size());
System.out.println("JMP tokens: " + jmp_tokens.size());
System.out.println("BA tokens: " + ba_tokens.size());
System.out.println("USHMM tokens: " + ushmm_tokens.size());
System.out.println("ITS tokens: " + its_tokens.size());
System.out.println("CEGESOMA tokens: " + cegesoma_tokens.size());
System.out.println("IfZ tokens: " + ifz_tokens.size());
return tokenLists;
} |
d47deebc-5514-40fa-b848-a9cef2b1244e | public HashMap<String, List<String>> annotatePOS(
HashMap<String, List<String>> tokens) throws IOException,
TreeTaggerException {
System.out.println();
System.out.println("BEGIN POS ANNOTATION");
HashMap<String, List<String>> annotated = new HashMap<String, List<String>>();
List<String> niod_pos = new ArrayList<String>();
List<String> wl_pos = new ArrayList<String>();
List<String> yv_pos = new ArrayList<String>();
List<String> jmp_pos = new ArrayList<String>();
List<String> ba_pos = new ArrayList<String>();
List<String> ushmm_pos = new ArrayList<String>();
List<String> its_pos = new ArrayList<String>();
List<String> cegesoma_pos = new ArrayList<String>();
List<String> ifz_pos = new ArrayList<String>();
for (String key : tokens.keySet()) {
System.out.println("ANNOTATING " + key);
List<String> annotation = new ArrayList<String>();
PartOfSpeechTagging annotate = new PartOfSpeechTagging();
annotation = annotate.annotatePOSpeech(tokens.get(key));
//
if (key.equals("niod")) {
niod_pos.addAll(annotation);
}
if (key.equals("wiener")) {
wl_pos.addAll(annotation);
}
if (key.equals("yadvashem")) {
yv_pos.addAll(annotation);
}
if (key.equals("jewishmuseumprag")) {
jmp_pos.addAll(annotation);
}
if (key.equals("bundesarchiv")) {
ba_pos.addAll(annotation);
}
if (key.equals("ushmm")) {
ushmm_pos.addAll(annotation);
}
if (key.equals("its")) {
its_pos.addAll(annotation);
}
if (key.equals("cegesoma")) {
cegesoma_pos.addAll(annotation);
}
if (key.equals("ifz")) {
ifz_pos.addAll(annotation);
}
}
System.out.println("POS NIOD SIZE " + niod_pos.size());
System.out.println("POS WL SIZE " + wl_pos.size());
System.out.println("POS YV SIZE " + yv_pos.size());
System.out.println("POS JMP SIZE " + jmp_pos.size());
System.out.println("POS BA SIZE " + ba_pos.size());
System.out.println("POS USHMM SIZE " + ushmm_pos.size());
System.out.println("POS ITS SIZE " + its_pos.size());
System.out.println("POS IfZ SIZE " + ifz_pos.size());
System.out.println("POS CEGESOMA SIZE " + cegesoma_pos.size());
annotated.put("niod", niod_pos);
annotated.put("wiener", wl_pos);
annotated.put("yadvashem", yv_pos);
annotated.put("jewishmuseumprag", jmp_pos);
annotated.put("bundesarchiv", ba_pos);
annotated.put("ushmm", ushmm_pos);
annotated.put("its", its_pos);
annotated.put("cegesoma", cegesoma_pos);
annotated.put("ifz", ifz_pos);
return annotated;
} |
199332a5-b020-46fe-bb42-7d7d1b645d4d | static List<String> removeDuplicates(List<String> arrayList) {
HashSet<String> set = new HashSet<String>(arrayList);
arrayList.clear();
arrayList.addAll(set);
return arrayList;
} |
8e4e9ca2-ccc6-4827-8595-809c0643ecf5 | static List<Integer> removeDuplicateIndexes(List<Integer> arrayList) {
HashSet<Integer> set = new HashSet<Integer>(arrayList);
arrayList.clear();
arrayList.addAll(set);
return arrayList;
} |
e834f3cc-dce6-418e-84b6-1e1c5116aba0 | static String listToString(List<String> arrayList) {
String string = "";
for (int i = 0; i < arrayList.size() - 1; i++) {
string = string + arrayList.get(i) + " ";
}
if (arrayList.size() > 0) {
string = string + arrayList.get(arrayList.size() - 1);
}
return string;
} |
0cc578c9-8b68-46c3-8aec-4864802e784d | static String listToString2(List<String> arrayList) {
String string = "";
for (int i = 0; i < arrayList.size() - 1; i++) {
string = string + arrayList.get(i) + " ";
}
if (arrayList.size() > 0) {
string = string + arrayList.get(arrayList.size() - 1);
}
return string;
} |
0f6fc423-5068-46f4-a0cd-49580286429e | public static HashMap<String, Double> sortByValue(HashMap<String, Double> map) {
List<Map.Entry<String, Double>> list = new LinkedList<Map.Entry<String, Double>>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<String, Double>>() {
public int compare(Map.Entry<String, Double> m1, Map.Entry<String, Double> m2) {
int out = 0;
if (m2.getValue() < m1.getValue()){
out = -1;
}
if (m2.getValue() > m1.getValue()){
out = 1;
}
if (m2.getValue() == m1.getValue()){
out = 0;
}
return out;
}
});
HashMap<String, Double> result = new LinkedHashMap<String, Double>();
for (Map.Entry<String, Double> entry : list) {
result.put(entry.getKey(), entry.getValue());
}
return result;
} |
b735695b-119f-4dbb-ba52-a6ed1b7d8f04 | public int compare(Map.Entry<String, Double> m1, Map.Entry<String, Double> m2) {
int out = 0;
if (m2.getValue() < m1.getValue()){
out = -1;
}
if (m2.getValue() > m1.getValue()){
out = 1;
}
if (m2.getValue() == m1.getValue()){
out = 0;
}
return out;
} |
b0edadef-cbfb-44db-b315-55c3d70d13e2 | public String substituteSynonym(String word) {
InputStream inputStreamSynonyms = getClass().getResourceAsStream(
"/synonyms.dic");
String feature;
// Create dictionary of synonyms
HashMap<String, String> dictionary = new HashMap<String, String>();
BufferedReader br = null;
String currentLine;
try {
br = new BufferedReader(new InputStreamReader(inputStreamSynonyms));
while ((currentLine = br.readLine()) != null) {
String[] splittedLine = currentLine.split("\t");
dictionary.put(splittedLine[0], splittedLine[1]);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
}
if (dictionary.containsKey(word)){
feature = dictionary.get(word);
}else{
feature = word;
}
return feature;
} |
1fc603a3-c47f-4324-a16c-a1b3ce6e36dc | public HashMap<String, List<String>> loadFiles4Model(String descriptionsFolder) {
File descriptions = new File(descriptionsFolder);
System.out.println("Loading files...");
List<String> niod_lines = new ArrayList<String>();
List<String> wl_lines = new ArrayList<String>();
List<String> yv_lines = new ArrayList<String>();
List<String> jmp_lines = new ArrayList<String>();
List<String> ushmm_lines = new ArrayList<String>();
List<String> bundesarchiv_lines = new ArrayList<String>();
List<String> its_lines = new ArrayList<String>();
List<String> cegesoma_lines = new ArrayList<String>();
List<String> ifz_lines = new ArrayList<String>();
Pattern textFile = Pattern.compile(".*txt");
List<String> fileList = new ArrayList<String>();
HashMap<String, List<String>> filesContent = new HashMap<String, List<String>>();
for (final File fileEntry : descriptions.listFiles()) {
Matcher matcherText = textFile.matcher(fileEntry.toString());
if (matcherText.find()) {
fileList.add(fileEntry.getName());
}
}
for (int i = 0; i < fileList.size(); i++) {
String currentLine;
List<String> linesOfFile = new ArrayList<String>();
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(descriptionsFolder
+ fileList.get(i)));
while ((currentLine = br.readLine()) != null) {
linesOfFile.add(currentLine);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
br.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//provisional names of institutions
if (fileList.get(i).matches("niod_.*")) {
niod_lines.addAll(linesOfFile);
}
if (fileList.get(i).matches("wiener_.*")) {
wl_lines.addAll(linesOfFile);
}
if (fileList.get(i).matches("yadvashem_.*")) {
yv_lines.addAll(linesOfFile);
}
if (fileList.get(i).matches("jewishmuseumprag_.*")) {
jmp_lines.addAll(linesOfFile);
}
if (fileList.get(i).matches("Bundesarchiv_.*")) {
bundesarchiv_lines.addAll(linesOfFile);
}
if (fileList.get(i).matches("ushmm_.*")) {
ushmm_lines.addAll(linesOfFile);
}
if (fileList.get(i).matches("its_.*")) {
its_lines.addAll(linesOfFile);
}
if (fileList.get(i).matches("cegesoma_.*")) {
cegesoma_lines.addAll(linesOfFile);
}
if (fileList.get(i).matches("ifz_.*")) {
ifz_lines.addAll(linesOfFile);
}
}
filesContent.put("niod", niod_lines);
filesContent.put("wiener", wl_lines);
filesContent.put("yadvashem", yv_lines);
filesContent.put("jewishmuseumprag", jmp_lines);
filesContent.put("bundesarchiv", bundesarchiv_lines);
filesContent.put("ushmm", ushmm_lines);
filesContent.put("its", its_lines);
filesContent.put("cegesoma", cegesoma_lines);
filesContent.put("ifz", ifz_lines);
System.out.println("NIOD lines: " + niod_lines.size());
System.out.println("WL lines: " + wl_lines.size());
System.out.println("YV lines: " + yv_lines.size());
System.out.println("JMP lines: " + jmp_lines.size());
System.out.println("BA lines: " + bundesarchiv_lines.size());
System.out.println("USHMM lines: " + ushmm_lines.size());
System.out.println("ITS lines: " + its_lines.size());
System.out.println("CEGESOMA lines: " + cegesoma_lines.size());
System.out.println("IFZ lines: " + ifz_lines.size());
return filesContent;
} |
f3ddf601-e635-4dd6-a6eb-fb053da27ea1 | public HashMap<String, HashMap<String, Double>> rankingTfIdf(
HashMap<String, List<String>> extractedFeats, String targetFolder)
throws IOException {
File featuresFile = new File("features.txt");
System.out.println();
System.out.println("Begin ranking of features");
// Read files features.txt and store the features in a list
List<String> featuresList = new ArrayList<String>();
String currentLine;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(targetFolder + featuresFile));
while ((currentLine = br.readLine()) != null) {
if (currentLine.length() > 2){
featuresList.add(currentLine);
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
br.close();
}
// Compute feature occurrences
// and length of each document
HashMap<String, HashMap<String, Integer>> featureOccurrence = new HashMap<String, HashMap<String, Integer>>();
HashMap<String, Integer> lengths = new HashMap<String, Integer>();
for (String key : extractedFeats.keySet()) {
int length = extractedFeats.get(key).size();
HashMap<String, Integer> featuresCount = new HashMap<String, Integer>();
for (int i = 0; i < extractedFeats.get(key).size(); i++) {
if (featuresCount.containsKey(extractedFeats.get(key).get(i))) {
int value = featuresCount.get(extractedFeats.get(key)
.get(i));
featuresCount
.put(extractedFeats.get(key).get(i), value + 1);
} else {
featuresCount.put(extractedFeats.get(key).get(i), 1);
}
}
featureOccurrence.put(key, featuresCount);
lengths.put(key, length);
}
// Compute Term Frequencies
// declaration of TF hashmap for all the descriptions
HashMap<String, HashMap<String, Double>> termFrequencies = new HashMap<String, HashMap<String, Double>>();
for (String key : featureOccurrence.keySet()) {
System.out.println("KEY " + key);
HashMap<String, Double> frequenciesDocument = new HashMap<String, Double>();
// extract maximal frequency of a feature. It will be used for
// normalization of the term frequency
Double max = (double) Collections.max(featureOccurrence.get(key).values());
for (String feat : featureOccurrence.get(key).keySet()) {
Double tfvalue = featureOccurrence.get(key).get(feat) / max;
frequenciesDocument.put(feat, tfvalue);
}
termFrequencies.put(key, frequenciesDocument);
}
// Compute Inverse Document Frequencies
HashMap<String, HashMap<String, Double>> idfs = new HashMap<String, HashMap<String, Double>>();
List<String> institutions = new ArrayList<String>();
institutions.addAll(termFrequencies.keySet());
// here for loop and chech the IDF :-)
for (int i = 0; i < institutions.size(); i++) {
HashMap<String, Double> institutionIdf = new HashMap<String, Double>();
for (String key : termFrequencies.get(institutions.get(i)).keySet()) {
double inDocs = 0;
double idf = 0;
for (int index = 0; index < institutions.size(); index++) {
if (termFrequencies.get(institutions.get(index))
.containsKey(key)) {
inDocs++;
}
}
idf = Math.log(1 + (institutions.size() / inDocs));
institutionIdf.put(key, idf);
}
idfs.put(institutions.get(i), institutionIdf);
}
// ADD checks and print it out
// begin thinking about document to understand the classes.
HashMap<String, HashMap<String, Double>> tfidfs = new HashMap<String, HashMap<String, Double>>();
for (int i = 0; i < institutions.size(); i++) {
HashMap<String, Double> institutionTfIdf = new HashMap<String, Double>();
for (String key : termFrequencies.get(institutions.get(i)).keySet()) {
double tf = termFrequencies.get(institutions.get(i)).get(key);
double idf = idfs.get(institutions.get(i)).get(key);
double tfidf = tf * idf;
institutionTfIdf.put(key, tfidf);
// System.out.println(key + "\t" + tfidf);
}
tfidfs.put(institutions.get(i), institutionTfIdf);
}
// write tfidf files
for (String key : tfidfs.keySet()) {
String filename = key + ".tfidf";
try {
FileWriter fstream = new FileWriter(targetFolder + filename);
BufferedWriter out = new BufferedWriter(fstream);
for (String feat : tfidfs.get(key).keySet()) {
out.write(feat + "\t" + tfidfs.get(key).get(feat));
out.newLine();
}
out.close();
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
}
System.out.println("Vector space built!!");
return tfidfs;
} |
10078714-f3df-4cc0-869a-e5106ebd8c57 | public String getTreeTaggerFolder() {
Properties prop = new Properties();
try {
prop.load(getClass().getResourceAsStream("/config.properties"));
} catch (IOException ex) {
ex.printStackTrace();
}
final String TREETAGGER_FOLDER = prop.getProperty("treetagger_folder");
return TREETAGGER_FOLDER;
} |
7898f60c-b34c-4081-9092-e35962d0f9ec | public static void main( String[] args ) throws IOException, TreeTaggerException
{
String descriptionsFolder = args[0];
String targetFolder = args[1];
//Load collection and file descriptions
LoadFiles upload = new LoadFiles();
HashMap<String, List<String>> uploaded = upload
.loadFiles4Model(descriptionsFolder);
//Tokenize the texts
TokenizeLearnMaterial tokenizeMaterial = new TokenizeLearnMaterial();
HashMap<String, List<String>> tokenized = tokenizeMaterial
.tokenizeDescriptions(uploaded);
uploaded.clear();
//Annotate part of speech
POSannotateLernMaterial annotatePOS = new POSannotateLernMaterial();
HashMap<String, List<String>> annotated = annotatePOS.annotatePOS(tokenized);
//Extract relevant features for each institution
//Infer the features of the vector space
ExtractRelevantFeatures extractFeats = new ExtractRelevantFeatures();
HashMap<String, List<String>> extracted = extractFeats
.extractFeatures(annotated, targetFolder);
//Build vectorial representation of each institution with TF*IDF
RankTfIdf rankFeats = new RankTfIdf();
HashMap<String, HashMap<String, Double>> tfidf = rankFeats
.rankingTfIdf(extracted, targetFolder);
//END
System.out.println( "FINISH!" );
} |
e7e4c30d-ccf1-4317-9103-19cd390e39a9 | public List<String> annotatePOSpeech(List<String> tokenized)
throws IOException, TreeTaggerException {
// Point TT4J to the TreeTagger installation directory. The executable
// is expected
// in the "bin" subdirectory - in this example at
// "/opt/treetagger/bin/tree-tagger"
System.setProperty("treetagger.home", treeTaggerFolder);
TreeTaggerWrapper<String> tt = new TreeTaggerWrapper<String>();
final List<String> outputTreeTagger = new ArrayList<String>();
try {
tt.setModel(treeTaggerFolder + "lib/english.par:utf8");
tt.setHandler(new TokenHandler<String>() {
public void token(String token, String pos, String lemma) {
outputTreeTagger.add(token + "\t" + pos + "\t" + lemma);
}
});
tt.process(tokenized);
} finally {
tt.destroy();
}
return outputTreeTagger;
} |
1b0fbe18-28e5-41e3-9a0e-1e89456e773e | public void token(String token, String pos, String lemma) {
outputTreeTagger.add(token + "\t" + pos + "\t" + lemma);
} |
a7b76523-06d6-4582-8005-20515ac326b8 | public AppTest( String testName )
{
super( testName );
} |
e339e2b0-abeb-4924-9f15-be6bfb152c83 | public static Test suite()
{
return new TestSuite( AppTest.class );
} |
6416777b-4b1c-47fa-9fb0-93ba2d091d38 | public void testApp()
{
assertTrue( true );
} |
dc9cc1c4-00a3-4771-9af6-81dc7fe00a40 | @Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
Config.init(event.getSuggestedConfigurationFile());
ItemsAndBlocks.init();
} |
92f254b2-9177-49e1-a62b-701728d3c781 | @Mod.EventHandler
public void init(FMLInitializationEvent event)
{
MinecraftForge.EVENT_BUS.register(new EventHandler());
} |
696695ef-7ea8-4f34-9cb2-0cb188ad5d5c | @Mod.EventHandler
public void postInit(FMLPostInitializationEvent event)
{} |
396fdae8-5628-45b1-a1ed-e16afa658c73 | public CreativeTabBB() {
super(CreativeTabs.getNextID(), "B&B");
} |
4f4581b5-64d8-4b71-bce5-1032350d9745 | @Override
public Item getTabIconItem() {
return Items.egg;
} |
48ce39a2-c122-4e7d-b5fd-daced003633a | @SideOnly(Side.CLIENT)
public String getTranslatedTabLabel()
{
return "Bits & Bobs";
} |
1af41321-baa7-4e57-b50d-f76b3a1cb854 | protected EnchantmentBB(int id) {
super(id == Ref.opulenceID ? Ref.opulenceID : Ref.earthbaneID, 0, EnumEnchantmentType.all);
this.setName(id == Ref.opulenceID ? "Opulence" : "Earthbane");
this.id = id;
} |
d548afc5-0b98-4d6d-87e4-e4e5ddd2e0b5 | @Override
public boolean canApplyAtEnchantingTable(ItemStack stack)
{
return false;
} |
05c22d6e-1bce-4963-8d7e-a40f485e404e | @Override
public boolean isAllowedOnBooks()
{
return false;
} |
3fd32d39-906b-4770-8b4f-ef68693b1b49 | @Override
public boolean canApplyTogether(Enchantment enchantment)
{
if(id == Ref.opulenceID && (enchantment == Enchantment.fortune || enchantment == Enchantment.silkTouch || enchantment == Enchantment.looting))
{
return false;
}
else
{
return true;
}
} |
a44d97b3-e098-4877-b0b0-4f9cc14dbcd7 | public static void init()
{
initializeBlocks();
registerBlocks();
initializeItems();
registerItems();
registerSmelts();
registerRecipes();
registerOreDict();
} |
c227e713-4224-48e7-868c-de09e3738a40 | public static void initializeBlocks()
{
oreCrackedIron.setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockName("oreCrackedIron").setBlockTextureName(TEXTURE + "oreCrackedIron");
oreCrackedGold.setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockName("oreCrackedGold").setBlockTextureName(TEXTURE + "oreCrackedGold");
} |
f5c6b0fc-be59-4bc8-afcb-6d3b16e3b6e3 | public static void registerBlocks()
{
GameRegistry.registerBlock(oreCrackedIron, "oreCrackedIron");
GameRegistry.registerBlock(oreCrackedGold, "oreCrackedGold");
} |
5a3dec22-28f7-4391-8001-02893b95d02e | public static void initializeItems()
{
diamondTP.setUnlocalizedName("thickPickaxeDiamond").setTextureName(TEXTURE + "thickPickaxeDiamond");
diamondTS.setUnlocalizedName("thickShovelDiamond").setTextureName(TEXTURE + "thickShovelDiamond");
diamondTA.setUnlocalizedName("thickAxeDiamond").setTextureName(TEXTURE + "thickAxeDiamond");
ironTP.setUnlocalizedName("thickPickaxeIron").setTextureName(TEXTURE + "thickPickaxeIron");
ironTS.setUnlocalizedName("thickShovelIron").setTextureName(TEXTURE + "thickShovelIron");
ironTA.setUnlocalizedName("thickAxeIron").setTextureName(TEXTURE + "thickAxeIron");
stoneTP.setUnlocalizedName("thickPickaxeStone").setTextureName(TEXTURE + "thickPickaxeStone");
stoneTS.setUnlocalizedName("thickShovelStone").setTextureName(TEXTURE + "thickShovelStone");
stoneTA.setUnlocalizedName("thickAxeStone").setTextureName(TEXTURE + "thickAxeStone");
lapisTP.setUnlocalizedName("thickPickaxeLapis").setTextureName(TEXTURE + "thickPickaxeLapis");
lapisTS.setUnlocalizedName("thickShovelLapis").setTextureName(TEXTURE + "thickShovelLapis");
lapisTA.setUnlocalizedName("thickAxeLapis").setTextureName(TEXTURE + "thickAxeLapis");
lapisPick.setUnlocalizedName("pickaxeLapis").setTextureName(TEXTURE + "pickaxeLapis");
lapisShovel.setUnlocalizedName("shovelLapis").setTextureName(TEXTURE + "shovelLapis");
lapisAxe.setUnlocalizedName("axeLapis").setTextureName(TEXTURE + "axeLapis");
lapisSword.setUnlocalizedName("swordLapis").setTextureName(TEXTURE + "swordLapis");
diamondPlate.setUnlocalizedName("plateDiamond").setTextureName(TEXTURE + "diamondPlate").setCreativeTab(Ref.tab);
ironPlate.setUnlocalizedName("plateIron").setTextureName(TEXTURE + "ironPlate").setCreativeTab(Ref.tab);
stonePlate.setUnlocalizedName("plateStone").setTextureName(TEXTURE + "stonePlate").setCreativeTab(Ref.tab);
lapisPlate.setUnlocalizedName("plateLapis").setTextureName(TEXTURE + "lapisPlate").setCreativeTab(Ref.tab);
lapisPlateLarge.setUnlocalizedName("plateLapisLarge").setTextureName(TEXTURE + "lapisPlateLarge").setCreativeTab(Ref.tab);
lapisChunk.setUnlocalizedName("chunkLapis").setTextureName(TEXTURE + "lapisChunk").setCreativeTab(Ref.tab);
toolHandle.setUnlocalizedName("toolHandle").setTextureName(TEXTURE + "toolHandle").setCreativeTab(Ref.tab);
opulenceEnchantItem.setUnlocalizedName("enchantItemOpulence").setTextureName(TEXTURE + "opulenceEnchant");
earthbaneEnchantItem.setUnlocalizedName("enchantItemEarthbane").setTextureName(TEXTURE + "earthbaneEnchant");
pickEB[0].setUnlocalizedName("pickEBIron").setTextureName(TEXTURE + "thickPickaxeIron").setCreativeTab(null);
pickEB[1].setUnlocalizedName("pickEBLapis").setTextureName(TEXTURE + "thickPickaxeLapis").setCreativeTab(null);
pickEB[2].setUnlocalizedName("pickEBDiamond").setTextureName(TEXTURE + "thickPickaxeDiamond").setCreativeTab(null);
shovelEB[0].setUnlocalizedName("shovelEBIron").setTextureName(TEXTURE + "thickShovelIron").setCreativeTab(null);
shovelEB[1].setUnlocalizedName("shovelEBLapis").setTextureName(TEXTURE + "thickShovelLapis").setCreativeTab(null);
shovelEB[2].setUnlocalizedName("shovelEBDiamond").setTextureName(TEXTURE + "thickShovelDiamond").setCreativeTab(null);
} |
ed955f6b-7664-423b-b5fb-872da4105f77 | public static void registerItems()
{
GameRegistry.registerItem(diamondTP, "thickPickaxeDiamond");
GameRegistry.registerItem(diamondTS, "thickShovelDiamond");
GameRegistry.registerItem(diamondTA, "thickAxeDiamond");
GameRegistry.registerItem(ironTP, "thickPickaxeIron");
GameRegistry.registerItem(ironTS, "thickShovelIron");
GameRegistry.registerItem(ironTA, "thickAxeIron");
GameRegistry.registerItem(stoneTP, "thickPickaxeStone");
GameRegistry.registerItem(stoneTS, "thickShovelStone");
GameRegistry.registerItem(stoneTA, "thickAxeStone");
GameRegistry.registerItem(lapisTP, "thickPickaxeLapis");
GameRegistry.registerItem(lapisTS, "thickShovelLapis");
GameRegistry.registerItem(lapisTA, "thickAxeLapis");
GameRegistry.registerItem(lapisPick, "pickaxeLapis");
GameRegistry.registerItem(lapisShovel, "shovelLapis");
GameRegistry.registerItem(lapisAxe, "axeLapis");
GameRegistry.registerItem(lapisSword, "swordLapis");
GameRegistry.registerItem(diamondPlate, "plateDiamond");
GameRegistry.registerItem(ironPlate, "plateIron");
GameRegistry.registerItem(stonePlate, "plateStone");
GameRegistry.registerItem(lapisPlate, "plateLapis");
GameRegistry.registerItem(lapisPlateLarge, "plateLapisLarge");
GameRegistry.registerItem(lapisChunk, "chunkLapis");
GameRegistry.registerItem(toolHandle, "toolHandle");
GameRegistry.registerItem(opulenceEnchantItem, "enchantItemOpulence");
GameRegistry.registerItem(earthbaneEnchantItem, "enchantItemEarthbane");
GameRegistry.registerItem(smashedOre, "smashedOre");
GameRegistry.registerItem(pickEB[0], "pickEBIron");
GameRegistry.registerItem(pickEB[1], "pickEBLapis");
GameRegistry.registerItem(pickEB[2], "pickEBDiamond");
GameRegistry.registerItem(shovelEB[0], "shovelEBIron");
GameRegistry.registerItem(shovelEB[1], "shovelEBLapis");
GameRegistry.registerItem(shovelEB[2], "shovelEBDiamond");
} |
4999bf63-625e-4534-904f-1d70c12bbadc | public static void registerSmelts()
{
GameRegistry.addSmelting(oreCrackedIron, new ItemStack(Items.iron_ingot), 3.0F);
GameRegistry.addSmelting(oreCrackedGold, new ItemStack(Items.gold_ingot), 3.0F);
} |
7c14e7a3-771c-4c1d-9739-2031c2a8c73a | public static void registerRecipes()
{
GameRegistry.addShapedRecipe(new ItemStack(diamondTP), new Object[]{"DDD", " P ", " H ", 'D', new ItemStack(diamondPlate), 'P', new ItemStack(Items.diamond_pickaxe), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(diamondTS), new Object[]{"D", "S", "H", 'D', new ItemStack(diamondPlate), 'S', new ItemStack(Items.diamond_shovel), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(diamondTA), new Object[]{"DD", "DA", " H", 'D', new ItemStack(diamondPlate), 'A', new ItemStack(Items.diamond_axe), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(ironTP), new Object[]{"III", " P ", " H ", 'I', new ItemStack(ironPlate), 'P', new ItemStack(Items.iron_pickaxe), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(ironTS), new Object[]{"I", "S", "H", 'I', new ItemStack(ironPlate), 'S', new ItemStack(Items.iron_shovel), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(ironTA), new Object[]{"II", "IA", " H", 'I', new ItemStack(ironPlate), 'A', new ItemStack(Items.iron_axe), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(stoneTP), new Object[]{"RRR", " P ", " H ", 'R', new ItemStack(stonePlate), 'P', new ItemStack(Items.stone_pickaxe), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(stoneTS), new Object[]{"R", "S", "H", 'R', new ItemStack(stonePlate), 'S', new ItemStack(Items.stone_shovel), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(stoneTA), new Object[]{"RR", "RA", " H", 'R', new ItemStack(stonePlate), 'A', new ItemStack(Items.stone_axe), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(lapisTP), new Object[]{"LLL", " P ", " H ", 'D', new ItemStack(lapisPlateLarge), 'P', new ItemStack(lapisPick), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(lapisTS), new Object[]{"L", "S", "H", 'D', new ItemStack(lapisPlateLarge), 'S', new ItemStack(lapisShovel), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(lapisTA), new Object[]{"LL", "LA", " H", 'D', new ItemStack(lapisPlateLarge), 'A', new ItemStack(lapisAxe), 'H', new ItemStack(toolHandle)});
GameRegistry.addShapedRecipe(new ItemStack(lapisPick), new Object[]{"LLL", " s ", " s ", 'L', new ItemStack(lapisPlate), 's', new ItemStack(Items.stick)});
GameRegistry.addShapedRecipe(new ItemStack(lapisShovel), new Object[]{"L", "s", "s", 'L', new ItemStack(lapisPlate), 's', new ItemStack(Items.stick)});
GameRegistry.addShapedRecipe(new ItemStack(lapisAxe), new Object[]{"LL", "Ls", "s ", 'L', new ItemStack(lapisPlate), 's', new ItemStack(Items.stick)});
GameRegistry.addShapedRecipe(new ItemStack(lapisSword), new Object[]{"L", "L", "s", 'L', new ItemStack(lapisPlate), 's', new ItemStack(Items.stick)});
GameRegistry.addShapedRecipe(new ItemStack(diamondPlate), new Object[]{"DDD", 'D', new ItemStack(Items.diamond)});
GameRegistry.addShapedRecipe(new ItemStack(ironPlate), new Object[]{"III", 'I', new ItemStack(Items.iron_ingot)});
GameRegistry.addShapedRecipe(new ItemStack(stonePlate), new Object[]{"CSC", 'S', new ItemStack(Blocks.stone), 'C', new ItemStack(Blocks.cobblestone)});
GameRegistry.addShapedRecipe(new ItemStack(lapisPlate), new Object[]{"LLL", 'L', new ItemStack (lapisChunk)});
GameRegistry.addShapedRecipe(new ItemStack(lapisPlateLarge), new Object[]{"LLL", "LLL", 'L', new ItemStack (lapisPlate)});
GameRegistry.addShapedRecipe(new ItemStack(lapisChunk), new Object[]{" L ", "LLL", " L ", 'L', new ItemStack(Items.dye, 1, 4)});
GameRegistry.addShapedRecipe(new ItemStack(toolHandle), new Object[]{"SIS", "SIS", "SIS", 'S', new ItemStack(Blocks.stone), 'I', new ItemStack(Items.stick)});
GameRegistry.addShapedRecipe(new ItemStack(opulenceEnchantItem), new Object[]{"DLD", "RCR", "DLD", 'D', new ItemStack(Items.diamond), 'L', new ItemStack(Blocks.lapis_block), 'R', new ItemStack(Blocks.redstone_block), 'C', new ItemStack(earthbaneEnchantItem)});
GameRegistry.addShapedRecipe(new ItemStack(earthbaneEnchantItem), new Object[]{"CTC", "TDT", "CTC", 'C', new ItemStack(Blocks.cobblestone), 'T', new ItemStack(Blocks.tnt), 'D', new ItemStack(Items.diamond)});
GameRegistry.addShapelessRecipe(new ItemStack(Items.diamond, 3), new ItemStack(diamondPlate));
GameRegistry.addShapelessRecipe(new ItemStack(Items.iron_ingot, 3), new ItemStack(ironPlate));
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.cobblestone, 3), new ItemStack(stonePlate));
GameRegistry.addShapelessRecipe(new ItemStack(lapisChunk, 3), new ItemStack(lapisPlate));
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.lapis_block, 6), new ItemStack(lapisPlateLarge));
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 5, 4), new ItemStack(lapisChunk));
} |
2b7407bb-3f31-4324-8cdd-9776b1b8fbb5 | public static void registerOreDict()
{} |
25cc6c89-809c-4baf-9ed0-da36e3d68c53 | public static void init(File file)
{
Configuration config = new Configuration(file);
config.load();
Ref.opulenceID = config.get("Settings", "Opulence Enchantment ID", 60).getInt();
Ref.earthbaneID = config.get("Settings", "Earthbane Enchantment ID", 63).getInt();
config.save();
} |
67de8eee-378d-4621-873d-0cca55ffb7d2 | public ItemEBPick(ToolMaterial material)
{
super(material);
} |
4aa96ff1-238a-4715-835f-80fdf627680c | @Override
public boolean onBlockDestroyed(ItemStack tool, World world, Block block, int x, int y, int z, EntityLivingBase user)
{
if(user instanceof EntityPlayer && canMine(block) && !world.isRemote)
{
EntityPlayer player = (EntityPlayer)user;
int lvlE = tool.stackTagCompound.getInteger("lvl");
boolean silky = EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, tool) > 0 ? true : false;
Block dropBlock = block == Blocks.stone && !silky ? Blocks.cobblestone : block;
MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, player, true, 4.5D);
int limit = 0;
int count = 0;
int xStart = lvlE;
int xStop = lvlE;
int yStart = 1;
int yStop = lvlE == 1 ? 1 : 3;
int zStart = lvlE;
int zStop = lvlE;
//0 = Bottom, 1 = Top, 2 = , 3 = , 4 = East, 5 = West
switch (mop.sideHit)
{
case 0:
System.out.println("Hit Bottom");
yStart = 0;
yStop = 2*lvlE;
break;
case 1:
System.out.println("Hit Top");
yStart = 2*lvlE;
yStop = 0;
break;
case 2:
System.out.println("Hit 2");
zStart = 0;
zStop = 2*lvlE;
break;
case 3:
System.out.println("Hit 3");
zStart = 2*lvlE;
zStop = 0;
break;
case 4:
System.out.println("Hit 4");
xStart = 0;
xStop = 2*lvlE;
break;
case 5:
System.out.println("Hit 5");
xStart = 2*lvlE;
xStop = 0;
break;
}
Slot slot;
ArrayList<Integer> slots = new ArrayList();
ArrayList<Integer> numInSlot = new ArrayList();
int drops = 0;
for(int i = 9; i < 45; i++)
{
slot = player.inventoryContainer.getSlot(i);
if (slot.getStack() == null)
{
slots.add(i);
numInSlot.add(64);
drops += 64;
}
else if(slot.getStack().getItem() == Item.getItemFromBlock(dropBlock) && slot.getStack().stackSize < slot.getSlotStackLimit())
{
slots.add(i);
numInSlot.add(slot.getSlotStackLimit() - slot.getStack().stackSize);
drops += slot.getSlotStackLimit() - slot.getStack().stackSize;
}
}
int max = lvlE == 1 ? 27 : 125;
drops = drops > max ? max : drops;
limit = drops;
for (int xPos = x - xStart; xPos <= x + xStop; xPos++)
{
for (int yPos = y - yStart; yPos <= y + yStop; yPos++)
{
for (int zPos = z - zStart; zPos <= z + zStop; zPos++)
{
if(world.getBlock(xPos, yPos, zPos) == block)
{
if(limit < 1)
{
break;
}
world.setBlockToAir(xPos, yPos, zPos);
count++;
limit--;
}
}
}
}
if(tool.stackTagCompound.getBoolean("drops") == true)
{
drops = count;
Iterator slotIt = slots.iterator();
Iterator dropsIt = numInSlot.iterator();
int putInSlot;
int currentSlot;
int putStackSize;
int currStackSize;
while(drops > 0)
{
putInSlot = (Integer)dropsIt.next();
currentSlot = (Integer)slotIt.next();
try
{
currStackSize = player.inventoryContainer.getSlot(currentSlot).getStack().stackSize;
}
catch(NullPointerException e)
{
currStackSize = 0;
}
if(putInSlot > drops)
putInSlot = drops;
putStackSize = currStackSize + putInSlot;
player.inventoryContainer.putStackInSlot(currentSlot, new ItemStack(dropBlock, putStackSize));
drops -= putInSlot;
}
}
}
return true;
} |
e423b40f-e2df-448f-9564-19102ccc3a01 | private boolean canMine(Block block)
{
return block == Blocks.stone ? true : block == Blocks.netherrack ? true : block == Blocks.end_stone ? true : block == Blocks.obsidian ? true : false;
} |
5c225d79-fef9-48e2-a83c-3acbd3bc3c17 | @Override
public void onCreated(ItemStack item, World world, EntityPlayer player)
{
item.stackTagCompound = new NBTTagCompound();
item.stackTagCompound.setInteger("lvl", 1);
item.stackTagCompound.setBoolean("drops", true);
} |
ab32c368-9af3-441b-bd6d-b7628620ae6d | @Override
public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player)
{
if(player.isSneaking())
{
ItemStack result = item;
Boolean drops = result.stackTagCompound.getBoolean("drops");
result.stackTagCompound.setBoolean("drops", drops == true ? false : true);
return result;
}
return item;
} |
0c430667-5c01-40ea-839a-4445b7e1dfd4 | public ItemThickShovel(ToolMaterial material)
{
super(EnumHelper.addToolMaterial("thick" + material.name(), material.getHarvestLevel(), material.getMaxUses()*4, material.getEfficiencyOnProperMaterial(), material.getDamageVsEntity(), material.getEnchantability()));
this.setCreativeTab(Ref.tab);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.