public static ResourceHandle newHandle(HandleType type, String resource) { return new ResourceHandle(type, resource); }
private static ResourceHandle buildHandleFromString(String name) { String[] values = name.split("!"); return ResourceHandle.newHandle(values[0], values[1]); }
public static <C> Class<? extends C> loadFromClassOrInherit(ResourceHandle resource, Class<C> ifaceClass, Map<String, Object> tuples) throws Exception { if (resource.getType() == HandleType.CLASS) { return Class.forName(resource.resource).asSubclass(ifaceClass); } else { if (resource.getType() == HandleType.INHERIT) { AnyObject yaml = ConfigurationLoader.load(resource.resource); return getFromClassOrInherit(yaml, ifaceClass, tuples); } else { throw new IllegalArgumentException( "Illegal experiment descriptor, must contain one node of type <class> or <inherit>"); } } }
public static ResourceHandle buildHandleFromMap(Map<String, String> map) { Map.Entry<String, String> name = Iterators.get(map.entrySet().iterator(), 0); return ResourceHandle.newHandle(name.getKey(), name.getValue()); }
public static ResourceHandle newInheritHandle(String resource) { return new ResourceHandle(HandleType.INHERIT, resource); }
public static ResourceHandle buildHandleFromObject(AnyObject object) { AnyTuple name = Iterables.get(object.getTuples(), 0); return ResourceHandle.newHandle(name.getKey(), (String) name.getObject()); }
public static ResourceHandle newHandle(String type, String resource) { try { return new ResourceHandle(HandleType.valueOf(type.toUpperCase()), resource); } catch (Exception e) { throw new IllegalArgumentException( "Illegal experiment descriptor, must contain one node of type <class> or <inherit>"); } }
@SuppressWarnings("unchecked") void loadOption(Map<String, Object> description, List<AnalysisEngineDescription> aes) { try { Map.Entry<String, Object> first = getFirst(description); HandleType type = HandleType.getInstance(first.getKey()); if (type == HandleType.PIPELINE) { List<Map<String, Object>> pipeline = (List<Map<String, Object>>) first.getValue(); List<AnalysisEngineDescription> options = createInnerPipeline(pipeline); aes.addAll(options); } else { String resource = (String) first.getValue(); List<AnalysisEngineDescription> options = doLoadOptions(ResourceHandle.newHandle(type, resource), description); aes.addAll(options); } } catch (Exception e) { System.err.printf("Unable to load option %s caused by:\n", description); Throwable cause = e.getCause(); if (cause != null) { cause.printStackTrace(); } else { e.printStackTrace(); } } }
if (o instanceof String) { String component = ((String) o).trim(); ResourceHandle handle = ResourceHandle.newHandle(type, component); Set<AnalysisEngineDescription> local = Sets.newLinkedHashSet(doLoadOptions(handle)); sets.add(local);