Skip to content

Commit 947590f

Browse files
committed
Merge remote-tracking branch 'upstream/master' into windows-integration
2 parents 0fbd566 + 96761f2 commit 947590f

284 files changed

Lines changed: 67654 additions & 70078 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/**
2-
* This software is released under the University of Illinois/Research and
3-
* Academic Use License. See the LICENSE file in the root folder for details.
4-
* Copyright (c) 2016
2+
* This software is released under the University of Illinois/Research and Academic Use License. See
3+
* the LICENSE file in the root folder for details. Copyright (c) 2016
54
*
6-
* Developed by:
7-
* The Cognitive Computations Group
8-
* University of Illinois at Urbana-Champaign
5+
* Developed by: The Cognitive Computations Group University of Illinois at Urbana-Champaign
96
* http://cogcomp.cs.illinois.edu/
107
*/
118
/**
@@ -27,64 +24,64 @@
2724
*/
2825
public class Document {
2926

30-
private final String label;
31-
private final List<String> words;
32-
private String guid;
33-
34-
/**
35-
* Create a new document
36-
*
37-
* @throws IOException
38-
*/
39-
public Document(File file, String label) throws IOException {
40-
this.label = label;
41-
BufferedReader reader = new BufferedReader(new FileReader(file));
42-
43-
words = new ArrayList<String>();
44-
String line = null;
45-
while ((line = reader.readLine()) != null) {
46-
for (String word : line.split("\\s+"))
47-
words.add(word.trim());
48-
}
49-
50-
reader.close();
51-
}
52-
53-
public Document(File file) throws IOException {
54-
this(file, "unknown");
55-
}
56-
57-
public Document(List<String> words) {
58-
59-
this(words, "unknown");
60-
}
61-
62-
public void setGUID(String guid) {
63-
this.guid = guid;
64-
}
65-
66-
public String getGUID(){
67-
return this.guid;
68-
}
69-
70-
71-
public Document(List<String> words, String label) {
72-
this.words = words;
73-
this.label = label;
74-
}
75-
76-
public String getLabel() {
77-
return label;
78-
}
79-
80-
public List<String> getWords() {
81-
return Collections.unmodifiableList(words);
82-
}
83-
84-
@Override
85-
public String toString() {
86-
// TODO Auto-generated method stub
87-
return label + ", " + words;
88-
}
27+
private final String label;
28+
private final List<String> words;
29+
private String guid;
30+
31+
/**
32+
* Create a new document
33+
*
34+
* @throws IOException
35+
*/
36+
public Document(File file, String label) throws IOException {
37+
this.label = label;
38+
BufferedReader reader = new BufferedReader(new FileReader(file));
39+
40+
words = new ArrayList<String>();
41+
String line = null;
42+
while ((line = reader.readLine()) != null) {
43+
for (String word : line.split("\\s+"))
44+
words.add(word.trim());
45+
}
46+
47+
reader.close();
48+
}
49+
50+
public Document(File file) throws IOException {
51+
this(file, "unknown");
52+
}
53+
54+
public Document(List<String> words) {
55+
56+
this(words, "unknown");
57+
}
58+
59+
public void setGUID(String guid) {
60+
this.guid = guid;
61+
}
62+
63+
public String getGUID() {
64+
return this.guid;
65+
}
66+
67+
68+
public Document(List<String> words, String label) {
69+
this.words = words;
70+
this.label = label;
71+
}
72+
73+
public String getLabel() {
74+
return label;
75+
}
76+
77+
public List<String> getWords() {
78+
return Collections.unmodifiableList(words);
79+
}
80+
81+
@Override
82+
public String toString() {
83+
// TODO Auto-generated method stub
84+
return label + ", " + words;
85+
}
8986

9087
}

lbjava-examples/src/main/java/edu/illinois/cs/cogcomp/lbjava/examples/DocumentReader.java

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/**
2-
* This software is released under the University of Illinois/Research and
3-
* Academic Use License. See the LICENSE file in the root folder for details.
4-
* Copyright (c) 2016
2+
* This software is released under the University of Illinois/Research and Academic Use License. See
3+
* the LICENSE file in the root folder for details. Copyright (c) 2016
54
*
6-
* Developed by:
7-
* The Cognitive Computations Group
8-
* University of Illinois at Urbana-Champaign
5+
* Developed by: The Cognitive Computations Group University of Illinois at Urbana-Champaign
96
* http://cogcomp.cs.illinois.edu/
107
*/
118
package edu.illinois.cs.cogcomp.lbjava.examples;
@@ -26,50 +23,48 @@
2623
*
2724
*/
2825
public class DocumentReader implements Parser {
29-
26+
3027
private final List<File> files;
31-
28+
3229
private int currentFileId;
33-
30+
3431
/**
3532
*
3633
*/
3734
public DocumentReader(String directory) {
3835
File d = new File(directory);
39-
36+
4037
if (!d.exists()) {
4138
System.err.println(directory + " does not exist!");
4239
System.exit(-1);
4340
}
44-
41+
4542
if (!d.isDirectory()) {
4643
System.err.println(directory + " is not a directory!");
4744
System.exit(-1);
4845
}
49-
46+
5047
files = new ArrayList<File>();
5148
for (File f : d.listFiles()) {
5249
if (f.isDirectory()) {
5350
files.addAll(Arrays.asList(f.listFiles()));
5451
}
5552
}
56-
53+
5754
Collections.shuffle(files);
5855
currentFileId = 0;
5956
}
60-
61-
public void close() {
62-
}
63-
57+
58+
public void close() {}
59+
6460
public Object next() {
65-
61+
6662
if (currentFileId < files.size()) {
6763
File file = files.get(currentFileId++);
68-
69-
String[] split = file.getPath().split("\\" +File.separator);
70-
64+
65+
String[] split = file.getPath().split("\\" + File.separator);
7166
String label = split[split.length - 2];
72-
67+
7368
try {
7469
return new Document(file, label);
7570
} catch (IOException e) {
@@ -79,9 +74,9 @@ public Object next() {
7974
}
8075
} else
8176
return null;
82-
77+
8378
}
84-
79+
8580
public void reset() {
8681
currentFileId = 0;
8782
}

lbjava-examples/src/main/java/edu/illinois/cs/cogcomp/lbjava/examples/badges/BadgeDataReader.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/**
2-
* This software is released under the University of Illinois/Research and
3-
* Academic Use License. See the LICENSE file in the root folder for details.
4-
* Copyright (c) 2016
2+
* This software is released under the University of Illinois/Research and Academic Use License. See
3+
* the LICENSE file in the root folder for details. Copyright (c) 2016
54
*
6-
* Developed by:
7-
* The Cognitive Computations Group
8-
* University of Illinois at Urbana-Champaign
5+
* Developed by: The Cognitive Computations Group University of Illinois at Urbana-Champaign
96
* http://cogcomp.cs.illinois.edu/
107
*/
118
/**
@@ -37,7 +34,7 @@ public class BadgeDataReader implements Parser {
3734

3835
private int currentline;
3936
private BufferedReader br;
40-
37+
4138
/**
4239
*
4340
*/
@@ -52,23 +49,22 @@ public BadgeDataReader(String file) {
5249
}
5350
br.close();
5451
} catch (Exception e) {
55-
52+
5653
}
5754
}
58-
59-
public void close() {
60-
}
61-
55+
56+
public void close() {}
57+
6258
public Object next() {
63-
59+
6460
if (currentline == lines.size()) {
6561
return null;
6662
} else {
6763
currentline++;
6864
return lines.get(currentline - 1);
6965
}
7066
}
71-
67+
7268
public void reset() {
7369
currentline = 0;
7470
}
Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/**
2-
* This software is released under the University of Illinois/Research and
3-
* Academic Use License. See the LICENSE file in the root folder for details.
4-
* Copyright (c) 2016
2+
* This software is released under the University of Illinois/Research and Academic Use License. See
3+
* the LICENSE file in the root folder for details. Copyright (c) 2016
54
*
6-
* Developed by:
7-
* The Cognitive Computations Group
8-
* University of Illinois at Urbana-Champaign
5+
* Developed by: The Cognitive Computations Group University of Illinois at Urbana-Champaign
96
* http://cogcomp.cs.illinois.edu/
107
*/
118
package edu.illinois.cs.cogcomp.lbjava.examples.badges;
@@ -17,24 +14,24 @@
1714

1815
public class FeatureWeightCalculator {
1916

20-
/**
21-
* @param args
22-
*/
23-
public static void main(String[] args) {
24-
// TODO Auto-generated method stub
25-
BadgeClassifier bc = new BadgeClassifier();
26-
Lexicon lc = bc.getLexicon();
27-
for (int i = 0; i < lc.size(); i++) {
28-
Feature f = lc.lookupKey(i);
29-
System.out.println(f);
30-
int[] id = new int[1];
31-
double[] val = new double[1];
32-
id[0] = i;
33-
val[0] = 1;
34-
ScoreSet ss = bc.scores(id, val);
35-
System.out.println(ss.get("positive"));
36-
}
37-
System.out.println("threshold:" + bc.getThreshold());
38-
}
17+
/**
18+
* @param args
19+
*/
20+
public static void main(String[] args) {
21+
// TODO Auto-generated method stub
22+
BadgeClassifier bc = new BadgeClassifier();
23+
Lexicon lc = bc.getLexicon();
24+
for (int i = 0; i < lc.size(); i++) {
25+
Feature f = lc.lookupKey(i);
26+
System.out.println(f);
27+
int[] id = new int[1];
28+
double[] val = new double[1];
29+
id[0] = i;
30+
val[0] = 1;
31+
ScoreSet ss = bc.scores(id, val);
32+
System.out.println(ss.get("positive"));
33+
}
34+
System.out.println("threshold:" + bc.getThreshold());
35+
}
3936

4037
}

0 commit comments

Comments
 (0)