code
stringlengths
73
34.1k
label
stringclasses
1 value
public static MethodNode findMethod(Collection<MethodNode> methodNodes, boolean isStatic, Type returnType, String name, Type ... paramTypes) { Validate.notNull(methodNodes); Validate.notNull(returnType); Validate.notNull(name); Validate.notNull(paramTypes); Validate.n...
java
public static List<AbstractInsnNode> findInvocationsOf(InsnList insnList, Method expectedMethod) { Validate.notNull(insnList); Validate.notNull(expectedMethod); List<AbstractInsnNode> ret = new ArrayList<>(); Type expectedMethodDesc = Type.getType(expectedMethod); Type ...
java
public static List<AbstractInsnNode> findInvocationsWithParameter(InsnList insnList, Type expectedParamType) { Validate.notNull(insnList); Validate.notNull(expectedParamType); Validate.isTrue(expectedParamType.getSort() != Type.METHOD && expectedParamType.getSort() != Type.VOID); ...
java
public static List<AbstractInsnNode> searchForOpcodes(InsnList insnList, int ... opcodes) { Validate.notNull(insnList); Validate.notNull(opcodes); Validate.isTrue(opcodes.length > 0); List<AbstractInsnNode> ret = new LinkedList<>(); Set<Integer> opcodeSet = new ...
java
public static LineNumberNode findLineNumberForInstruction(InsnList insnList, AbstractInsnNode insnNode) { Validate.notNull(insnList); Validate.notNull(insnNode); int idx = insnList.indexOf(insnNode); Validate.isTrue(idx != -1); // Get index of labels and insnNod...
java
public static LocalVariableNode findLocalVariableNodeForInstruction(List<LocalVariableNode> lvnList, InsnList insnList, final AbstractInsnNode insnNode, int idx) { Validate.notNull(insnList); Validate.notNull(insnNode); Validate.isTrue(idx >= 0); int insnIdx = insnLi...
java
public static FieldNode findField(ClassNode classNode, String name) { Validate.notNull(classNode); Validate.notNull(name); Validate.notEmpty(name); return classNode.fields.stream() .filter(x -> name.equals(x.name)) .findAny().orElse(null); }
java
public static void validateXMLSchema(String xsdPath, String xmlPath) throws IOException, SAXException { InputStream xsdStream = null; InputStream xmlStream = null; try { xsdStream = XmlUtils.class.getResourceAsStream(xsdPath); //try loading from classpath first - fallback to disk if (xsdStream == null...
java
public static void validateXMLSchema(InputStream xsdStream, InputStream xmlStream) throws IOException, SAXException { SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = factory.newSchema(new StreamSource(xsdStream)); Validator validator = schem...
java
public static String getElementQualifiedName(XMLStreamReader xmlReader, Map<String, String> namespaces) { String namespaceUri = null; String localName = null; switch(xmlReader.getEventType()) { case XMLStreamConstants.START_ELEMENT: case XMLStreamConstants.END_ELEMENT: namespaceUri = xmlReader.getNam...
java
public static DateTime fromString(String rfc3339Timestamp) { if (rfc3339Timestamp == null) { return null; } DateTime dateTime = new DateTime(rfc3339Timestamp, DateTimeZone.UTC); return dateTime; }
java
private ServerConfiguration loadConfiguration(ServerConfigurationReader configurationReader) throws ConfigurationException { ServerConfiguration configuration = configurationReader.read(); return configuration; }
java
public Collection<String> getRelatedDetectionSystems(DetectionSystem detectionSystem) { Collection<String> relatedDetectionSystems = new HashSet<String>(); relatedDetectionSystems.add(detectionSystem.getDetectionSystemId()); if(correlationSets != null) { for(CorrelationSet correlationSet : correlationSets) {...
java
private Collection<String> buildTopicNames(Response response) { Collection<String> topicNames = new HashSet<>(); Collection<String> detectionSystemNames = appSensorServer.getConfiguration().getRelatedDetectionSystems(response.getDetectionSystem()); for(String detectionSystemName : detectionSystemNames) { ...
java
@Override public void analyze(Response response) { if (response != null) { logger.info("NO-OP Response for user <" + response.getUser().getUsername() + "> - should be executing response action " + response.getAction()); } }
java
public Collection<Response> findResponses(SearchCriteria criteria, Collection<Response> responses) { if (criteria == null) { throw new IllegalArgumentException("criteria must be non-null"); } Collection<Response> matches = new ArrayList<Response>(); User user = criteria.getUser(); Collection<String> ...
java
private ClientConfiguration loadConfiguration(ClientConfigurationReader configurationReader) throws ConfigurationException { ClientConfiguration configuration = configurationReader.read(); return configuration; }
java
private Collection<String> buildQueueNames(Response response) { Collection<String> queueNames = new HashSet<>(); Collection<String> detectionSystemNames = appSensorServer.getConfiguration().getRelatedDetectionSystems(response.getDetectionSystem()); for(String detectionSystemName : detectionSystemNames) { ...
java
protected String encodeCEFHeader(String text) { String encoded = text; // back-slash encode back-slashes (needs to be first) encoded = encoded.replace("\\","\\\\"); // back-slash encode pipes encoded = encoded.replace("|","\\|"); // strip carriage returns and newlines encoded = encoded.replace("\...
java
protected String encodeCEFExtension(String text) { String encoded = text; // back-slash encode back-slashes (needs to be first) encoded = encoded.replace("\\","\\\\"); // back-slash encode equals signs encoded = encoded.replace("=","\\="); // strip carriage returns and newlines encoded = encoded....
java
@Override public void analyze(Response response) { if(response == null) { return; } if (ResponseHandler.LOG.equals(response.getAction())) { logger.info("Handling <log> response for user <{}>", response.getUser().getUsername()); } else { logger.info("Delegating response for user <{}> to configured r...
java
public long next() { long currentTime = System.currentTimeMillis(); long counter; synchronized(this) { if (currentTime < referenceTime) { throw new RuntimeException(String.format("Last referenceTime %s is after reference time %s", referenceTime, currentTime)); } else if (currentTime >...
java
public void addTimexAnnotation(String timexType, int begin, int end, Sentence sentence, String timexValue, String timexQuant, String timexFreq, String timexMod, String emptyValue, String timexId, String foundByRule, JCas jcas) { Timex3 annotation = new Timex3(jcas); annotation.setBegin(begin); annotation.se...
java
public void specifyAmbiguousValues(JCas jcas) { // build up a list with all found TIMEX expressions List<Timex3> linearDates = new ArrayList<Timex3>(); FSIterator iterTimex = jcas.getAnnotationIndex(Timex3.type).iterator(); // Create List of all Timexes of types "date" and "time" while (iterTimex.hasNext()) ...
java
public boolean checkPosConstraint(Sentence s, String posConstraint, MatchResult m, JCas jcas) { Pattern paConstraint = Pattern.compile("group\\(([0-9]+)\\):(.*?):"); for (MatchResult mr : Toolbox.findMatches(paConstraint,posConstraint)) { int groupNumber = Integer.parseInt(mr.group(1)); int tokenBegin = s.get...
java
private Boolean isValidDCT(JCas jcas) { FSIterator dctIter = jcas.getAnnotationIndex(Dct.type).iterator(); if(!dctIter.hasNext()) { return true; } else { Dct dct = (Dct) dctIter.next(); String dctVal = dct.getValue(); if(dctVal == null) return false; if(dctVal.matches("\\d{8}") // So...
java
void startScanSFeaturesAt(List seq, int pos) { sFeatures.clear(); sFeatureIdx = 0; Observation obsr = (Observation)seq.get(pos); // scan over all context predicates for (int i = 0; i < obsr.cps.length; i++) { Element elem = (Element)dict.dict.get(new Integer(obsr.cps[i])); if (elem == null) { ...
java
Feature nextSFeature() { Feature sF = (Feature)sFeatures.get(sFeatureIdx); sFeatureIdx++; return sF; }
java
Feature nextEFeature() { Feature eF = (Feature)eFeatures.get(eFeatureIdx); eFeatureIdx++; return eF; }
java
public void updateFeatures() { for (int i = 0; i < feaGen.features.size(); i++) { Feature f = (Feature)feaGen.features.get(i); f.wgt = lambda[f.idx]; } }
java
public void initInference() { if (lambda == null) { System.out.println("numFetures: " + feaGen.numFeatures()); lambda = new double[feaGen.numFeatures() + 1]; // reading feature weights from the feature list for (int i = 0; i < feaGen.features.size(); i++) { Feature f = (Feature)feaGen.featu...
java
public void compMult(DoubleVector dv) { for (int i = 0; i < len; i++) { vect[i] *= dv.vect[i]; } }
java
public static int findFirstOf (String container, String chars, int begin){ int minIdx = -1; for (int i = 0; i < chars.length() && i >= 0; ++i){ int idx = container.indexOf(chars.charAt(i), begin); if ( (idx < minIdx && idx != -1) || minIdx == -1){ ...
java
public static int findLastOf (String container, String charSeq, int begin){ //find the last occurrence of one of characters in charSeq from begin backward for (int i = begin; i < container.length() && i >= 0; --i){ if (charSeq.contains("" + container.charAt(i))) return ...
java
public static int findFirstNotOf(String container, String chars, int begin){ //find the first occurrence of characters not in the charSeq from begin forward for (int i = begin; i < container.length() && i >=0; ++i) if (!chars.contains("" + container.charAt(i))) return i; return -1; }
java
public static int findLastNotOf(String container, String charSeq, int end){ for (int i = end; i < container.length() && i >= 0; --i){ if (!charSeq.contains("" + container.charAt(i))) return i; } return -1; }
java
public static boolean containNumber(String str) { for (int i = 0; i < str.length(); i++) { if (Character.isDigit(str.charAt(i))) { return true; } } return false; }
java
public static boolean isAllNumber(String str) { boolean hasNumber = false; for (int i = 0; i < str.length(); i++) { if (!(Character.isDigit(str.charAt(i)) || str.charAt(i) == '.' || str.charAt(i) == ',' || str.charAt(i) == '%' || str.charAt(i) == '$' || str.charAt(i) == '_')) { return fal...
java
public static boolean isFirstCap(String str) { if (isAllCap(str)) return false; if (str.length() > 0 && Character.isLetter(str.charAt(0)) && Character.isUpperCase(str.charAt(0))) { return true; } return false; }
java
public static boolean endsWithPunc(String str) { if (str.endsWith(".") || str.endsWith("?") || str.endsWith("!") || str.endsWith(",") || str.endsWith(":") || str.endsWith("\"") || str.endsWith("'") || str.endsWith("''") || str.endsWith(";")) { return true; } return false; }
java
public static boolean endsWithStop(String str) { if (str.endsWith(".") || str.endsWith("?") || str.endsWith("!")) { return true; } return false; }
java
public static int countStops(String str) { int count = 0; for (int i = 0; i < str.length(); i++) { if (str.charAt(i) == '.' || str.charAt(i) == '?' || str.charAt(i) == '!') { count++; } } return count; }
java
public static int countPuncs(String str) { int count = 0; for (int i = 0; i < str.length(); i++) { if (str.charAt(i) == '.' || str.charAt(i) == '?' || str.charAt(i) == '!' || str.charAt(i) == ',' || str.charAt(i) == ':' || str.charAt(i) == ';') { count++; } } return count; ...
java
public static boolean isStop(String str) { if (str.compareTo(".") == 0) { return true; } if (str.compareTo("?") == 0) { return true; } if (str.compareTo("!") == 0) { return true; } return false; }
java
public static boolean isPunc(String str) { if (str == null) return false; str = str.trim(); for (int i = 0; i < str.length(); ++i){ char c = str.charAt(i); if (Character.isDigit(c) || Character.isLetter(c)){ return false; } } return true; }
java
public static String capitalizeWord( String s ) { // validate if( (s == null) || (s.length() == 0) ) { return s; } return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); }
java
public static String sort( String s ) { char[] chars = s.toCharArray(); Arrays.sort( chars ); return new String( chars ); }
java
public String convert(String text){ String ret = text; if (cpsUni2Uni == null) return ret; Iterator<String> it = cpsUni2Uni.keySet().iterator(); while(it.hasNext()){ String cpsChar = it.next(); ret = ret.replaceAll(cpsChar, cpsUni2Uni.get(cpsChar)); } return ret; }
java
public static void printDetail(Class<?> c, String msg) { if(Logger.printDetails) { String preamble; if(c != null) preamble = "["+c.getSimpleName()+"]"; else preamble = ""; synchronized(System.err) { System.err.println(preamble+" "+msg); } } }
java
public static void printError(Class<?> c, String msg) { String preamble; if(c != null) preamble = "["+c.getSimpleName()+"]"; else preamble = ""; synchronized(System.err) { System.err.println(preamble+" "+msg); } }
java
protected boolean readFeatureParameters(Element node){ try{ NodeList childrent = node.getChildNodes(); cpnames = new Vector<String>(); paras = new Vector<Vector<Integer>>(); for (int i = 0; i < childrent.getLength(); i++) if (childrent.item(i) instanceof Element) { Element child = (El...
java
public static Vector<Element> readFeatureNodes(String templateFile){ Vector<Element> feaTypes = new Vector<Element>(); try { // Read feature template file........ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); In...
java
public void generateTrainData(String inputPath, String outputPath){ try{ File file = new File(inputPath); ArrayList<Sentence> data = new ArrayList<Sentence>(); if (file.isFile()){ System.out.println("Reading " + file.getName()); data = (ArrayList<Sentence>) reader.readFi...
java
public String getContextStr(Sentence sent, int wordIdx){ String cpStr = ""; for (int i = 0; i < cntxGenVector.size(); ++i){ String [] context = cntxGenVector.get(i).getContext(sent, wordIdx); if (context != null){ for (int j = 0; j < context.length; ++j){ if (context[j].trim().equals("")) c...
java
public void writeCpMaps(Dictionary dict, PrintWriter fout) throws IOException { Iterator it = null; if (cpStr2Int == null) { return; } int count = 0; for (it = cpStr2Int.keySet().iterator(); it.hasNext(); ) { String cpStr = (String)it.next(); Integer cpInt = (Integer)cpStr2Int.get(cpStr); ...
java
public void writeLbMaps(PrintWriter fout) throws IOException { if (lbStr2Int == null) { return; } // write the map size fout.println(Integer.toString(lbStr2Int.size())); for (Iterator it = lbStr2Int.keySet().iterator(); it.hasNext(); ) { String lbStr = (String)it.next(); Integer lbInt = (Integer...
java
public void readTstData(String dataFile) { if (tstData != null) { tstData.clear(); } else { tstData = new ArrayList(); } // open data file BufferedReader fin = null; try { fin = new BufferedReader(new InputStreamReader(new FileInputStream(dataFile), "UTF-8")); System.out.println("Read...
java
public void setFilename(String v) { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_filename == null) jcasType.jcas.throwFeatMissing("filename", "de.unihd.dbs.uima.types.heideltime.Event"); jcasType.ll_cas.ll_setStringValue(addr, ((Event_Type)jcasType).casFeatCode_filename, v);}
java
public int getTokId() { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_tokId == null) jcasType.jcas.throwFeatMissing("tokId", "de.unihd.dbs.uima.types.heideltime.Event"); return jcasType.ll_cas.ll_getIntValue(addr, ((Event_Type)jcasType).casFeatCode_tokId);}
java
public void setTokId(int v) { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_tokId == null) jcasType.jcas.throwFeatMissing("tokId", "de.unihd.dbs.uima.types.heideltime.Event"); jcasType.ll_cas.ll_setIntValue(addr, ((Event_Type)jcasType).casFeatCode_tokId, v);}
java
public String getEventId() { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_eventId == null) jcasType.jcas.throwFeatMissing("eventId", "de.unihd.dbs.uima.types.heideltime.Event"); return jcasType.ll_cas.ll_getStringValue(addr, ((Event_Type)jcasType).casFeatCode_eventId);}
java
public void setEventId(String v) { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_eventId == null) jcasType.jcas.throwFeatMissing("eventId", "de.unihd.dbs.uima.types.heideltime.Event"); jcasType.ll_cas.ll_setStringValue(addr, ((Event_Type)jcasType).casFeatCode_eventId, v);}
java
public int getEventInstanceId() { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_eventInstanceId == null) jcasType.jcas.throwFeatMissing("eventInstanceId", "de.unihd.dbs.uima.types.heideltime.Event"); return jcasType.ll_cas.ll_getIntValue(addr, ((Event_Type)jcasType).casFeatCode_eventInstanceI...
java
public void setEventInstanceId(int v) { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_eventInstanceId == null) jcasType.jcas.throwFeatMissing("eventInstanceId", "de.unihd.dbs.uima.types.heideltime.Event"); jcasType.ll_cas.ll_setIntValue(addr, ((Event_Type)jcasType).casFeatCode_eventInstanceId...
java
public String getModality() { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_modality == null) jcasType.jcas.throwFeatMissing("modality", "de.unihd.dbs.uima.types.heideltime.Event"); return jcasType.ll_cas.ll_getStringValue(addr, ((Event_Type)jcasType).casFeatCode_modality);}
java
public void setModality(String v) { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_modality == null) jcasType.jcas.throwFeatMissing("modality", "de.unihd.dbs.uima.types.heideltime.Event"); jcasType.ll_cas.ll_setStringValue(addr, ((Event_Type)jcasType).casFeatCode_modality, v);}
java
public String getTense() { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_tense == null) jcasType.jcas.throwFeatMissing("tense", "de.unihd.dbs.uima.types.heideltime.Event"); return jcasType.ll_cas.ll_getStringValue(addr, ((Event_Type)jcasType).casFeatCode_tense);}
java
public void setTense(String v) { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_tense == null) jcasType.jcas.throwFeatMissing("tense", "de.unihd.dbs.uima.types.heideltime.Event"); jcasType.ll_cas.ll_setStringValue(addr, ((Event_Type)jcasType).casFeatCode_tense, v);}
java
public void setToken(Token v) { if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_token == null) jcasType.jcas.throwFeatMissing("token", "de.unihd.dbs.uima.types.heideltime.Event"); jcasType.ll_cas.ll_setRefValue(addr, ((Event_Type)jcasType).casFeatCode_token, jcasType.ll_cas.ll_getFSRef(v));}
java
public void addTWord(String word, String tag){ TWord tword = new TWord(word, tag); sentence.add(tword); }
java
public void initialize(Language language, String hunpos_path, String hunpos_model_path, Boolean annotateTokens, Boolean annotateSentences, Boolean annotatePOS) { this.initialize(new HunPosTaggerContext(language, hunpos_path, hunpos_model_path, annotateTokens, annotateSentences, annotatePOS)); }
java
public void initialize(UimaContext aContext) { annotate_tokens = (Boolean) aContext.getConfigParameterValue(PARAM_ANNOTATE_TOKENS); annotate_sentences = (Boolean) aContext.getConfigParameterValue(PARAM_ANNOTATE_SENTENCES); annotate_pos = (Boolean) aContext.getConfigParameterValue(PARAM_ANNOTATE_POS); this.langu...
java
public boolean init(String modelDir){ try { classifier = new Classification(modelDir); feaGen = new FeatureGenerator(); classifier.init(); return true; } catch(Exception e){ System.out.println("Error while initilizing classifier: " + e.getMessage()); return fa...
java
public static void main(String args[]){ if (args.length != 4){ displayHelp(); System.exit(1); } try{ JVnSenSegmenter senSegmenter = new JVnSenSegmenter(); senSegmenter.init(args[1]); String option = arg...
java
private static void senSegmentFile(String infile, String outfile, JVnSenSegmenter senSegmenter ){ try{ BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream(infile), "UTF-8")); BufferedWriter out = new BufferedWriter(new OutputStreamWriter( ...
java
public static void loadVietnameseDict(String filename) { try { FileInputStream in = new FileInputStream(filename); if (hsVietnameseDict == null) { hsVietnameseDict = new HashSet(); BufferedReader reader = new BufferedReader( new InputStreamReader(in, "UTF-8")); String line; while (...
java
public static void loadViPersonalNames(String filename) { try { FileInputStream in = new FileInputStream(filename); if (hsViFamilyNames == null) { hsViFamilyNames = new HashSet(); hsViLastNames = new HashSet(); hsViMiddleNames = new HashSet(); BufferedReader reader = new BufferedReade...
java
public static void loadViLocationList(String filename) { try { FileInputStream in = new FileInputStream(filename); if (hsViLocations == null) { hsViLocations = new HashSet(); BufferedReader reader = new BufferedReader( new InputStreamReader(in, "UTF-8")); String line; while ((line ...
java
public String getFilename() { if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_filename == null) jcasType.jcas.throwFeatMissing("filename", "de.unihd.dbs.uima.types.heideltime.Token"); return jcasType.ll_cas.ll_getStringValue(addr, ((Token_Type)jcasType).casFeatCode_filename);}
java
public int getTokenId() { if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_tokenId == null) jcasType.jcas.throwFeatMissing("tokenId", "de.unihd.dbs.uima.types.heideltime.Token"); return jcasType.ll_cas.ll_getIntValue(addr, ((Token_Type)jcasType).casFeatCode_tokenId);}
java
public void setTokenId(int v) { if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_tokenId == null) jcasType.jcas.throwFeatMissing("tokenId", "de.unihd.dbs.uima.types.heideltime.Token"); jcasType.ll_cas.ll_setIntValue(addr, ((Token_Type)jcasType).casFeatCode_tokenId, v);}
java
public void setSentId(int v) { if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_sentId == null) jcasType.jcas.throwFeatMissing("sentId", "de.unihd.dbs.uima.types.heideltime.Token"); jcasType.ll_cas.ll_setIntValue(addr, ((Token_Type)jcasType).casFeatCode_sentId, v);}
java
public String getPos() { if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_pos == null) jcasType.jcas.throwFeatMissing("pos", "de.unihd.dbs.uima.types.heideltime.Token"); return jcasType.ll_cas.ll_getStringValue(addr, ((Token_Type)jcasType).casFeatCode_pos);}
java
public void setPos(String v) { if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_pos == null) jcasType.jcas.throwFeatMissing("pos", "de.unihd.dbs.uima.types.heideltime.Token"); jcasType.ll_cas.ll_setStringValue(addr, ((Token_Type)jcasType).casFeatCode_pos, v);}
java
public String getEasterSunday(int year, int days) { int K = year / 100; int M = 15 + ( ( 3 * K + 3 ) / 4 ) - ( ( 8 * K + 13 ) / 25 ); int S = 2 - ( (3 * K + 3) / 4 ); int A = year % 19; int D = ( 19 * A + M ) % 30; int R = ( D / 29) + ( ( D / 28 ) - ( D / 29 ) * ( A / 11 ) ); int OG = 21 + D - R; int SZ...
java
public String getShroveTideWeekOrthodox(int year){ String easterOrthodox = getEasterSundayOrthodox(year); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); try{ Calendar calendar = Calendar.getInstance(); Date date = formatter.parse(easterOrthodox); ...
java
public String getWeekdayOfMonth(int number, int weekday, int month, int year) { return getWeekdayRelativeTo(String.format("%04d-%02d-01", year, month), weekday, number, true); }
java
public boolean containsKey(Object key) { // the key is a direct hit from our cache if(cache.containsKey(key)) return true; // the key is a direct hit from our hashmap if(container.containsKey(key)) return true; // check if the requested key is a matching string of a regex key from our container Itera...
java
public boolean containsValue(Object value) { // the value is a direct hit from our cache if(cache.containsValue(value)) return true; // the value is a direct hit from our hashmap if(container.containsValue(value)) return true; // otherwise, the value isn't within this object return false; }
java
public Set<Entry<String, T>> entrySet() { // prepare the container HashSet<Entry<String, T>> set = new HashSet<Entry<String, T>>(); // add the set from our container set.addAll(container.entrySet()); // add the set from our cache set.addAll(cache.entrySet()); return set; }
java
public T get(Object key) { // output for requested key null is the value null; normal Map behavior if(key == null) return null; T result = null; if((result = cache.get(key)) != null) { // if the requested key maps to a value in the cache return result; } else if((result = container.get(key)) != null)...
java
public Set<String> keySet() { // prepare container HashSet<String> set = new HashSet<String>(); // add container keys set.addAll(container.keySet()); // add cache keys set.addAll(cache.keySet()); return set; }
java
public T put(String key, T value) { return container.put(key, value); }
java
public T putCache(String key, T value) { return cache.put(key, value); }
java
public Collection<T> values() { // prepare set HashSet<T> set = new HashSet<T>(); // add all container values set.addAll(container.values()); // add all cache values set.addAll(cache.values()); return set; }
java
public PrintWriter openTrainLogFile() { String filename = modelDir + File.separator + trainLogFile; PrintWriter fout = null; try { fout = new PrintWriter(new OutputStreamWriter( (new FileOutputStream(filename)), "UTF-8")); } catch (IOException e) { System.out.println(e.toString()); return null...
java
public BufferedReader openModelFile() { String filename = modelDir + File.separator + modelFile; BufferedReader fin = null; try { fin = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "UTF-8")); } catch (IOException e) { System.out.println(e.toString()); return null; ...
java
public void writeOptions(PrintWriter fout) { fout.println("OPTION VALUES:"); fout.println("=============="); fout.println("Model directory: " + modelDir); fout.println("Model file: " + modelFile); fout.println("Option file: " + optionFile); fout.println("Training log file: " + trainLogFile + " (this one)"); fou...
java
public static String getXNextDay(String date, Integer x) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String newDate = ""; Calendar c = Calendar.getInstance(); try { c.setTime(formatter.parse(date)); c.add(Calendar.DAY_OF_MONTH, x); c.getTime(); newDate = formatter.format(c.get...
java
public static String getXNextWeek(String date, Integer x, Language language) { NormalizationManager nm = NormalizationManager.getInstance(language, false); String date_no_W = date.replace("W", ""); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-w"); String newDate = ""; Calendar c = Calendar.getInsta...
java