Java Code Examples for gnu.trove.THashSet#addAll()

The following examples show how to use gnu.trove.THashSet#addAll() . 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: RequiredDataCreation.java    From semafor-semantic-parser with GNU General Public License v3.0 6 votes vote down vote up
public static THashSet<String> getRelatedWords(FNModelOptions options) {
	String fmFile = options.frameNetMapFile.get();
	String wnConfigFile = options.wnConfigFile.get();
	String stopFile = options.stopWordsFile.get();
	String luXmlDir = options.luXmlDir.get();
	THashMap<String, THashSet<String>> mFrameMap = 
		(THashMap<String, THashSet<String>>)
		SerializedObjects.readSerializedObject(fmFile);
	WordNetRelations wnr = new WordNetRelations(stopFile, wnConfigFile);
	THashSet<String> set = getAllRelatedWords(mFrameMap, 
											wnr);
	THashSet<String> absentExampleLUs = getListOfLUs(luXmlDir, wnr);
	set.addAll(absentExampleLUs);
	String relatedWordsFile = options.allRelatedWordsFile.get();
	SerializedObjects.writeSerializedObject(set, relatedWordsFile);
	return set;
}
 
Example 2
Source File: RequiredDataCreation.java    From semafor-semantic-parser with GNU General Public License v3.0 5 votes vote down vote up
public static Set<String> getSelectedRelatedWords(THashMap<String,Set<String>> rlMap)
{
	Set<String> keys = rlMap.keySet();
	THashSet<String> result = new THashSet<String>();
	for(String key: keys)
	{
		if(key.equals("identity")/*||key.equals("synonym")||key.equals("derived-form")||key.equals("morph")*/)
			result.addAll(rlMap.get(key));
	}
	return result;
}
 
Example 3
Source File: FEDict.java    From semafor-semantic-parser with GNU General Public License v3.0 5 votes vote down vote up
public void merge(String filename){
	THashMap<String,THashSet<String>> tempdict=(THashMap<String,THashSet<String>>)SerializedObjects.readSerializedObject(filename);
	for(String key : tempdict.keySet()){
		THashSet newval=tempdict.get(key);
		if(fedict.contains(key)){
			THashSet val=fedict.get(key);
			val.addAll(newval);
		}
		else{
			fedict.put(key, newval);
		}
	}
	fedict.putAll(tempdict);
}
 
Example 4
Source File: CSharpBaseResolveContext.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@RequiredReadAction
private CSharpResolveContext getSuperContext()
{
	THashSet<PsiElement> alreadyProcessedItem = new THashSet<>();
	if(myRecursiveGuardSet != null)
	{
		alreadyProcessedItem.addAll(myRecursiveGuardSet);
	}
	return getSuperContextImpl(alreadyProcessedItem);
}
 
Example 5
Source File: VcsDirtyScopeImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Set<FilePath> getDirtyFilesNoExpand() {
  final THashSet<FilePath> paths = newFilePathsSet();
  for (THashSet<FilePath> filePaths : myDirtyFiles.values()) {
    paths.addAll(filePaths);
  }
  return paths;
}
 
Example 6
Source File: VcsDirtyScopeImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Set<FilePath> getRecursivelyDirtyDirectories() {
  THashSet<FilePath> result = newFilePathsSet();
  for (THashSet<FilePath> dirsByRoot : myDirtyDirectoriesRecursively.values()) {
    result.addAll(dirsByRoot);
  }
  return result;
}
 
Example 7
Source File: SegmentLargeUnlabeledSet.java    From semafor-semantic-parser with GNU General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) {
	FNModelOptions options = 
		new FNModelOptions(args);
	String inFile = options.trainParseFile.get();
	RequiredDataForFrameIdentification r = 
		(RequiredDataForFrameIdentification)SerializedObjects.readSerializedObject(options.fnIdReqDataFile.get());
	THashSet<String> allRelatedWords = r.getAllRelatedWords();
	THashSet<String> predicateSet = new THashSet<String>();
	try {
		BufferedReader bReader = 
			new BufferedReader(new FileReader(inFile));
		for (int i = 0; i < 1000000; i = i + 1000) {
			ArrayList<String> tokenNums = new ArrayList<String>();
			ArrayList<String> parses = new ArrayList<String>();
			for (int j = i; j < i + 1000; j ++) {
				String line = bReader.readLine();
				line = line.trim();
				parses.add(line);
				tokenNums.add(""+(j-i));
			}
			RoteSegmenter seg = new RoteSegmenter();
			ArrayList<String> segs = seg.findSegmentationForTest(tokenNums, parses, allRelatedWords);
			ArrayList<String> modified = ParseUtils.getRightInputForFrameIdentification(segs);
			Set<String> setOfWords = getSetOfWords(modified, parses);
			predicateSet.addAll(setOfWords);
			MoreRelaxedSegmenter seg2 = new MoreRelaxedSegmenter();
			segs = seg2.findSegmentationForTest(tokenNums, parses, allRelatedWords);
			modified = ParseUtils.getRightInputForFrameIdentification(segs);
			setOfWords = getSetOfWords(modified, parses);
			predicateSet.addAll(setOfWords);
			System.out.println("Done:"+(i+1000));
		}
		bReader.close();
	} catch (IOException e) {
		e.printStackTrace();
		System.exit(-1);
	}
	String[] arr = new String[predicateSet.size()];
	predicateSet.toArray(arr);
	Arrays.sort(arr);
	System.out.println("Size of arr:" + arr.length);
	ArrayList<String> list = new ArrayList<String>();
	for (String a: arr) {
		list.add(a);
	}
	ParsePreparation.writeSentencesToTempFile(options.outputPredicatesFile.get(), list);
}
 
Example 8
Source File: WordNetRelations.java    From semafor-semantic-parser with GNU General Public License v3.0 4 votes vote down vote up
private THashMap<String, Set<String>> collapseFinerRelations(Map<RelationType, Set<String>> rel)
{
	THashMap<String,Set<String>> result = new THashMap<String,Set<String>>();
	THashSet<String> identity = new THashSet<String>();
	THashSet<String> synonym = new THashSet<String>();
	THashSet<String> antonym = new THashSet<String>();
	THashSet<String> hypernym = new THashSet<String>();
	THashSet<String> hyponym = new THashSet<String>();
	THashSet<String> derivedForm = new THashSet<String>();
	THashSet<String> morphSet = new THashSet<String>();
	THashSet<String> verbGroup = new THashSet<String>();
	THashSet<String> entailment = new THashSet<String>();
	THashSet<String> entailedBy = new THashSet<String>();
	THashSet<String> seeAlso = new THashSet<String>();
	THashSet<String> causalRelation = new THashSet<String>();
	THashSet<String> sameNumber = new THashSet<String>();
	
	identity.addAll(rel.get(RelationType.idty));
	synonym.addAll(rel.get(RelationType.synm)); synonym.addAll(rel.get(RelationType.syn2));
	antonym.addAll(rel.get(RelationType.antm)); antonym.addAll(rel.get(RelationType.extd)); antonym.addAll(rel.get(RelationType.indi));
	hypernym.addAll(rel.get(RelationType.hype));
	hyponym.addAll(rel.get(RelationType.hypo));
	derivedForm.addAll(rel.get(RelationType.derv));
	morphSet.addAll(rel.get(RelationType.morph));
	verbGroup.addAll(rel.get(RelationType.vgrp));
	entailment.addAll(rel.get(RelationType.entl));
	entailedBy.addAll(rel.get(RelationType.entlby));
	seeAlso.addAll(rel.get(RelationType.alsoc));
	causalRelation.addAll(rel.get(RelationType.cause));
	if(sourceWord==null)
	{
		System.out.println("Problem. Source Word Null. Exiting");
		System.exit(0);
	}
	if(sourceWord.charAt(0)>='0'&&sourceWord.charAt(0)<='9')
		sameNumber.add(sourceWord);
	
	
	result.put("identity",identity);
	result.put("synonym",synonym);
	result.put("antonym",antonym);
	result.put("hypernym",hypernym);
	result.put("hyponym",hyponym);
	result.put("derived-form",derivedForm);
	result.put("morph",morphSet);
	result.put("verb-group",verbGroup);
	result.put("entailment",entailment);
	result.put("entailed-by",entailedBy);
	result.put("see-also",seeAlso);
	result.put("causal-relation",causalRelation);
	result.put("same-number", sameNumber);
	
	return result;
}