Java Code Examples for it.unimi.dsi.fastutil.objects.ObjectArrayList#isEmpty()

The following examples show how to use it.unimi.dsi.fastutil.objects.ObjectArrayList#isEmpty() . 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: MathSolver.java    From WarpPI with Apache License 2.0 6 votes vote down vote up
private boolean checkEquals(final ObjectArrayList<Function> a, final ObjectArrayList<Function> b) {
	if (a == null && b == null) {
		return true;
	} else if (a != null && b != null) {
		if (a.isEmpty() == b.isEmpty()) {
			int size;
			if ((size = a.size()) == b.size()) {
				for (int i = 0; i < size; i++) {
					if (a.get(i).equals(b.get(i)) == false) {
						return false;
					}
				}
				return true;
			}
		}
	}
	return false;
}
 
Example 2
Source File: OutputContainer.java    From WarpPI with Apache License 2.0 5 votes vote down vote up
public boolean isContentEmpty() {
	for (final BlockContainer root : roots) {
		final ObjectArrayList<Block> cnt = root.getContent();
		if (cnt != null && !cnt.isEmpty()) {
			return false;
		}
	}
	return true;
}
 
Example 3
Source File: HyFD.java    From metanome-algorithms with Apache License 2.0 4 votes vote down vote up
private void executeFDEP() throws AlgorithmExecutionException {
	// Initialize
	System.out.println("Initializing ...");
	RelationalInput relationalInput = this.getInput();
	this.initialize(relationalInput);
	
	// Load data
	System.out.println("Loading data ...");
	ObjectArrayList<List<String>> records = this.loadData(relationalInput);
	this.closeInput(relationalInput);
	
	// Create default output if input is empty
	if (records.isEmpty()) {
		ObjectArrayList<ColumnIdentifier> columnIdentifiers = this.buildColumnIdentifiers();
		for (int attr = 0; attr < this.numAttributes; attr++)
			this.resultReceiver.receiveResult(new FunctionalDependency(new ColumnCombination(), columnIdentifiers.get(attr)));
		return;
	}
	
	int numRecords = records.size();
	
	// Calculate plis
	System.out.println("Calculating plis ...");
	List<PositionListIndex> plis = PLIBuilder.getPLIs(records, this.numAttributes, this.valueComparator.isNullEqualNull());
	records = null; // we proceed with the values in the plis
	
	// Calculate inverted plis
	System.out.println("Inverting plis ...");
	int[][] invertedPlis = this.invertPlis(plis, numRecords);

	// Extract the integer representations of all records from the inverted plis
	System.out.println("Extracting integer representations for the records ...");
	int[][] compressedRecords = new int[numRecords][];
	for (int recordId = 0; recordId < numRecords; recordId++)
		compressedRecords[recordId] = this.fetchRecordFrom(recordId, invertedPlis);
	
	// Execute fdep
	System.out.println("Executing fdep ...");
	FDEP fdep = new FDEP(this.numAttributes, this.valueComparator);
	FDTree fds = fdep.execute(compressedRecords);
	
	// Output all valid FDs
	System.out.println("Translating fd-tree into result format ...");
	List<FunctionalDependency> result = fds.getFunctionalDependencies(this.buildColumnIdentifiers(), plis);
	plis = null;
	int numFDs = 0;
	for (FunctionalDependency fd : result) {
		//System.out.println(fd);
		this.resultReceiver.receiveResult(fd);
		numFDs++;
	}
	System.out.println("... done! (" + numFDs + " FDs)");
}
 
Example 4
Source File: HyFD.java    From metanome-algorithms with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
private void executeFDEP() throws AlgorithmExecutionException {
	// Initialize
	Logger.getInstance().writeln("Initializing ...");
	RelationalInput relationalInput = this.getInput();
	this.initialize(relationalInput);
	
	// Load data
	Logger.getInstance().writeln("Loading data ...");
	ObjectArrayList<List<String>> records = this.loadData(relationalInput);
	this.closeInput(relationalInput);
	
	// Create default output if input is empty
	if (records.isEmpty()) {
		ObjectArrayList<ColumnIdentifier> columnIdentifiers = this.buildColumnIdentifiers();
		for (int attr = 0; attr < this.numAttributes; attr++)
			this.resultReceiver.receiveResult(new FunctionalDependency(new ColumnCombination(), columnIdentifiers.get(attr)));
		return;
	}
	
	int numRecords = records.size();
	
	// Calculate plis
	Logger.getInstance().writeln("Calculating plis ...");
	List<PositionListIndex> plis = PLIBuilder.getPLIs(records, this.numAttributes, this.valueComparator.isNullEqualNull());
	records = null; // we proceed with the values in the plis
	
	// Calculate inverted plis
	Logger.getInstance().writeln("Inverting plis ...");
	int[][] invertedPlis = this.invertPlis(plis, numRecords);

	// Extract the integer representations of all records from the inverted plis
	Logger.getInstance().writeln("Extracting integer representations for the records ...");
	int[][] compressedRecords = new int[numRecords][];
	for (int recordId = 0; recordId < numRecords; recordId++)
		compressedRecords[recordId] = this.fetchRecordFrom(recordId, invertedPlis);
	
	// Execute fdep
	Logger.getInstance().writeln("Executing fdep ...");
	FDEP fdep = new FDEP(this.numAttributes, this.valueComparator);
	FDTree fds = fdep.execute(compressedRecords);
	
	// Output all valid FDs
	Logger.getInstance().writeln("Translating fd-tree into result format ...");
	List<FunctionalDependency> result = fds.getFunctionalDependencies(this.buildColumnIdentifiers(), plis);
	plis = null;
	int numFDs = 0;
	for (FunctionalDependency fd : result) {
		//Logger.getInstance().writeln(fd);
		this.resultReceiver.receiveResult(fd);
		numFDs++;
	}
	Logger.getInstance().writeln("... done! (" + numFDs + " FDs)");
}
 
Example 5
Source File: AnnotatedPhrase.java    From minie with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Detect the quantities in a phrase (given the sentence semantic graph).
 * @param sentSemGraph: the sentence semantic graph
 */
public void detectQuantities(SemanticGraph sentSemGraph, int i){
    // Quantity words and edges
    ObjectArrayList<IndexedWord> qWords;
    ObjectArrayList<SemanticGraphEdge> qEdges = new ObjectArrayList<>();
    
    // Tokens regex patterns
    String tokenRegexPattern;
    if (i == 1)
        tokenRegexPattern = REGEX.QUANTITY_SEQUENCE;
    else
        tokenRegexPattern = REGEX.QUANTITY_SEQUENCE_WITH_NO;
    
    TokenSequencePattern tPattern = TokenSequencePattern.compile(tokenRegexPattern);
    TokenSequenceMatcher tMatcher = tPattern.getMatcher(this.getWordCoreLabelList());
    
    // Some reusable variables
    List<CoreMap> matchCoreMaps;
    ObjectOpenHashSet<IndexedWord> wordsSet = new ObjectOpenHashSet<>();
    IndexedWord head;
    Set<SemanticGraphEdge> subtreeedges = new HashSet<>();
    int matchCounter = -1;
    
    // Annotate the matches and their subtrees
    while (tMatcher.find()){      
        matchCounter++;
        matchCoreMaps = tMatcher.groupNodes();
        
        // Get the head word of the phrase and see whether or not to add it to the quantities
        head = CoreNLPUtils.getRootFromCoreMapWordList(sentSemGraph, matchCoreMaps);
        if (head.ner().equals(NE_TYPE.DATE) || head.ner().equals(NE_TYPE.LOCATION) ||
                head.ner().equals(NE_TYPE.MISC) || head.ner().equals(NE_TYPE.ORGANIZATION) || 
                head.ner().equals(NE_TYPE.PERSON) || head.ner().equals(NE_TYPE.TIME))
            continue;
        
        // Add the sutree elements of the head word if the right relations are in force
        for (IndexedWord w: sentSemGraph.getChildren(head)){
            if ((sentSemGraph.reln(head, w) == EnglishGrammaticalRelations.QUANTIFIER_MODIFIER) ||
                (sentSemGraph.reln(head, w) == EnglishGrammaticalRelations.ADVERBIAL_MODIFIER)){
                wordsSet.add(w);
                subtreeedges = CoreNLPUtils.getSubTreeEdges(w, sentSemGraph, null);
            }
        }
        
        // Add the quantity words found and annotate them within the phrase
        wordsSet.addAll(CoreNLPUtils.getWordSetFromCoreMapList(matchCoreMaps));
        wordsSet.addAll(CoreNLPUtils.getSortedWordsFromListOfEdges(subtreeedges));
        wordsSet.retainAll(this.getWordList());
        qWords = CoreNLPUtils.getSortedWordsFromSetOfWords(wordsSet);
        if (qWords.isEmpty())
            continue;
        this.setQuantitiesFromWordList(qWords.clone(), qEdges, sentSemGraph, i, matchCounter);
        
        // Reset
        qWords.clear();
        wordsSet.clear();
    }
}
 
Example 6
Source File: HyFD.java    From winter with Apache License 2.0 4 votes vote down vote up
private void executeFDEP() throws AlgorithmExecutionException {
	// Initialize
	System.out.println("Initializing ...");
	RelationalInput relationalInput = this.getInput();
	this.initialize(relationalInput);
	
	// Load data
	System.out.println("Loading data ...");
	ObjectArrayList<List<String>> records = this.loadData(relationalInput);
	this.closeInput(relationalInput);
	
	// Create default output if input is empty
	if (records.isEmpty()) {
		ObjectArrayList<ColumnIdentifier> columnIdentifiers = this.buildColumnIdentifiers();
		for (int attr = 0; attr < this.numAttributes; attr++)
			this.resultReceiver.receiveResult(new FunctionalDependency(new ColumnCombination(), columnIdentifiers.get(attr)));
		return;
	}
	
	int numRecords = records.size();
	
	// Calculate plis
	System.out.println("Calculating plis ...");
	List<PositionListIndex> plis = PLIBuilder.getPLIs(records, this.numAttributes, this.valueComparator.isNullEqualNull());
	records = null; // we proceed with the values in the plis
	
	// Calculate inverted plis
	System.out.println("Inverting plis ...");
	int[][] invertedPlis = this.invertPlis(plis, numRecords);

	// Extract the integer representations of all records from the inverted plis
	System.out.println("Extracting integer representations for the records ...");
	int[][] compressedRecords = new int[numRecords][];
	for (int recordId = 0; recordId < numRecords; recordId++)
		compressedRecords[recordId] = this.fetchRecordFrom(recordId, invertedPlis);
	
	// Execute fdep
	System.out.println("Executing fdep ...");
	FDEP fdep = new FDEP(this.numAttributes, this.valueComparator);
	FDTree fds = fdep.execute(compressedRecords);
	
	// Output all valid FDs
	System.out.println("Translating fd-tree into result format ...");
	List<FunctionalDependency> result = fds.getFunctionalDependencies(this.buildColumnIdentifiers(), plis);
	plis = null;
	int numFDs = 0;
	for (FunctionalDependency fd : result) {
		//System.out.println(fd);
		this.resultReceiver.receiveResult(fd);
		numFDs++;
	}
	System.out.println("... done! (" + numFDs + " FDs)");
}
 
Example 7
Source File: HyFD.java    From winter with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
private void executeFDEP() throws AlgorithmExecutionException {
	// Initialize
	Logger.getInstance().writeln("Initializing ...");
	RelationalInput relationalInput = this.getInput();
	this.initialize(relationalInput);
	
	// Load data
	Logger.getInstance().writeln("Loading data ...");
	ObjectArrayList<List<String>> records = this.loadData(relationalInput);
	this.closeInput(relationalInput);
	
	// Create default output if input is empty
	if (records.isEmpty()) {
		ObjectArrayList<ColumnIdentifier> columnIdentifiers = this.buildColumnIdentifiers();
		for (int attr = 0; attr < this.numAttributes; attr++)
			this.resultReceiver.receiveResult(new FunctionalDependency(new ColumnCombination(), columnIdentifiers.get(attr)));
		return;
	}
	
	int numRecords = records.size();
	
	// Calculate plis
	Logger.getInstance().writeln("Calculating plis ...");
	List<PositionListIndex> plis = PLIBuilder.getPLIs(records, this.numAttributes, this.valueComparator.isNullEqualNull());
	records = null; // we proceed with the values in the plis
	
	// Calculate inverted plis
	Logger.getInstance().writeln("Inverting plis ...");
	int[][] invertedPlis = this.invertPlis(plis, numRecords);

	// Extract the integer representations of all records from the inverted plis
	Logger.getInstance().writeln("Extracting integer representations for the records ...");
	int[][] compressedRecords = new int[numRecords][];
	for (int recordId = 0; recordId < numRecords; recordId++)
		compressedRecords[recordId] = this.fetchRecordFrom(recordId, invertedPlis);
	
	// Execute fdep
	Logger.getInstance().writeln("Executing fdep ...");
	FDEP fdep = new FDEP(this.numAttributes, this.valueComparator);
	FDTree fds = fdep.execute(compressedRecords);
	
	// Output all valid FDs
	Logger.getInstance().writeln("Translating fd-tree into result format ...");
	List<FunctionalDependency> result = fds.getFunctionalDependencies(this.buildColumnIdentifiers(), plis);
	plis = null;
	int numFDs = 0;
	for (FunctionalDependency fd : result) {
		//Logger.getInstance().writeln(fd);
		this.resultReceiver.receiveResult(fd);
		numFDs++;
	}
	Logger.getInstance().writeln("... done! (" + numFDs + " FDs)");
}
 
Example 8
Source File: MathSolver.java    From WarpPI with Apache License 2.0 4 votes vote down vote up
private ObjectArrayList<Function> applyRules(final ObjectArrayList<Function> fncs,
		final RuleType currentAcceptedRules) throws InterruptedException, Error {
	final ObjectArrayList<Rule> rules = initialFunction.getMathContext().getAcceptableRules(currentAcceptedRules);
	ObjectArrayList<Function> results = null;
	final ObjectArrayList<Rule> appliedRules = new ObjectArrayList<>();
	for (final Function fnc : fncs) {
		boolean didSomething = false;
		for (final Rule rule : rules) {
			if (isSimplified(fnc, rule) == false) {
				final List<Function> ruleResults = fnc.simplify(rule);
				if (ruleResults != null && !ruleResults.isEmpty()) {
					if (results == null) {
						results = new ObjectArrayList<>();
					}
					results.addAll(ruleResults);
					appliedRules.add(rule);
					setSimplified(fnc, rule);
					didSomething = true;
					break;
				}
			}
		}
		if (!didSomething && fncs.size() > 1) {
			if (results == null) {
				results = new ObjectArrayList<>();
			}
			results.add(fnc);
		}
	}
	if (appliedRules.isEmpty()) {
		results = null;
	}
	if (WarpPI.getPlatform().getConsoleUtils().getOutputLevel() >= ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN & results != null && !appliedRules.isEmpty()) {
		final StringBuilder rulesStr = new StringBuilder();
		for (final Rule r : appliedRules) {
			rulesStr.append(r.getRuleName());
			rulesStr.append(',');
		}
		if (rulesStr.length() > 0) {
			rulesStr.setLength(rulesStr.length() - 1);
		}
		WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", currentAcceptedRules.toString(), "Applied rules: " + rulesStr);
	}
	return results;
}