code
stringlengths
73
34.1k
label
stringclasses
1 value
public static int getWeekdayOfDate(String date) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); int weekday = 0; Calendar c = Calendar.getInstance(); try { c.setTime(formatter.parse(date)); weekday = c.get(Calendar.DAY_OF_WEEK); } catch (ParseException e) { e.printStackTrace(); }...
java
public static int getWeekOfDate(String date) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); int week = 0; ; Calendar c = Calendar.getInstance(); try { c.setTime(formatter.parse(date)); week = c.get(Calendar.WEEK_OF_YEAR); } catch (ParseException e) { e.printStackTrace(); } r...
java
public static Locale getLocaleFromString(String locale) throws LocaleException { for(Locale l : Locale.getAvailableLocales()) { if(locale.toLowerCase().equals(l.toString().toLowerCase())) { return l; } } throw new LocaleException(); }
java
public void allocateMemory(int memorySize) { this.memorySize = memorySize; memory = new PairDblInt[memorySize][numLabels]; for (int i = 0; i < memorySize; i++) { for (int j = 0; j < numLabels; j++) { memory[i][j] = new PairDblInt(); } } }
java
public void computeMi() { Mi.assign(0.0); model.taggerFGen.startScanEFeatures(); while (model.taggerFGen.hasNextEFeature()) { Feature f = model.taggerFGen.nextEFeature(); if (f.ftype == Feature.EDGE_FEATURE1) { Mi.mtrx[f.yp][f.y] += model.lambda[f.idx] * f.val; } } for (int i = 0; i < Mi...
java
public void computeVi(List seq, int pos, DoubleVector Vi, boolean isExp) { Vi.assign(0.0); // start scan features for sequence "seq" at position "pos" model.taggerFGen.startScanSFeaturesAt(seq, pos); // examine all features at position "pos" while (model.taggerFGen.hasNextSFeature()) { Feature f = model.tag...
java
public int findMax(PairDblInt[] cols) { int maxIdx = 0; double maxVal = -1.0; for (int i = 0; i < numLabels; i++) { if (cols[i].first > maxVal) { maxVal = cols[i].first; maxIdx = i; } } return maxIdx; }
java
public void viterbiInference(List seq) { int i, j, k; int seqLen = seq.size(); if (seqLen <= 0) { return; } if (memorySize < seqLen) { allocateMemory(seqLen); } // compute Vi for the first position in the sequence computeVi(seq, 0, Vi, true); for (j = 0; j < numLabels; j++) { memory[0][j]...
java
private void tokenize(JCas jcas) { // read tokenized text to add tokens to the jcas Logger.printDetail(component, "TreeTagger (tokenization) with: " + ttprops.abbFileName); EnumSet<Flag> flags = Flag.getSet(ttprops.languageSwitch); TreeTaggerTokenizer ttt; ttprops.abbFileName = "english-abbreviations"; if(...
java
private void tokenizeChinese(JCas jcas) { try { // read tokenized text to add tokens to the jcas Process proc = ttprops.getChineseTokenizationProcess(); Logger.printDetail(component, "Chinese tokenization: " + ttprops.chineseTokenizerPath); BufferedReader in = new BufferedReader(new InputStreamReader(...
java
public static void readAbbrList(String dataFile, Map map) throws IOException { BufferedReader fin = new BufferedReader(new FileReader(dataFile)); String line; while ((line = fin.readLine()) != null) { StringTokenizer strTok = new StringTokenizer(line, " \t\r\n"); if (strTok.countToken...
java
public static List doFeatureGen(Map map, String text , List markList, boolean label){ markList.clear(); //Find out positions of .!? and store them in the markList int nextPos = 0; while( (nextPos = StringUtils.findFirstOf(text, ".!?", nextPos + 1)) != -1) ...
java
public void initialize(Language language, DocumentType typeToProcess, OutputType outputType, String configPath) { initialize(language, typeToProcess, outputType, configPath, POSTagger.TREETAGGER); }
java
private void runIntervalTagger(JCas jcas) { logger.log(Level.FINEST, "Running Interval Tagger..."); Integer beforeAnnotations = jcas.getAnnotationIndex().size(); // Prepare the options for IntervalTagger's execution Properties settings = new Properties(); settings.put(IntervalTagger.PARAM_LANGUAGE, l...
java
@Deprecated public Process getTokenizationProcess(File inputFile) throws IOException { // assemble a command line for the tokenization script and execute it ArrayList<String> command = new ArrayList<String>(); command.add("perl"); if(this.utf8Switch != "") command.add(this.utf8Switch); command.add(this.ro...
java
public void readDict(BufferedReader fin) throws IOException { dict.clear(); String line; // get dictionary size if ((line = fin.readLine()) == null) { System.out.println("No dictionary size information"); return; } int dictSize = Integer.parseInt(line); if (dictSize <= 0) { System.out.printl...
java
public void writeDict(PrintWriter fout) throws IOException { Iterator it = null; int count = 0; for (it = dict.keySet().iterator(); it.hasNext(); ) { Integer cpInt = (Integer)it.next(); Element elem = (Element)dict.get(cpInt); if (elem.chosen == 1) { count++; } } // write the diction...
java
public void addDict(int cp, int label, int count) { Element elem = (Element)dict.get(new Integer(cp)); if (elem == null) { // if the context predicate is not found elem = new Element(); elem.count = count; CountFIdx cntFIdx = new CountFIdx(count, -1); elem.lbCntFidxes.put(new Integer(...
java
public void generateDict() { if (data.trnData == null) { System.out.println("No data available for generating dictionary"); return; } // scan all data observations of the training data for (int i = 0; i < data.trnData.size(); i++) { Observation obsr = (Observation)data.trnData.get(i); fo...
java
public static List<String> getTokens(String sentence) { //Token container List<String> tokens = new ArrayList<String>(); //Token building buffer StringBuilder buff = new StringBuilder(); for(char c : sentence.toCharArray()) { //Spaces delimit tokens (if non-empty token) if(buff.length() > 0 && spaces...
java
public Integer addTokenAnnotation(String tokenString, String fileId, Integer sentId, Integer tokId, Integer positionCounter, JCas jcas){ Token token = new Token(jcas); if (!((sentId == newTokSentNumber) && (tokId == newTokSentNumber))){ if(USE_SPACES) // in chinese, there are no spaces, so the +1 correction is u...
java
private Integer getNumberOfDocuments(List<File> inputFiles) throws ResourceInitializationException{ String directory = (String) getConfigParameterValue(PARAM_INPUTDIR); String filename = directory+"/"+FILE_BASE_SEGMENTATION; for (File file : inputFiles) { if (file.getAbsolutePath().equals(filename)){ try ...
java
public int strId2Idx(Map fmap) { Integer idxInt = (Integer)fmap.get(strId); if (idxInt != null) { this.idx = idxInt.intValue(); } return this.idx; }
java
public int strId2IdxAdd(Map fmap) { strId2Idx(fmap); if (idx < 0) { idx = fmap.size(); fmap.put(strId, new Integer(idx)); } return idx; }
java
private void readRePatternResources(ResourceMap hmResourcesRePattern, Boolean load_temponym_resources) { ////////////////////////////////////// // READ REGULAR EXPRESSION PATTERNS // ////////////////////////////////////// InputStream is = null; InputStreamReader isr = null; BufferedReader br = null; try ...
java
private void finalizeRePattern(String name, String rePattern) { // create correct regular expression rePattern = rePattern.replaceFirst("\\|", ""); /* this was added to reduce the danger of getting unusable groups from user-made repattern * files with group-producing parentheses (i.e. "(foo|bar)" while matchin...
java
public int getSentId() { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_sentId == null) jcasType.jcas.throwFeatMissing("sentId", "de.unihd.dbs.uima.types.heideltime.Timex3"); return jcasType.ll_cas.ll_getIntValue(addr, ((Timex3_Type)jcasType).casFeatCode_sentId);}
java
public int getFirstTokId() { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_firstTokId == null) jcasType.jcas.throwFeatMissing("firstTokId", "de.unihd.dbs.uima.types.heideltime.Timex3"); return jcasType.ll_cas.ll_getIntValue(addr, ((Timex3_Type)jcasType).casFeatCode_firstTokId);}
java
public void setFirstTokId(int v) { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_firstTokId == null) jcasType.jcas.throwFeatMissing("firstTokId", "de.unihd.dbs.uima.types.heideltime.Timex3"); jcasType.ll_cas.ll_setIntValue(addr, ((Timex3_Type)jcasType).casFeatCode_firstTokId, v);}
java
public String getAllTokIds() { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_allTokIds == null) jcasType.jcas.throwFeatMissing("allTokIds", "de.unihd.dbs.uima.types.heideltime.Timex3"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_allTokIds);}
java
public void setAllTokIds(String v) { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_allTokIds == null) jcasType.jcas.throwFeatMissing("allTokIds", "de.unihd.dbs.uima.types.heideltime.Timex3"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_allTokIds, v);}
java
public int getTimexInstance() { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexInstance == null) jcasType.jcas.throwFeatMissing("timexInstance", "de.unihd.dbs.uima.types.heideltime.Timex3"); return jcasType.ll_cas.ll_getIntValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexInstance);}
java
public void setTimexInstance(int v) { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexInstance == null) jcasType.jcas.throwFeatMissing("timexInstance", "de.unihd.dbs.uima.types.heideltime.Timex3"); jcasType.ll_cas.ll_setIntValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexInstance, v)...
java
public String getTimexType() { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexType == null) jcasType.jcas.throwFeatMissing("timexType", "de.unihd.dbs.uima.types.heideltime.Timex3"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexType);}
java
public void setTimexType(String v) { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexType == null) jcasType.jcas.throwFeatMissing("timexType", "de.unihd.dbs.uima.types.heideltime.Timex3"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexType, v);}
java
public String getTimexValue() { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexValue == null) jcasType.jcas.throwFeatMissing("timexValue", "de.unihd.dbs.uima.types.heideltime.Timex3"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexValue);}
java
public void setTimexValue(String v) { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexValue == null) jcasType.jcas.throwFeatMissing("timexValue", "de.unihd.dbs.uima.types.heideltime.Timex3"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexValue, v);}
java
public String getFoundByRule() { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_foundByRule == null) jcasType.jcas.throwFeatMissing("foundByRule", "de.unihd.dbs.uima.types.heideltime.Timex3"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_foundByRule);}
java
public void setFoundByRule(String v) { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_foundByRule == null) jcasType.jcas.throwFeatMissing("foundByRule", "de.unihd.dbs.uima.types.heideltime.Timex3"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_foundByRule, v);}
java
public String getTimexQuant() { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexQuant == null) jcasType.jcas.throwFeatMissing("timexQuant", "de.unihd.dbs.uima.types.heideltime.Timex3"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexQuant);}
java
public void setTimexQuant(String v) { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexQuant == null) jcasType.jcas.throwFeatMissing("timexQuant", "de.unihd.dbs.uima.types.heideltime.Timex3"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexQuant, v);}
java
public String getTimexFreq() { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexFreq == null) jcasType.jcas.throwFeatMissing("timexFreq", "de.unihd.dbs.uima.types.heideltime.Timex3"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexFreq);}
java
public void setTimexFreq(String v) { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexFreq == null) jcasType.jcas.throwFeatMissing("timexFreq", "de.unihd.dbs.uima.types.heideltime.Timex3"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexFreq, v);}
java
public String getTimexMod() { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexMod == null) jcasType.jcas.throwFeatMissing("timexMod", "de.unihd.dbs.uima.types.heideltime.Timex3"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexMod);}
java
public void setTimexMod(String v) { if (Timex3_Type.featOkTst && ((Timex3_Type)jcasType).casFeat_timexMod == null) jcasType.jcas.throwFeatMissing("timexMod", "de.unihd.dbs.uima.types.heideltime.Timex3"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3_Type)jcasType).casFeatCode_timexMod, v);}
java
public void generateFeatures() { if (features != null) { features.clear(); } else { features = new ArrayList(); } if (fmap != null) { fmap.clear(); } else { fmap = new HashMap(); } if (currentFeatures != null) { currentFeatures.clear(); } else { currentFeatures = new ArrayL...
java
public void readFeatures(BufferedReader fin) throws IOException { if (features != null) { features.clear(); } else { features = new ArrayList(); } if (fmap != null) { fmap.clear(); } else { fmap = new HashMap(); } if (currentFeatures != null) { currentFeatures.clear(); } else { ...
java
public void writeFeatures(PrintWriter fout) throws IOException { // write the number of features fout.println(Integer.toString(features.size())); for (int i = 0; i < features.size(); i++) { Feature f = (Feature)features.get(i); fout.println(f.toString(data.cpInt2Str, data.lbInt2Str)); } // wirte the ...
java
public void startScanFeatures(Observation obsr) { currentFeatures.clear(); currentFeatureIdx = 0; // 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) {//this context predicate doesn't appear i...
java
public String classify(String cps) { // cps contains a list of context predicates String modelLabel = ""; int i; intCps.clear(); StringTokenizer strTok = new StringTokenizer(cps, " \t\r\n"); int count = strTok.countTokens(); for (i = 0; i < count; i++) { String cpStr = strTok.nextToke...
java
public List classify(List data) { List list = new ArrayList(); for (int i = 0; i < data.size(); i++) { list.add(classify((String)data.get(i))); } return list; }
java
public void registerProcessor(String processor, Priority prio) { this.processorNames.get(prio).add(processor); }
java
public void initializeAllProcessors(UimaContext aContext) { for(Priority prio : processorNames.keySet()) { for(String pn : processorNames.get(prio)) { try { Class<?> c = Class.forName(pn); GenericProcessor p = (GenericProcessor) c.newInstance(); p.initialize(aContext); processors.get(prio)....
java
public void executeProcessors(JCas jcas, ProcessorManager.Priority prio) { if(!this.initialized) { Logger.printError(component, "Unable to execute Processors; initialization was not concluded successfully."); System.exit(-1); } LinkedList<GenericProcessor> myList = processors.get(prio); for(GenericProc...
java
public String getTimexValueEB() { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_TimexValueEB == null) jcasType.jcas.throwFeatMissing("TimexValueEB", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3Interval_Type)jca...
java
public void setTimexValueEB(String v) { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_TimexValueEB == null) jcasType.jcas.throwFeatMissing("TimexValueEB", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3Interval_Type)jcas...
java
public String getTimexValueLE() { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_TimexValueLE == null) jcasType.jcas.throwFeatMissing("TimexValueLE", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3Interval_Type)jca...
java
public void setTimexValueLE(String v) { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_TimexValueLE == null) jcasType.jcas.throwFeatMissing("TimexValueLE", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3Interval_Type)jcas...
java
public String getTimexValueEE() { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_TimexValueEE == null) jcasType.jcas.throwFeatMissing("TimexValueEE", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3Interval_Type)jca...
java
public void setTimexValueEE(String v) { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_TimexValueEE == null) jcasType.jcas.throwFeatMissing("TimexValueEE", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3Interval_Type)jcas...
java
public String getTimexValueLB() { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_TimexValueLB == null) jcasType.jcas.throwFeatMissing("TimexValueLB", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3Interval_Type)jca...
java
public void setTimexValueLB(String v) { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_TimexValueLB == null) jcasType.jcas.throwFeatMissing("TimexValueLB", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3Interval_Type)jcas...
java
public String getEmptyValue() { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_emptyValue == null) jcasType.jcas.throwFeatMissing("emptyValue", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3Interval_Type)jcasType)...
java
public void setEmptyValue(String v) { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_emptyValue == null) jcasType.jcas.throwFeatMissing("emptyValue", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3Interval_Type)jcasType)....
java
public String getBeginTimex() { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_beginTimex == null) jcasType.jcas.throwFeatMissing("beginTimex", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3Interval_Type)jcasType)...
java
public void setBeginTimex(String v) { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_beginTimex == null) jcasType.jcas.throwFeatMissing("beginTimex", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3Interval_Type)jcasType)....
java
public String getEndTimex() { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_endTimex == null) jcasType.jcas.throwFeatMissing("endTimex", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); return jcasType.ll_cas.ll_getStringValue(addr, ((Timex3Interval_Type)jcasType).casFe...
java
public void setEndTimex(String v) { if (Timex3Interval_Type.featOkTst && ((Timex3Interval_Type)jcasType).casFeat_endTimex == null) jcasType.jcas.throwFeatMissing("endTimex", "de.unihd.dbs.uima.types.heideltime.Timex3Interval"); jcasType.ll_cas.ll_setStringValue(addr, ((Timex3Interval_Type)jcasType).casFea...
java
public void process(JCas jcas) { try { tagger.process(jcas); } catch(AnalysisEngineProcessException e) { e.printStackTrace(); } }
java
public String getTimexId() { if (Dct_Type.featOkTst && ((Dct_Type)jcasType).casFeat_timexId == null) jcasType.jcas.throwFeatMissing("timexId", "de.unihd.dbs.uima.types.heideltime.Dct"); return jcasType.ll_cas.ll_getStringValue(addr, ((Dct_Type)jcasType).casFeatCode_timexId);}
java
public void setTimexId(String v) { if (Dct_Type.featOkTst && ((Dct_Type)jcasType).casFeat_timexId == null) jcasType.jcas.throwFeatMissing("timexId", "de.unihd.dbs.uima.types.heideltime.Dct"); jcasType.ll_cas.ll_setStringValue(addr, ((Dct_Type)jcasType).casFeatCode_timexId, v);}
java
private static void patternCompile() { try { ptnNumber = Pattern.compile(strNumberPattern); ptnShortDate = Pattern.compile(strShortDatePattern); ptnLongDate = Pattern.compile(strLongDatePattern); ptnPercentage = Pattern.compile(strPercentagePattern); ptnCurrency = Pattern.compile(strCurrencyPatte...
java
private static String patternMatching(String ptnName, String input) { String suffix = ""; if (ptnNumber == null) patternCompile(); Matcher matcher; if (ptnName.equals("number")) { matcher = ptnNumber.matcher(input); if (matcher.matches()) suffix = ":number"; } else if (ptnName.equals("...
java
public void parseVnSyllable(String syll) { strSyllable = syll; strMainVowel = ""; strSecondaryVowel = ""; strFirstConsonant = ""; strLastConsonant = ""; iCurPos = 0; validViSyll = true; parseFirstConsonant(); parseSecondaryVowel(); parseMainVowel(); parseLastConsonant(); }
java
private void parseFirstConsonant() { // find first of (vnfirstconsonant) // if not found, first consonant = ZERO // else the found consonant Iterator iter = alFirstConsonants.iterator(); while (iter.hasNext()) { String strFirstCon = (String) iter.next(); if (strSyllable.startsWith(strFirstCon, iCurPos))...
java
private void parseSecondaryVowel() { if (!validViSyll) return; // get the current and next character in the syllable string char curChar, nextChar; if (iCurPos > strSyllable.length() - 1) { validViSyll = false; return; } curChar = strSyllable.charAt(iCurPos); if (iCurPos == strSyllable.length() ...
java
private void parseMainVowel() { if (!validViSyll) return; if (iCurPos > strSyllable.length() - 1) { validViSyll = false; return; } String strVowel = ""; for (int i = iCurPos; i < strSyllable.length(); ++i) { int idx = vnVowels.indexOf(strSyllable.charAt(i)); if (idx == -1) break; strVo...
java
private void parseLastConsonant() { if (!validViSyll) return; if (iCurPos > strSyllable.length()) strLastConsonant = ZERO; String strCon = strSyllable.substring(iCurPos, strSyllable.length()); if (strCon.length() > 3) { validViSyll = false; return; } Iterator iter = alLastConsonants.iterator()...
java
private static void initArrayList(ArrayList al, String str) { StringTokenizer strTknr = new StringTokenizer(str, "|"); while (strTknr.hasMoreTokens()) { al.add(strTknr.nextToken()); } }
java
public static void displayCopyright() { System.out.println("Vietnamese Word Segmentation:"); System.out.println("\tusing Conditional Random Fields"); System.out.println("\ttesting our dataset of 8000 sentences with the highest F1-measure of 94%"); System.out.println("Copyright (C) by...
java
public static void displayHelp() { System.out.println("Usage:"); System.out.println("\tCase 1: WordSegmenting -modeldir <model directory> -inputfile <input data file>"); System.out.println("\tCase 2: WordSegmenting -modeldir <model directory> -inputdir <input data directory>"); Syste...
java
public static Boolean checkInfrontBehind(MatchResult r, Sentence s) { Boolean ok = true; // get rid of expressions such as "1999" in 53453.1999 if (r.start() > 1) { if ((s.getCoveredText().substring(r.start() - 2, r.start()).matches("\\d\\."))){ ok = false; } } // get rid of expressions if the...
java
public void inferenceAll(List data) { System.out.println("Starting inference ..."); long start, stop, elapsed; start = System.currentTimeMillis(); for (int i = 0; i < data.size(); i++) { System.out.println("sequence " + Integer.toString(i + 1)); List seq = (List)data.get(i); inference(seq); ...
java
public void readCpMaps(BufferedReader fin) throws IOException { if (cpStr2Int != null) { cpStr2Int.clear(); } else { cpStr2Int = new HashMap(); } if (cpInt2Str != null) { cpInt2Str.clear(); } else { cpInt2Str = new HashMap(); } String line; // get size of context predicate map if ((li...
java
public void readLbMaps(BufferedReader fin) throws IOException { if (lbStr2Int != null) { lbStr2Int.clear(); } else { lbStr2Int = new HashMap(); } if (lbInt2Str != null) { lbInt2Str.clear(); } else { lbInt2Str = new HashMap(); } String line; // get size of label map if ((line = fin.read...
java
public int getSentenceId() { if (Sentence_Type.featOkTst && ((Sentence_Type)jcasType).casFeat_sentenceId == null) jcasType.jcas.throwFeatMissing("sentenceId", "de.unihd.dbs.uima.types.heideltime.Sentence"); return jcasType.ll_cas.ll_getIntValue(addr, ((Sentence_Type)jcasType).casFeatCode_sentenceId);}
java
public void setSentenceId(int v) { if (Sentence_Type.featOkTst && ((Sentence_Type)jcasType).casFeat_sentenceId == null) jcasType.jcas.throwFeatMissing("sentenceId", "de.unihd.dbs.uima.types.heideltime.Sentence"); jcasType.ll_cas.ll_setIntValue(addr, ((Sentence_Type)jcasType).casFeatCode_sentenceId, v);}
java
public String getUri() { if (SourceDocInfo_Type.featOkTst && ((SourceDocInfo_Type)jcasType).casFeat_uri == null) jcasType.jcas.throwFeatMissing("uri", "de.unihd.dbs.uima.types.heideltime.SourceDocInfo"); return jcasType.ll_cas.ll_getStringValue(addr, ((SourceDocInfo_Type)jcasType).casFeatCode_uri);}
java
public int getOffsetInSource() { if (SourceDocInfo_Type.featOkTst && ((SourceDocInfo_Type)jcasType).casFeat_offsetInSource == null) jcasType.jcas.throwFeatMissing("offsetInSource", "de.unihd.dbs.uima.types.heideltime.SourceDocInfo"); return jcasType.ll_cas.ll_getIntValue(addr, ((SourceDocInfo_Type)jcasTyp...
java
public void setOffsetInSource(int v) { if (SourceDocInfo_Type.featOkTst && ((SourceDocInfo_Type)jcasType).casFeat_offsetInSource == null) jcasType.jcas.throwFeatMissing("offsetInSource", "de.unihd.dbs.uima.types.heideltime.SourceDocInfo"); jcasType.ll_cas.ll_setIntValue(addr, ((SourceDocInfo_Type)jcasType...
java
@SuppressWarnings({"unchecked","rawtypes"}) public static void setProps(Properties prop) { properties = prop; Iterator propIt = properties.entrySet().iterator(); while(propIt.hasNext()) { Entry<String, String> entry = (Entry<String, String>) propIt.next(); properties.setProperty(entry.getKey...
java
public boolean initSenSegmenter(String modelDir){ System.out.println("Initilize JVnSenSegmenter ..."); //initialize sentence segmentation vnSenSegmenter = new JVnSenSegmenter(); if (!vnSenSegmenter.init(modelDir)){ System.out.println("Error while initilizing JVnSenSegmenter"); vnSenSegmenter =...
java
public boolean initSegmenter(String modelDir){ System.out.println("Initilize JVnSegmenter ..."); System.out.println(modelDir); vnSegmenter = new CRFSegmenter(); try{ vnSegmenter.init(modelDir); } catch (Exception e){ System.out.println("Error while initializing JVnSegmenter"); vnSegm...
java
public boolean initPosTagger(String modelDir){ try{ this.vnPosTagger = new MaxentTagger(modelDir); } catch (Exception e){ System.out.println("Error while initializing POS TAgger"); vnPosTagger = null; return false; } return true; }
java
public String senSegment(String text){ String ret = text; //Segment sentences if (vnSenSegmenter != null){ ret = vnSenSegmenter.senSegment(text); } return ret.trim(); }
java
public String senTokenize(String text){ String ret = text; if (isTokenization){ ret = PennTokenizer.tokenize(text); } return ret.trim(); }
java
public String wordSegment(String text){ String ret = text; if (vnSegmenter == null) return ret; ret = vnSegmenter.segmenting(ret); return ret; }
java
public String posTagging(String text){ String ret = text; if (vnPosTagger != null){ ret = vnPosTagger.tagging(text); } return ret; }
java
@Deprecated public static WayPoint of( final Latitude latitude, final Longitude longitude, final Length elevation, final Speed speed, final ZonedDateTime time, final Degrees magneticVariation, final Length geoidHeight, final String name, final String comment, final String description, final Strin...
java
public static Location of(final Point point) { requireNonNull(point); return of( point.getLatitude(), point.getLongitude(), point.getElevation().orElse(null) ); }
java