id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
65538552-5459-4594-a726-1d351c2b3183 | public static void writeSingleFile(Integer docId, String url, String path, String parentUrl, String title, String h1, String h2, String h3, String bold,
String strong, String em, String anchorText, String parsedData) throws IOException {
FileWriter fstream = new FileWriter("combinedwebpages", true);
BufferedWri... |
9736fd9c-95fd-43fd-860d-ec0017cc6f7d | public static ArrayList<String> tokenizeFile(File input) throws IOException {
BufferedReader inputBR = null;
ArrayList<String> tokanizedWords = new ArrayList<String>();
ArrayList<String> tempArrList = new ArrayList<String>();
try {
String inputString = "";
// Storing all stop words in a HashSet
... |
5fa98125-efa9-46fe-9d11-60b70f68929f | public static ArrayList<String> removeStopWords(List<String> wordList, HashSet<String> stopWords) {
ArrayList<String> modifiedWordList = new ArrayList<String>(wordList);
for(String word: wordList) {
if(stopWords.contains(word)) {
modifiedWordList.remove(word);
}
}
return modifiedWordList;
} |
63088b29-c570-4ef8-a667-eab6e2767aab | public static void printFrequencies(List<Frequency> frequencies) {
int totTwoGrmCnt = 0;
Boolean isTwoGram = false;
for (Frequency frequency : frequencies) {
totTwoGrmCnt += frequency.getFrequency();
if(frequency.getText().split(" ").length > 1) isTwoGram = true;
}
if(isTwoGram) {
System.out.println(... |
96087077-3452-46c3-ad74-2fa1e806673e | public static List<Frequency> computeFourGramFrequencies(ArrayList<String> words) {
List<Frequency> fourGramList = new ArrayList<Frequency>();
Map<String, Integer> fourGramMap = new TreeMap<String, Integer>();
// Adding a pair of words and its corresponding frequency in a TreeMap.
for (int i=0;i<words.size()... |
e248a0fb-d353-4a9a-b58e-c006eb98e638 | public Frequency(String word) {
this.word = word;
this.frequency = 0;
} |
8c3eeb3c-6958-4e32-a39a-79d4c093a6e0 | public Frequency(String word, int frequency) {
this.word = word;
this.frequency = frequency;
} |
f8081d44-558e-417f-a946-6a834cdec418 | public String getText() {
return word;
} |
b4edce29-2d3f-4b02-a08e-0a6667be7966 | public int getFrequency() {
return frequency;
} |
14cb7ea9-710e-4bc7-9a87-3f111f79c8a7 | public void incrementFrequency() {
frequency++;
} |
1946767a-119c-45e0-b88c-aef649fe72fd | @Override
public String toString() {
return word + "\t" + frequency;
} |
4aa8d601-334e-4848-b234-061d4a487897 | public JSONArray() {
this.myArrayList = new ArrayList();
} |
b7747783-9d50-47a2-8a22-23bf6b00c9c7 | public JSONArray(JSONTokener x) throws JSONException {
this();
if (x.nextClean() != '[') {
throw x.syntaxError("A JSONArray text must start with '['");
}
if (x.nextClean() != ']') {
x.back();
for (;;) {
if (x.nextClean() == ',') {
... |
62674857-a438-4b89-b68d-8c908f886425 | public JSONArray(String source) throws JSONException {
this(new JSONTokener(source));
} |
935f2051-0e9f-4aa0-85cb-bb22729c5d43 | public JSONArray(Collection collection) {
this.myArrayList = new ArrayList();
if (collection != null) {
Iterator iter = collection.iterator();
while (iter.hasNext()) {
this.myArrayList.add(JSONObject.wrap(iter.next()));
}
}
} |
1c1abc55-68ab-4a65-926a-bd473a8ced52 | public JSONArray(Object array) throws JSONException {
this();
if (array.getClass().isArray()) {
int length = Array.getLength(array);
for (int i = 0; i < length; i += 1) {
this.put(JSONObject.wrap(Array.get(array, i)));
}
} else {
th... |
c544aaf9-c0f5-4863-8693-c779cc68b3db | public Object get(int index) throws JSONException {
Object object = this.opt(index);
if (object == null) {
throw new JSONException("JSONArray[" + index + "] not found.");
}
return object;
} |
a589e148-b79a-4e2e-a694-c17770e27e26 | public boolean getBoolean(int index) throws JSONException {
Object object = this.get(index);
if (object.equals(Boolean.FALSE)
|| (object instanceof String && ((String) object)
.equalsIgnoreCase("false"))) {
return false;
} else if (object.equal... |
d3fc6aa8-16b7-444b-8254-298167fe3c52 | public double getDouble(int index) throws JSONException {
Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).doubleValue()
: Double.parseDouble((String) object);
} catch (Exception e) {
throw new JSONException("J... |
12094b41-710e-45db-be85-92a8e7dcb7a7 | public int getInt(int index) throws JSONException {
Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).intValue()
: Integer.parseInt((String) object);
} catch (Exception e) {
throw new JSONException("JSONArray[" ... |
ec59fb95-f191-4720-8d0f-4e2f60f7ca02 | public JSONArray getJSONArray(int index) throws JSONException {
Object object = this.get(index);
if (object instanceof JSONArray) {
return (JSONArray) object;
}
throw new JSONException("JSONArray[" + index + "] is not a JSONArray.");
} |
bb951574-9e93-4c8d-8402-9ec60215058a | public JSONObject getJSONObject(int index) throws JSONException {
Object object = this.get(index);
if (object instanceof JSONObject) {
return (JSONObject) object;
}
throw new JSONException("JSONArray[" + index + "] is not a JSONObject.");
} |
159609c7-d780-46bb-8780-d14397c7a1e4 | public long getLong(int index) throws JSONException {
Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).longValue()
: Long.parseLong((String) object);
} catch (Exception e) {
throw new JSONException("JSONArray["... |
428e0383-3926-43fc-a275-52123d955027 | public String getString(int index) throws JSONException {
Object object = this.get(index);
if (object instanceof String) {
return (String) object;
}
throw new JSONException("JSONArray[" + index + "] not a string.");
} |
21911af7-d127-40a3-b754-461d0bb4e9ee | public boolean isNull(int index) {
return JSONObject.NULL.equals(this.opt(index));
} |
4adfc109-6df0-4956-89f8-d5f43e80ebdc | public String join(String separator) throws JSONException {
int len = this.length();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < len; i += 1) {
if (i > 0) {
sb.append(separator);
}
sb.append(JSONObject.valueToString(this.myArrayL... |
e66ceb1e-29f9-4828-b825-b2b37a88a6d1 | public int length() {
return this.myArrayList.size();
} |
c6daf1ef-3f72-406e-9ec8-57cfc4beab36 | public Object opt(int index) {
return (index < 0 || index >= this.length()) ? null : this.myArrayList
.get(index);
} |
77a68ff7-ba2b-4472-81a1-facb1e0cc997 | public boolean optBoolean(int index) {
return this.optBoolean(index, false);
} |
cde4cbe6-44b4-4e05-9644-1a49e56fe0e8 | public boolean optBoolean(int index, boolean defaultValue) {
try {
return this.getBoolean(index);
} catch (Exception e) {
return defaultValue;
}
} |
3f7058f7-3fe0-4a1a-9756-c00f1308d854 | public double optDouble(int index) {
return this.optDouble(index, Double.NaN);
} |
89b9db90-3b90-4468-9271-56dfe05a2597 | public double optDouble(int index, double defaultValue) {
try {
return this.getDouble(index);
} catch (Exception e) {
return defaultValue;
}
} |
be3d973e-c898-4539-a690-6e3429df89bc | public int optInt(int index) {
return this.optInt(index, 0);
} |
e33d8ce8-9e57-46f3-9fb1-396789265172 | public int optInt(int index, int defaultValue) {
try {
return this.getInt(index);
} catch (Exception e) {
return defaultValue;
}
} |
7bd008a1-dc96-44b1-85ff-d66bb67bded2 | public JSONArray optJSONArray(int index) {
Object o = this.opt(index);
return o instanceof JSONArray ? (JSONArray) o : null;
} |
f6f40395-0af3-446e-9483-56a530415f2a | public JSONObject optJSONObject(int index) {
Object o = this.opt(index);
return o instanceof JSONObject ? (JSONObject) o : null;
} |
fecde42a-f059-4b29-9a0f-4f7011e190ad | public long optLong(int index) {
return this.optLong(index, 0);
} |
832ab319-dfe0-40be-95ad-6729cfcba304 | public long optLong(int index, long defaultValue) {
try {
return this.getLong(index);
} catch (Exception e) {
return defaultValue;
}
} |
51ab1326-e247-47c3-ac55-f4b6a2139369 | public String optString(int index) {
return this.optString(index, "");
} |
e3d1424b-707c-48d9-84ea-4924b1e0a025 | public String optString(int index, String defaultValue) {
Object object = this.opt(index);
return JSONObject.NULL.equals(object) ? defaultValue : object
.toString();
} |
ccd72706-e4f3-4a09-990e-3a22ad0bf3dc | public JSONArray put(boolean value) {
this.put(value ? Boolean.TRUE : Boolean.FALSE);
return this;
} |
c50fdea9-76fa-478f-93f3-2fb84755f497 | public JSONArray put(Collection value) {
this.put(new JSONArray(value));
return this;
} |
bea63e19-bed5-46d1-90ac-f1157241e1ee | public JSONArray put(double value) throws JSONException {
Double d = new Double(value);
JSONObject.testValidity(d);
this.put(d);
return this;
} |
d6777dff-304b-46b6-85ea-bc6a54c0c2e6 | public JSONArray put(int value) {
this.put(new Integer(value));
return this;
} |
0f776ce6-e73b-45fb-ad0c-d79445521d4a | public JSONArray put(long value) {
this.put(new Long(value));
return this;
} |
e731a3e4-807b-45be-9ac8-e266fc93a97f | public JSONArray put(Map value) {
this.put(new JSONObject(value));
return this;
} |
e106e65d-c571-44db-858b-d1ff443fecb0 | public JSONArray put(Object value) {
this.myArrayList.add(value);
return this;
} |
e80f4ca0-1e76-44d1-bd17-82cff59de8cf | public JSONArray put(int index, boolean value) throws JSONException {
this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
return this;
} |
111cb9a4-8c5f-4480-8724-eda0abffcad1 | public JSONArray put(int index, Collection value) throws JSONException {
this.put(index, new JSONArray(value));
return this;
} |
f61b6c41-0e3a-4407-a03e-4fc8f0570fd6 | public JSONArray put(int index, double value) throws JSONException {
this.put(index, new Double(value));
return this;
} |
ca23c008-4a71-4aca-a95c-bc3aaee1d913 | public JSONArray put(int index, int value) throws JSONException {
this.put(index, new Integer(value));
return this;
} |
c18ef24e-563e-4b75-9d86-4e4478634abe | public JSONArray put(int index, long value) throws JSONException {
this.put(index, new Long(value));
return this;
} |
41223875-0639-45c3-90db-be11eaf4cf47 | public JSONArray put(int index, Map value) throws JSONException {
this.put(index, new JSONObject(value));
return this;
} |
c0360233-deee-4544-b73e-40c7ddb1a7fe | public JSONArray put(int index, Object value) throws JSONException {
JSONObject.testValidity(value);
if (index < 0) {
throw new JSONException("JSONArray[" + index + "] not found.");
}
if (index < this.length()) {
this.myArrayList.set(index, value);
} else ... |
eb8fa82f-77fb-4330-ac77-3a69560c3815 | public Object remove(int index) {
Object o = this.opt(index);
this.myArrayList.remove(index);
return o;
} |
3640f70b-c0fd-4b9d-9908-9eb95f6055e4 | public JSONObject toJSONObject(JSONArray names) throws JSONException {
if (names == null || names.length() == 0 || this.length() == 0) {
return null;
}
JSONObject jo = new JSONObject();
for (int i = 0; i < names.length(); i += 1) {
jo.put(names.getString(i), this.... |
74d3ce00-ac5c-4b5e-ae45-6f022dfee67c | public String toString() {
try {
return this.toString(0);
} catch (Exception e) {
return null;
}
} |
a1bb83b3-88a8-42e3-800b-f7a13f1ef9fa | public String toString(int indentFactor) throws JSONException {
StringWriter sw = new StringWriter();
synchronized (sw.getBuffer()) {
return this.write(sw, indentFactor, 0).toString();
}
} |
bdaf0e1a-3c63-4c66-b3e0-9732f6bb331f | public Writer write(Writer writer) throws JSONException {
return this.write(writer, 0, 0);
} |
1939a13e-8d06-40e3-99da-664ace171320 | Writer write(Writer writer, int indentFactor, int indent)
throws JSONException {
try {
boolean commanate = false;
int length = this.length();
writer.write('[');
if (length == 1) {
JSONObject.writeValue(writer, this.myArrayList.get(0),
... |
cb704a8c-7660-4d52-b48e-aec6ff72afa8 | public String toJSONString(); |
69b2ff64-fb7c-47f2-af4a-90ffb0d72172 | public JSONException(String message) {
super(message);
} |
9343d980-eec3-4a87-83a3-6d59f0c0cf86 | public JSONException(Throwable cause) {
super(cause.getMessage());
this.cause = cause;
} |
c351ddd3-1643-46ec-b27b-8e1af600bd33 | public Throwable getCause() {
return this.cause;
} |
a74dcfba-bb64-4a45-98aa-f3cf3d829922 | protected final Object clone() {
return this;
} |
0ba74c93-8e10-45fc-b094-c059f16ebcc7 | public boolean equals(Object object) {
return object == null || object == this;
} |
2edbe270-4ba1-458f-af2a-febee6d2a806 | public String toString() {
return "null";
} |
ae4a8e79-a7b9-47e2-8923-48ed870c9772 | public JSONObject() {
this.map = new HashMap();
} |
8fc74cb0-aa12-48af-b44b-6c36bbb71d83 | public JSONObject(JSONObject jo, String[] names) {
this();
for (int i = 0; i < names.length; i += 1) {
try {
this.putOnce(names[i], jo.opt(names[i]));
} catch (Exception ignore) {
}
}
} |
5b51e2fc-3961-487b-9aa6-a0c9ddba2cd7 | public JSONObject(JSONTokener x) throws JSONException {
this();
char c;
String key;
if (x.nextClean() != '{') {
throw x.syntaxError("A JSONObject text must begin with '{'");
}
for (;;) {
c = x.nextClean();
switch (c) {
case... |
703a23e2-c7be-43eb-bd08-a1e974cdfd55 | public JSONObject(Map map) {
this.map = new HashMap();
if (map != null) {
Iterator i = map.entrySet().iterator();
while (i.hasNext()) {
Map.Entry e = (Map.Entry)i.next();
Object value = e.getValue();
if (value != null) {
... |
3fa0d811-3d3e-42f9-9d01-3d590f483f23 | public JSONObject(Object bean) {
this();
this.populateMap(bean);
} |
3ae1bb2b-2e5c-4db3-8945-6ca6a140112a | public JSONObject(Object object, String names[]) {
this();
Class c = object.getClass();
for (int i = 0; i < names.length; i += 1) {
String name = names[i];
try {
this.putOpt(name, c.getField(name).get(object));
} catch (Exception ignore) {
... |
459f40e3-8bb0-4364-8025-0991a50f94b9 | public JSONObject(String source) throws JSONException {
this(new JSONTokener(source));
} |
bee9b4a3-b042-41ec-88c4-48c9253bbb80 | public JSONObject(String baseName, Locale locale) throws JSONException {
this();
ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale,
Thread.currentThread().getContextClassLoader());
// Iterate through the keys in the bundle.
Enumeration keys = bundle.getKeys();
... |
d5e43057-10a6-47e4-874f-757f5cebefe0 | public JSONObject accumulate(
String key,
Object value
) throws JSONException {
testValidity(value);
Object object = this.opt(key);
if (object == null) {
this.put(key, value instanceof JSONArray
? new JSONArray().put(value)
... |
c36c1674-2e99-435c-8136-b3a628a5c025 | public JSONObject append(String key, Object value) throws JSONException {
testValidity(value);
Object object = this.opt(key);
if (object == null) {
this.put(key, new JSONArray().put(value));
} else if (object instanceof JSONArray) {
this.put(key, ((JSONArray)objec... |
8d4c0fa2-9c44-4083-8456-537326f48670 | public static String doubleToString(double d) {
if (Double.isInfinite(d) || Double.isNaN(d)) {
return "null";
}
// Shave off trailing zeros and decimal point, if possible.
String string = Double.toString(d);
if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
... |
8bd06d64-615c-497a-a51f-0d92ddae08e8 | public Object get(String key) throws JSONException {
if (key == null) {
throw new JSONException("Null key.");
}
Object object = this.opt(key);
if (object == null) {
throw new JSONException("JSONObject[" + quote(key) +
"] not found.");
}... |
53d71034-45eb-4255-bb1e-5238ba10ee37 | public boolean getBoolean(String key) throws JSONException {
Object object = this.get(key);
if (object.equals(Boolean.FALSE) ||
(object instanceof String &&
((String)object).equalsIgnoreCase("false"))) {
return false;
} else if (object.equals(Boolean.T... |
323a71d5-5fc5-458e-818d-8ffc87528508 | public double getDouble(String key) throws JSONException {
Object object = this.get(key);
try {
return object instanceof Number
? ((Number)object).doubleValue()
: Double.parseDouble((String)object);
} catch (Exception e) {
throw new JSONExc... |
f1e09e4b-9963-4ad8-8a72-e3a2dac0ea8a | public int getInt(String key) throws JSONException {
Object object = this.get(key);
try {
return object instanceof Number
? ((Number)object).intValue()
: Integer.parseInt((String)object);
} catch (Exception e) {
throw new JSONException("JSO... |
0fc0a76e-b09e-42a7-bbaf-5d8d8eda3224 | public JSONArray getJSONArray(String key) throws JSONException {
Object object = this.get(key);
if (object instanceof JSONArray) {
return (JSONArray)object;
}
throw new JSONException("JSONObject[" + quote(key) +
"] is not a JSONArray.");
} |
6723ce1d-94c2-472e-a1ca-7e2e7f691b22 | public JSONObject getJSONObject(String key) throws JSONException {
Object object = this.get(key);
if (object instanceof JSONObject) {
return (JSONObject)object;
}
throw new JSONException("JSONObject[" + quote(key) +
"] is not a JSONObject.");
} |
eeb062ed-0b2e-4874-b1f3-befedd885e6e | public long getLong(String key) throws JSONException {
Object object = this.get(key);
try {
return object instanceof Number
? ((Number)object).longValue()
: Long.parseLong((String)object);
} catch (Exception e) {
throw new JSONException("JS... |
7c7f9770-18ab-44cd-ac43-51efc8420b79 | public static String[] getNames(JSONObject jo) {
int length = jo.length();
if (length == 0) {
return null;
}
Iterator iterator = jo.keys();
String[] names = new String[length];
int i = 0;
while (iterator.hasNext()) {
names[i] = (String)iter... |
e1859db7-f283-42ac-81c8-1a9e20eacdc1 | public static String[] getNames(Object object) {
if (object == null) {
return null;
}
Class klass = object.getClass();
Field[] fields = klass.getFields();
int length = fields.length;
if (length == 0) {
return null;
}
String[] names ... |
d88e52b1-f7d4-4fc2-94bc-649892feeb99 | public String getString(String key) throws JSONException {
Object object = this.get(key);
if (object instanceof String) {
return (String)object;
}
throw new JSONException("JSONObject[" + quote(key) +
"] not a string.");
} |
b4f77a8c-6bb0-49b2-8f7d-73e47ce49ebe | public boolean has(String key) {
return this.map.containsKey(key);
} |
b6d9df2e-f353-41db-82be-df0f23b06f46 | public JSONObject increment(String key) throws JSONException {
Object value = this.opt(key);
if (value == null) {
this.put(key, 1);
} else if (value instanceof Integer) {
this.put(key, ((Integer)value).intValue() + 1);
} else if (value instanceof Long) {
... |
48b8d934-4f99-43ee-ada6-cc4938675c52 | public boolean isNull(String key) {
return JSONObject.NULL.equals(this.opt(key));
} |
69eaf96f-0856-45f0-938d-0b605cfb01b1 | public Iterator keys() {
return this.keySet().iterator();
} |
c96c6709-428a-4c26-9cef-69318134b081 | public Set keySet() {
return this.map.keySet();
} |
6c7e97a6-59da-4e37-a005-088d347a21d7 | public int length() {
return this.map.size();
} |
649931bd-6291-4b6f-b875-d1eff09fd244 | public JSONArray names() {
JSONArray ja = new JSONArray();
Iterator keys = this.keys();
while (keys.hasNext()) {
ja.put(keys.next());
}
return ja.length() == 0 ? null : ja;
} |
d321cc22-9270-41b5-a149-98d40243ec65 | public static String numberToString(Number number)
throws JSONException {
if (number == null) {
throw new JSONException("Null pointer");
}
testValidity(number);
// Shave off trailing zeros and decimal point, if possible.
String string = number.toString();
... |
211a82c2-ac3b-436e-8021-4678aa1c6b7d | public Object opt(String key) {
return key == null ? null : this.map.get(key);
} |
f1b7f81d-cd5a-469e-8d2a-c0e0c7f1f2e6 | public boolean optBoolean(String key) {
return this.optBoolean(key, false);
} |
93abc96c-8785-46d0-9778-e9480a318c33 | public boolean optBoolean(String key, boolean defaultValue) {
try {
return this.getBoolean(key);
} catch (Exception e) {
return defaultValue;
}
} |
85752b22-cbee-40c8-9a05-2e4d407975a3 | public double optDouble(String key) {
return this.optDouble(key, Double.NaN);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.