/** Loads the class that will supply all documents for this Collection. * Set by property <tt>trec.document.class</tt> */ protected void loadDocumentClass() { try{ documentClass = ApplicationSetup.getClass(ApplicationSetup.getProperty("trec.document.class", TaggedDocument.class.getName())).asSubclass(Document.class); } catch (Exception e) { throw new IllegalArgumentException(e); } }
@Override public void setProperty(String key, String value) { ApplicationSetup.setProperty(key, value); }
/** * Construct a SimpleXMLCollection */ public SimpleXMLCollection() { this(ApplicationSetup.COLLECTION_SPEC, ApplicationSetup.makeAbsolute( ApplicationSetup.getProperty("xml.blacklist.docids", ""), ApplicationSetup.TERRIER_ETC)); }
/** set a property value only if it has not already been set * @param propertyKey the name of the property to set. * @param defaultValue the value of the property to set. */ public static void setDefaultProperty(String propertyKey, String defaultValue) { if (getProperty(propertyKey,null) != null) setProperty(propertyKey, defaultValue); }
/** * Contructs an instance of the TRECResultsMatching given an index. * @param _index * @throws IOException */ public TRECResultsMatching(Index _index) throws IOException { this(_index, ApplicationSetup.getProperty("matching.trecresults.file", ""), ApplicationSetup.getProperty("matching.dsms", "")); } /**
/** * Constructs an instance of ML2 * @param parameters * @throws Exception */ public ML2(String[] parameters) throws Exception { this.normClass = ApplicationSetup.getClass(parameters[0]).asSubclass(Normalisation.class); }
clearAllProperties(); TERRIER_HOME = getProperty("terrier.home", terrier_home); FileInputStream in = new FileInputStream(propertiesFile); commonPropertiesLoaded = configure(new BufferedInputStream(in)); in.close(); } catch (java.io.FileNotFoundException fnfe) { TERRIER_HOME = getProperty("terrier.home", terrier_home); if (TERRIER_HOME.equals("")) { System.err.println("Please ensure that the property terrier.home"); loadCommonProperties();
TERRIER_ETC = makeAbsolute( getProperty("terrier.etc","etc"), TERRIER_HOME); TERRIER_VAR = makeAbsolute( getProperty("terrier.var","var"), TERRIER_HOME); TERRIER_SHARE = makeAbsolute( getProperty("terrier.share", "share"), TERRIER_HOME); TERRIER_INDEX_PATH = makeAbsolute(getProperty("terrier.index.path", "index"), TERRIER_VAR); TERRIER_INDEX_PREFIX = getProperty("terrier.index.prefix", "data"); TREC_RESULTS = makeAbsolute(getProperty("trec.results", "results"), TERRIER_VAR); TREC_RESULTS_SUFFIX = getProperty("trec.results.suffix", ".res"); COLLECTION_SPEC = makeAbsolute(getProperty("collection.spec", "collection.spec"), TERRIER_ETC); IGNORE_EMPTY_DOCUMENTS = Boolean.parseBoolean(getProperty("ignore.empty.documents", "false")); MAX_TERM_LENGTH = Integer.parseInt(getProperty("max.term.length", "20")); EXPANSION_TERMS = Integer.parseInt(getProperty("expansion.terms", "10")); EXPANSION_DOCUMENTS = Integer.parseInt(getProperty("expansion.documents", "3")); BLOCK_INDEXING = Boolean.parseBoolean(getProperty("block.indexing", "false")); BLOCK_SIZE = Integer.parseInt(getProperty("blocks.size", "1")); MAX_BLOCKS = Integer.parseInt(getProperty("blocks.max", "100000")); FIELD_QUERYING = Boolean.parseBoolean(getProperty("field.querying", "false")); MEMORY_THRESHOLD_SINGLEPASS = UnitUtils.parseInt(getProperty("memory.reserved", System.getProperty("sun.arch.data.model", "32").equals("64") ? "200Mi" : "50Mi")); DOCS_CHECK_SINGLEPASS = Integer.parseInt(getProperty("docs.check", "20")); setupPlugins();
if (propertyKV.length ==1) propertyKV = new String[]{propertyKV[0], ""}; ApplicationSetup.setProperty(propertyKV[0], propertyKV[1]); applicationSetupUpdated = true; ApplicationSetup.loadCommonProperties();
@Test public void testTwoProperties() throws Exception { ApplicationSetup.clearAllProperties(); CLITool.run(testTool.class,new String[]{"-Dfoo=bar", "-Dfoo2=bar2"}); assertEquals("bar", ApplicationSetup.getProperty("foo", null)); assertEquals("bar2", ApplicationSetup.getProperty("foo2", null)); }
static Iterable<CLITool> getServiceIterator(boolean popular) { if (popular) { List<CLITool> list = new ArrayList<CLITool>(); for(String toolClass : POPULAR_COMMANDS) { try{ list.add(org.terrier.utility.ApplicationSetup.getClass(toolClass).asSubclass(CLITool.class).newInstance()); }catch (Exception e) {} } return list; } return ServiceLoader.load(CLITool.class, org.terrier.utility.ApplicationSetup.getClassLoader()); }
/** * Creates an instance of the class. The generated data structures * will be saved in the given path. The of the data is given by the prefix * parameter. * @param _path String the path where the generated data structures will be saved. * @param _prefix String the filename that the data structures will have. */ public Indexer(String _path, String _prefix) { this.fileNameNoExtension = ApplicationSetup.makeAbsolute(_prefix, _path); this.prefix = _prefix; this.path = _path; }
@After public void deleteTerrierEtc() { File fs[] = new File(terrier_etc).listFiles(); if (fs != null) for(File f : fs) f.delete(); org.terrier.utility.ApplicationSetup.clearAllProperties(); } }
/** Loads the common Terrier properties from the specified InputStream */ public static boolean configure(InputStream propertiesStream) throws IOException { appProperties.load(propertiesStream); loadCommonProperties(); return true; }
/** * Initialises the Rocchio's beta for query expansion. */ public void initialise() { /* Accept both rocchio.beta and rocchio_beta as property name. rocchio_beta will deprecated in due course. */ ROCCHIO_BETA = Double.parseDouble(ApplicationSetup.getProperty("rocchio.beta", ApplicationSetup.getProperty("rocchio_beta", "0.4d"))); PARAMETER_FREE = Boolean.parseBoolean(ApplicationSetup.getProperty("parameter.free.expansion", "true")); }
/** * Constructs an instance of MDL2. * @param parameters * @throws Exception */ public MDL2(String[] parameters) throws Exception { this.normClass = ApplicationSetup.getClass(parameters[0]).asSubclass(Normalisation.class); }
/** set a property value only if it has not already been set * @param propertyKey the name of the property to set. * @param defaultValue the value of the property to set. */ public static void setDefaultProperty(String propertyKey, String defaultValue) { if (getProperty(propertyKey,null) != null) setProperty(propertyKey, defaultValue); }
clearAllProperties(); TERRIER_HOME = getProperty("terrier.home", terrier_home); FileInputStream in = new FileInputStream(propertiesFile); commonPropertiesLoaded = configure(new BufferedInputStream(in)); in.close(); } catch (java.io.FileNotFoundException fnfe) { TERRIER_HOME = getProperty("terrier.home", terrier_home); if (TERRIER_HOME.equals("")) { System.err.println("Please ensure that the property terrier.home"); loadCommonProperties();
TERRIER_ETC = makeAbsolute( getProperty("terrier.etc","etc"), TERRIER_HOME); TERRIER_VAR = makeAbsolute( getProperty("terrier.var","var"), TERRIER_HOME); TERRIER_SHARE = makeAbsolute( getProperty("terrier.share", "share"), TERRIER_HOME); TERRIER_INDEX_PATH = makeAbsolute(getProperty("terrier.index.path", "index"), TERRIER_VAR); TERRIER_INDEX_PREFIX = getProperty("terrier.index.prefix", "data"); TREC_RESULTS = makeAbsolute(getProperty("trec.results", "results"), TERRIER_VAR); TREC_RESULTS_SUFFIX = getProperty("trec.results.suffix", ".res"); COLLECTION_SPEC = makeAbsolute(getProperty("collection.spec", "collection.spec"), TERRIER_ETC); IGNORE_EMPTY_DOCUMENTS = Boolean.parseBoolean(getProperty("ignore.empty.documents", "false")); MAX_TERM_LENGTH = Integer.parseInt(getProperty("max.term.length", "20")); EXPANSION_TERMS = Integer.parseInt(getProperty("expansion.terms", "10")); EXPANSION_DOCUMENTS = Integer.parseInt(getProperty("expansion.documents", "3")); BLOCK_INDEXING = Boolean.parseBoolean(getProperty("block.indexing", "false")); BLOCK_SIZE = Integer.parseInt(getProperty("blocks.size", "1")); MAX_BLOCKS = Integer.parseInt(getProperty("blocks.max", "100000")); FIELD_QUERYING = Boolean.parseBoolean(getProperty("field.querying", "false")); MEMORY_THRESHOLD_SINGLEPASS = UnitUtils.parseInt(getProperty("memory.reserved", System.getProperty("sun.arch.data.model", "32").equals("64") ? "200Mi" : "50Mi")); DOCS_CHECK_SINGLEPASS = Integer.parseInt(getProperty("docs.check", "20")); setupPlugins();
if (propertyKV.length ==1) propertyKV = new String[]{propertyKV[0], ""}; ApplicationSetup.setProperty(propertyKV[0], propertyKV[1]); applicationSetupUpdated = true; ApplicationSetup.loadCommonProperties();