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); } }
switch (attributeType) { case _ID_TYPE: field = new IDField(fieldValue); break; case STRING: field = new StringField(fieldValue); break; case INTEGER: field = new IntegerField(Integer.parseInt(fieldValue)); break; case DOUBLE: field = new DoubleField(Double.parseDouble(fieldValue)); break; case DATE: field = new DateField(fieldValue); break; case DATETIME: field = new DateTimeField(fieldValue); break; case TEXT: field = new TextField(fieldValue); break; case LIST: field = new ListField<String>(Arrays.asList(fieldValue)); break;
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 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(); } } }
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); }
private Tuple computeNextMatchingTuple() throws TexeraException { if (sortedWordCountMap == null) { computeWordCount(); } if (wordCountIterator.hasNext()) { Entry<String, Integer> entry = wordCountIterator.next(); List<IField> tupleFieldList = new ArrayList<>(); // Generate the new UUID. tupleFieldList.add(IDField.newRandomID()); tupleFieldList.add(new StringField(entry.getKey())); tupleFieldList.add(new IntegerField(entry.getValue())); cursor++; return new Tuple(SCHEMA_WORD_COUNT, tupleFieldList); } return null; }
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; } }
private Tuple popupOneTuple() { Tuple outputTuple = tupleBuffer.get(0); tupleBuffer.remove(0); if (tupleBuffer.isEmpty()) { tupleBuffer = null; } List<IField> outputFields = new ArrayList<>(); outputFields.addAll(outputTuple.getFields()); Integer className = idClassMap.get(outputTuple.getField(SchemaConstants._ID).getValue().toString()); outputFields.add(new IntegerField( className )); return new Tuple(outputSchema, outputFields); }
@Test public void testTupleWithSpanlist() { Tuple tuple = new Tuple.Builder() .add("attr1", AttributeType.TEXT, new TextField("test")) .add("spanList", AttributeType.LIST, new ListField<Span>(Arrays.asList( new Span("attr1", 0, 4, "test", "test")))) .build(); TestUtils.testJsonSerialization(tuple); }
/** * Generates a new IDField with a random UUID. * * @return */ public static IDField newRandomID() { return new IDField(UUID.randomUUID().toString()); }
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); }
private static Tuple getTextTuple(String content) { IField field = new TextField(content); Tuple tuple = new Tuple(SCHEMA_TEXT, field); return tuple; }
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); }
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> getOneToManyTestTuple() throws ParseException { IField[] fields1 = { new TextField(sentence1 + sentence2) }; Tuple tuple1 = new Tuple(SPLIT_SCHEMA, 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); }