use of json.JSONObject in project JsonPath by jayway.
the class TapestryJsonProviderTest method an_object_can_be_read.
@Test
public void an_object_can_be_read() {
JSONObject book = using(TAPESTRY_JSON_CONFIGURATION).parse(JSON_DOCUMENT).read("$.store.book[0]");
assertThat(book.get("author").toString()).isEqualTo("Nigel Rees");
}
use of json.JSONObject in project IR_Base by Linda-sunshine.
the class ParentChildAnalyzer method LoadDoc.
public void LoadDoc(String fileName) {
if (fileName == null || fileName.isEmpty())
return;
JSONObject json = LoadJSON(fileName);
String content = Utils.getJSONValue(json, "content");
String name = Utils.getJSONValue(json, "name");
String parent = Utils.getJSONValue(json, "parent");
_Doc d = new _Doc(m_corpus.getSize(), content, 0);
d.setName(name);
AnalyzeDoc(d);
}
use of json.JSONObject in project IR_Base by Linda-sunshine.
the class ParentChildAnalyzer method loadChildDoc.
public void loadChildDoc(String fileName) {
if (fileName == null || fileName.isEmpty())
return;
JSONObject json = LoadJSON(fileName);
String content = Utils.getJSONValue(json, "content");
String name = Utils.getJSONValue(json, "name");
String parent = Utils.getJSONValue(json, "parent");
String title = Utils.getJSONValue(json, "title");
//
// _ChildDoc4BaseWithPhi d = new _ChildDoc4BaseWithPhi(m_corpus.getSize(),
// name, "", content, 0);
// _ChildDoc4BaseWithPhi_Hard d = new _ChildDoc4BaseWithPhi_Hard(m_corpus.getSize(), name, "", content, 0) ;
// _ChildDoc4ChildPhi d = new _ChildDoc4ChildPhi(m_corpus.getSize(),
// name,
// "", content, 0);
// _ChildDoc4TwoPhi d = new _ChildDoc4TwoPhi(m_corpus.getSize(), name, "", content, 0);
// _ChildDoc4ThreePhi d = new _ChildDoc4ThreePhi(m_corpus.getSize(), name,
// "", content, 0);
// _ChildDoc4OneTopicProportion d = new _ChildDoc4OneTopicProportion(m_corpus.getSize(), name, "", content, 0);
_ChildDoc d = new _ChildDoc(m_corpus.getSize(), name, "", content, 0);
if (parentHashMap.containsKey(parent)) {
if (AnalyzeDoc(d)) {
// this is a valid child document
// if (parentHashMap.containsKey(parent)) {
_ParentDoc pDoc = parentHashMap.get(parent);
d.setParentDoc(pDoc);
pDoc.addChildDoc(d);
} else {
// System.err.format("filtering comments %s!\n", parent);
}
} else {
// System.err.format("[Warning]Missing parent document %s!\n", parent);
}
}
use of json.JSONObject in project tapestry5-hotel-booking by ccordenier.
the class AjaxLoader method initAjaxLoader.
@BeginRender
void initAjaxLoader(MarkupWriter writer) {
loader = javascriptSupport.allocateClientId("loader");
JSONObject data = new JSONObject();
data.put("zone", zone);
data.put("trigger", trigger);
data.put("loader", loader);
javascriptSupport.addInitializerCall(InitializationPriority.NORMAL, "initAjaxLoader", data);
}
use of json.JSONObject in project IR_Base by Linda-sunshine.
the class DocAnalyzer method LoadJsonDoc.
// Load a document and analyze it.
protected void LoadJsonDoc(String filename) {
_Product prod = null;
JSONArray jarray = null;
try {
JSONObject json = LoadJSON(filename);
prod = new _Product(json.getJSONObject("ProductInfo"));
jarray = json.getJSONArray("Reviews");
} catch (Exception e) {
// fail to parse a json document
System.err.print('X');
return;
}
for (int i = 0; i < jarray.length(); i++) {
try {
_Post post = new _Post(jarray.getJSONObject(i));
if (post.isValid(m_dateFormatter)) {
long timeStamp = m_dateFormatter.parse(post.getDate()).getTime();
String content;
// append document title into document content
if (Utils.endWithPunct(post.getTitle()))
content = post.getTitle() + " " + post.getContent();
else
content = post.getTitle() + ". " + post.getContent();
// int ID, String name, String prodID, String title, String source, int ylabel, long timeStamp
_Doc review = new _Doc(m_corpus.getSize(), post.getID(), prod.getID(), post.getTitle(), content, post.getLabel() - 1, timeStamp);
if (this.m_stnDetector != null)
AnalyzeDocWithStnSplit(review);
else
AnalyzeDoc(review);
}
} catch (ParseException e) {
System.out.print('T');
} catch (JSONException e) {
System.out.print('P');
}
}
}
Aggregations