@Override public Tuple getNextTuple() throws TexeraException { if (cursor == CLOSED) { throw new DataflowException(ErrorMessages.OPERATOR_NOT_OPENED); } if (cursor < resultJsonArray.length()) { Tuple tuple = new Tuple(ATERIX_SOURCE_SCHEMA, IDField.newRandomID(), new TextField(resultJsonArray.getJSONObject(cursor).get("ds").toString())); cursor ++; return tuple; } return null; }
private int compare(IField a, IField b, AttributeType attrType) { int retVal = 0; switch (attrType) { case INTEGER: retVal = ((IntegerField) a).getValue().compareTo(((IntegerField) b).getValue()); break; case DOUBLE: retVal = ((DoubleField) a).getValue().compareTo(((DoubleField) b).getValue()); break; case TEXT: retVal = ((TextField) a).getValue().compareTo(((TextField) b).getValue()); break; case STRING: retVal = ((StringField) a).getValue().compareTo(((StringField) b).getValue()); break; case DATE: retVal = ((DateField) a).getValue().compareTo(((DateField) b).getValue()); break; case DATETIME: retVal = ((DateTimeField) a).getValue().compareTo(((DateTimeField) b).getValue()); break; } return retVal; }
public static Tuple parsePromedHTML(String fileName, String content) { try { Document parsedDocument = Jsoup.parse(content); String mainText = parsedDocument.getElementById("preview").text(); Tuple tuple = new Tuple(PromedSchema.PROMED_SCHEMA, new StringField(fileName), new TextField(mainText)); return tuple; } catch (Exception e) { return null; } }
public static List<Tuple> getTwoSentenceTestTuple() { IField[] fields1 = { new TextField("Microsoft, Google and Facebook are organizations."), new TextField("Donald Trump and Barack Obama are persons") }; IField[] fields2 = { new TextField("I made an appointment at 8 am."), new TextField("Aug 16, 2016 is a really important date.")}; IField[] fields3 = { new TextField("I really love Kelly Clarkson's Because of You."), new TextField("Shirley Temple is a very famous actress.")}; Tuple tuple1 = new Tuple(SCHEMA_TWO_SENTENCE, fields1); Tuple tuple2 = new Tuple(SCHEMA_TWO_SENTENCE, fields2); Tuple tuple3 = new Tuple(SCHEMA_TWO_SENTENCE, fields3); return Arrays.asList(tuple1, tuple2, tuple3); }
public static List<Tuple> getTest4Tuple() throws ParseException { IField[] fields1 = { new TextField("Microsoft, Google and Facebook are organizations."), new TextField("Donald Trump and Barack Obama are persons") }; Tuple tuple1 = new Tuple(SCHEMA_TWO_SENTENCE, fields1); return Arrays.asList(tuple1); }
public static List<Tuple> getTest1Tuple() throws ParseException { IField[] fields1 = { new TextField("Microsoft is an organization.") }; Tuple tuple1 = new Tuple(SCHEMA_ONE_SENTENCE, fields1); return Arrays.asList(tuple1); }
public static List<Tuple> getTest7Tuple() throws ParseException { IField[] fields1 = { new TextField( "Feeling the warm sun rays beaming steadily down, the girl decided there was no need to wear a coat.") }; Tuple tuple1 = new Tuple(SCHEMA_ONE_SENTENCE, fields1); return Arrays.asList(tuple1); }
public static List<Tuple> getTest2Tuple() throws ParseException { IField[] fields1 = { new TextField("Microsoft, Google and Facebook are organizations.") }; Tuple tuple1 = new Tuple(SCHEMA_ONE_SENTENCE, fields1); return Arrays.asList(tuple1); }
public static List<Tuple> getOneToOneTestTuple() throws ParseException { IField[] fields1 = { new TextField(sentence1 + sentence2) }; Tuple tuple1 = new Tuple(SPLIT_SCHEMA, fields1); return Arrays.asList(tuple1); }
private static Tuple getTextTuple(String content) { IField field = new TextField(content); Tuple tuple = new Tuple(SCHEMA_TEXT, field); return tuple; }
public static List<Tuple> getOneToManyTestTuple() throws ParseException { IField[] fields1 = { new TextField(sentence1 + sentence2) }; Tuple tuple1 = new Tuple(SPLIT_SCHEMA, fields1); return Arrays.asList(tuple1); }
public static List<Tuple> getTest3Tuple() throws ParseException { IField[] fields1 = { new TextField( "Microsoft, Google and Facebook are organizations and Donald Trump and Barack Obama are persons.") }; Tuple tuple1 = new Tuple(SCHEMA_ONE_SENTENCE, fields1); return Arrays.asList(tuple1); }
public static List<Tuple> getTest8Tuple() { IField[] fields1 = { new TextField("This backpack costs me 300 dollars.")}; Tuple tuple1 = new Tuple(SCHEMA_ONE_SENTENCE, fields1); return Arrays.asList(tuple1); }
content = FileExtractorUtils.extractPlainTextFile(path); Tuple tuple = new Tuple(outputSchema, IDField.newRandomID(), new TextField(content)); cursor++; return tuple;
public static List<Tuple> getOneSentenceTestTuple() { IField[] fields1 = { new TextField("Microsoft is an organization.") }; IField[] fields2 = { new TextField("Microsoft, Google and Facebook are organizations.") }; IField[] fields3 = { new TextField( "Microsoft, Google and Facebook are organizations and Donald Trump and Barack Obama are persons.") }; IField[] fields4 = { new TextField( "Feeling the warm sun rays beaming steadily down, the girl decided there was no need to wear a coat.") }; IField[] fields5 = { new TextField("This backpack costs me 300 dollars.")}; IField[] fields6 = { new TextField("What't the brand, Samsung or Apple?")}; Tuple tuple1 = new Tuple(SCHEMA_ONE_SENTENCE, fields1); Tuple tuple2 = new Tuple(SCHEMA_ONE_SENTENCE, fields2); Tuple tuple3 = new Tuple(SCHEMA_ONE_SENTENCE, fields3); Tuple tuple4 = new Tuple(SCHEMA_ONE_SENTENCE, fields4); Tuple tuple5 = new Tuple(SCHEMA_ONE_SENTENCE, fields5); Tuple tuple6 = new Tuple(SCHEMA_ONE_SENTENCE, fields6); return Arrays.asList(tuple1, tuple2, tuple3, tuple4, tuple5, tuple6); }
public static List<Tuple> getSamplePeopleTuples() { try { IField[] fields1 = { new StringField("无忌"), new StringField("长孙"), new IntegerField(46), new DoubleField(5.50), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-14-1970")), new TextField("北京大学电气工程学院") }; IField[] fields2 = { new StringField("孔明"), new StringField("洛克贝尔"), new IntegerField(42), new DoubleField(5.99), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1974")), new TextField("北京大学计算机学院") }; IField[] fields3 = { new StringField("宋江"), new StringField("建筑"), new IntegerField(42), new DoubleField(5.99), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1974")), new TextField("伟大的建筑是历史的坐标,具有传承的价值。") }; Tuple tuple1 = new Tuple(SCHEMA_PEOPLE, fields1); Tuple tuple2 = new Tuple(SCHEMA_PEOPLE, fields2); Tuple tuple3 = new Tuple(SCHEMA_PEOPLE, fields3); return Arrays.asList(tuple1, tuple2, tuple3); } catch (ParseException e) { // exception should not happen because we know the data is correct e.printStackTrace(); return Arrays.asList(); } } }
@Test public void testTextField() { TextField textField = new TextField("text field test"); JsonNode jsonNode = TestUtils.testJsonSerialization(textField); Assert.assertTrue(jsonNode.get(JsonConstants.FIELD_VALUE).isTextual()); }
public static List<Tuple> constructSamplePeopleTuples() { IField[] fields1 = { new StringField("bruce"), new StringField("john Lee"), new IntegerField(46), new DoubleField(5.50), new DateTimeField(LocalDateTime.parse("1970-01-01T11:11:11")), new TextField("banana") }; IField[] fields2 = { new StringField("tom hanks"), new StringField("cruise"), new IntegerField(45), new DoubleField(5.95), new DateTimeField(LocalDateTime.parse("1980-01-02T13:14:15")), new TextField("mississippi") }; Tuple tuple1 = new Tuple(SCHEMA_PEOPLE, fields1); Tuple tuple2 = new Tuple(SCHEMA_PEOPLE, fields2); return Arrays.asList(tuple1, tuple2); } }
IField[] fields0 = { new StringField("bruce"), new StringField("john Lee"), new IntegerField(46), new DoubleField(5.50), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-14-1970")), new TextField("Tall Angry") }; IField[] fields1 = { new StringField("tom hanks"), new StringField("cruise"), new IntegerField(45), new DoubleField(5.95), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1971")), new TextField("Short Brown") }; IField[] fields2 = { new StringField("brad lie angelina"), new StringField("pitt"), new IntegerField(44), new DoubleField(6.10), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-12-1972")), new TextField("White Angry") }; IField[] fields3 = { new StringField("george lin lin"), new StringField("lin clooney"), new IntegerField(43), new DoubleField(6.06), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1973")), new TextField("Lin Clooney is Short and lin clooney is Angry") }; IField[] fields4 = { new StringField("christian john wayne"), new StringField("rock bale"), new IntegerField(42), new DoubleField(5.99), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1974")), new TextField("Tall Fair") }; IField[] fields5 = { new StringField("Mary brown"), new StringField("Lake Forest"), new IntegerField(42), new DoubleField(5.99), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1974")), new TextField("Short angry") };