Java Code Examples for org.apache.uima.jcas.cas.StringArray#size()
The following examples show how to use
org.apache.uima.jcas.cas.StringArray#size() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MongoEvents.java From baleen with Apache License 2.0 | 5 votes |
private List<Document> getEntityDocuments(Event e) { List<Document> entityDocuments = new ArrayList<>(); StringArray arguments = e.getArguments(); for (int i = 0; i < e.getEntities().size(); i++) { Entity entity = e.getEntities(i); // @formatter:off Document entityDocument = new Document() .append("entityId", entity.getExternalId()) .append(FIELD_TYPE, entity.getType().getShortName()) .append(FIELD_SUBTYPE, entity.getSubType()) .append(FIELD_VALUE, entity.getValue()) .append(FIELD_BEGIN, entity.getBegin()) .append(FIELD_END, entity.getEnd()); // @formatter:on Document fullEntityDocument = new Document().append(FIELD_ENTITY, entityDocument); if (arguments != null && i < arguments.size()) { fullEntityDocument.append(FIELD_ARGUMENT, arguments.get(i)); } else { fullEntityDocument.append(FIELD_ARGUMENT, ""); } entityDocuments.add(fullEntityDocument); } return entityDocuments; }
Example 2
Source File: BlueCasUtil.java From bluima with Apache License 2.0 | 5 votes |
public static List<String> toList(StringArray tokens) { List<String> l = new ArrayList<String>(tokens.size()); for (int i = 0; i < tokens.size(); i++) { l.add(tokens.get(i)); } return l; }
Example 3
Source File: StructuralHtml.java From baleen with Apache License 2.0 | 4 votes |
/** * Create a CSS style string for the style annotation * * @param s the style * @return the string */ private String buildCssStyle(final Style s) { final String color = s.getColor(); final StringArray decorations = s.getDecoration(); final String font = s.getFont(); // If no style info stop if (Strings.isNullOrEmpty(color) && Strings.isNullOrEmpty(font) && (decorations == null || decorations.size() == 0)) { return null; } final StringBuilder sb = new StringBuilder(); // This is very naive, it a passthrough of the original formats values // Effectively we are just hoping the browser knows what to do. if (!Strings.isNullOrEmpty(color)) { sb.append(String.format("color:%s; ", color)); } if (!Strings.isNullOrEmpty(font)) { sb.append(String.format("font-family:\"%s\"; ", color)); } if (decorations != null && decorations.size() > 0) { final String[] array = decorations.toArray(); for (final String a : array) { switch (a.toUpperCase()) { case "UNDERLINE": sb.append("text-decoration:underline; "); break; case "BOLD": sb.append("font-weight:bold; "); break; case "ITALIC": case "ITALICS": sb.append("font-style:italic; "); break; case "STRIKE": case "STRIKETHROUGH": sb.append("text-decoration: line-through; "); break; case "SUPERSCRIPT": sb.append("font-size: .7em; vertical-align: super; "); break; case "SUBSCRIPT": sb.append("font-size: .7em; vertical-align: sub; "); break; case "BIG": sb.append("font-size: 1.2em; "); break; case "SMALL": sb.append("font-size: .9em; "); break; case "highlighted": sb.append("background-color:#ffffe0; "); break; default: // No nothing - we don't know what it means break; } } } return sb.toString(); }
Example 4
Source File: CasCompare.java From uima-uimaj with Apache License 2.0 | 3 votes |
/** * This is an optional pre-compare operation. * * Somtimes, when comparing StringArrays, the order of the elements is not significant, * and the compare should be done ignoring order differences. * * This is accomplished by sorting the elements, before the compare is done, * using this method. * * Use this routine to accomplish the sort, on particular StringArrays you designate. * Call it for each one you want to sort. * * The sorting is done in a clone of the array, and the original array is not updated. * Instead, a Runnable is returned, which may be invoked later to update the original array with the sorted copy. * This allows sorting to be done while keeping the original values until a later time * * @param stringArray the array to be sorted * @return null or a runnable, which (when invoked) updates the original array with the sorted result. * callers should insure the runnable is garbage collected after use */ public Runnable sortStringArray(StringArray stringArray) { if (stringArray == null || stringArray.size() < 2) { return null; } String[] a = stringArray._getTheArray().clone(); inSortContext = true; Arrays.sort(a); return () -> System.arraycopy(a, 0, stringArray._getTheArray(), 0, stringArray.size()); }