gnu.trove.THashMap Java Examples

The following examples show how to use gnu.trove.THashMap. 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: PaperEvaluation.java    From semafor-semantic-parser with GNU General Public License v3.0 6 votes vote down vote up
public static void convertGoldTestToFramesFile()
{
	String goldFile = malRootDir+"/testdata/johansson.fulltest.sentences.frames";
	String outFile = malRootDir+"/FrameStructureExtraction/release/temp_johansson_full/file.frame.elements";
	ArrayList<String> inLines = ParsePreparation.readSentencesFromFile(goldFile);
	ArrayList<String> outLines = new ArrayList<String>();
	THashMap<String,THashSet<String>> frameMap = (THashMap<String,THashSet<String>>)SerializedObjects.readSerializedObject("lrdata/framenet.original.map");
	for(String inLine: inLines)
	{	
		String[] toks = inLine.split("\t");
		if(!frameMap.contains(toks[0]))
				continue;
		String outLine = "1\t"+toks[0]+"\t"+toks[1]+"\t"+toks[2]+"\t"+toks[3]+"\t"+toks[4];
		outLines.add(outLine);
	}
	ParsePreparation.writeSentencesToTempFile(outFile, outLines);
}
 
Example #2
Source File: FixTokenization.java    From semafor-semantic-parser with GNU General Public License v3.0 6 votes vote down vote up
public static void fixTokenization(String inputFile, String outputFile, THashMap<String, String> conv)
{
	try
	{
		BufferedReader bReader = new BufferedReader(new FileReader(inputFile));
		BufferedWriter bWriter = new BufferedWriter(new FileWriter(outputFile));
		String line = null;
		while((line=bReader.readLine())!=null)
		{	
			line = line.trim();
			System.out.println(line);
			line = fixDoubleQuotes(line,conv);
			line = fixOpeningQuote(line,conv);
			line = fixClosingQuote(line,conv);
			bWriter.write(line+"\n");
		}			
		bReader.close();
		bWriter.close();
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}		
}
 
Example #3
Source File: StdArrangementExtendableSettings.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public List<ArrangementSectionRule> getExtendedSectionRules() {
  synchronized (myExtendedSectionRules) {
    if (myExtendedSectionRules.isEmpty()) {
      final Map<String, StdArrangementRuleAliasToken> tokenIdToDefinition = new THashMap<String, StdArrangementRuleAliasToken>(myRulesAliases.size());
      for (StdArrangementRuleAliasToken alias : myRulesAliases) {
        final String id = alias.getId();
        tokenIdToDefinition.put(id, alias);
      }

      final List<ArrangementSectionRule> sections = getSections();
      for (ArrangementSectionRule section : sections) {
        final List<StdArrangementMatchRule> extendedRules = new ArrayList<StdArrangementMatchRule>();
        for (StdArrangementMatchRule rule : section.getMatchRules()) {
          appendExpandedRules(rule, extendedRules, tokenIdToDefinition);
        }
        myExtendedSectionRules.add(ArrangementSectionRule.create(section.getStartComment(), section.getEndComment(), extendedRules));
      }
    }
  }
  return myExtendedSectionRules;
}
 
Example #4
Source File: WSLDistribution.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * @return environment map of the default user in wsl
 */
@Nonnull
public Map<String, String> getEnvironment() {
  try {
    ProcessOutput processOutput = executeOnWsl(5000, "env");
    Map<String, String> result = new THashMap<>();
    for (String string : processOutput.getStdoutLines()) {
      int assignIndex = string.indexOf('=');
      if (assignIndex == -1) {
        result.put(string, "");
      }
      else {
        result.put(string.substring(0, assignIndex), string.substring(assignIndex + 1));
      }
    }
    return result;
  }
  catch (ExecutionException e) {
    LOG.warn(e);
  }

  return Collections.emptyMap();
}
 
Example #5
Source File: LocalFileSystemRefreshWorker.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * @param fileOrDir
 * @param refreshContext
 * @param childrenToRefresh  null means all
 * @param existingPersistentChildren
 */
RefreshingFileVisitor(@Nonnull NewVirtualFile fileOrDir,
                      @Nonnull RefreshContext refreshContext,
                      @Nullable Collection<String> childrenToRefresh,
                      @Nonnull Collection<? extends VirtualFile> existingPersistentChildren) {
  myFileOrDir = fileOrDir;
  myRefreshContext = refreshContext;
  myPersistentChildren = new THashMap<>(existingPersistentChildren.size(), refreshContext.strategy);
  myChildrenWeAreInterested = childrenToRefresh == null ? null : new THashSet<>(childrenToRefresh, refreshContext.strategy);

  for (VirtualFile child : existingPersistentChildren) {
    String name = child.getName();
    myPersistentChildren.put(name, child);
    if (myChildrenWeAreInterested != null) myChildrenWeAreInterested.add(name);
  }
}
 
Example #6
Source File: PermissionIndex.java    From idea-php-drupal-symfony2-bridge with MIT License 6 votes vote down vote up
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {

    return inputData -> {

        Map<String, Void> map = new THashMap<>();

        PsiFile psiFile = inputData.getPsiFile();
        if(!(psiFile instanceof YAMLFile) || !psiFile.getName().endsWith(".permissions.yml")) {
            return map;
        }

        for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) {
            String keyText = yamlKeyValue.getKeyText();
            if(StringUtils.isBlank(keyText)) {
                continue;
            }

            map.put(keyText, null);
        }

        return map;
    };
}
 
Example #7
Source File: TwigIncludeStubIndex.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return inputData -> {
        final Map<String, Void> map = new THashMap<>();

        PsiFile psiFile = inputData.getPsiFile();
        if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
            return map;
        }

        if(!(psiFile instanceof TwigFile)) {
            return map;
        }

        TwigUtil.visitTemplateIncludes((TwigFile) psiFile, templateInclude ->
            map.put(TwigUtil.normalizeTemplateName(templateInclude.getTemplateName()), null)
        );

        return map;
    };

}
 
Example #8
Source File: BladeStackStubIndex.java    From idea-php-laravel-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return fileContent -> {
        final Map<String, Void> map = new THashMap<>();
        PsiFile psiFile = fileContent.getPsiFile();

        if(!(psiFile instanceof BladeFileImpl)) {
            return map;
        }

        psiFile.acceptChildren(new BladeDirectivePsiElementWalkingVisitor(BladeTokenTypes.STACK_DIRECTIVE, map));

        return map;
    };
}
 
Example #9
Source File: ThisKindProcessor.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@Override
public void process(@Nonnull CSharpResolveOptions options,
		@Nonnull DotNetGenericExtractor defaultExtractor,
		@Nullable PsiElement forceQualifierElement,
		@Nonnull Processor<ResolveResult> processor)
{
	DotNetTypeDeclaration thisTypeDeclaration = PsiTreeUtil.getContextOfType(options.getElement(), DotNetTypeDeclaration.class);
	if(thisTypeDeclaration != null)
	{
		thisTypeDeclaration = CSharpCompositeTypeDeclaration.selectCompositeOrSelfType(thisTypeDeclaration);

		DotNetGenericExtractor genericExtractor = DotNetGenericExtractor.EMPTY;
		int genericParametersCount = thisTypeDeclaration.getGenericParametersCount();
		if(genericParametersCount > 0)
		{
			Map<DotNetGenericParameter, DotNetTypeRef> map = new THashMap<>(genericParametersCount);
			for(DotNetGenericParameter genericParameter : thisTypeDeclaration.getGenericParameters())
			{
				map.put(genericParameter, new CSharpTypeRefFromGenericParameter(genericParameter));
			}
			genericExtractor = CSharpGenericExtractor.create(map);
		}
		processor.process(new CSharpResolveResultWithExtractor(thisTypeDeclaration, genericExtractor));
	}
}
 
Example #10
Source File: LogLogisticRegressionModel.java    From semafor-semantic-parser with GNU General Public License v3.0 6 votes vote down vote up
protected void initializeParameterIndexes() {
	A = new Alphabet();
	V = new LDouble[PARAMETER_TABLE_INITIAL_CAPACITY];
	G = new LDouble[PARAMETER_TABLE_INITIAL_CAPACITY];
	m_trainingData = new ArrayList<TDoubleArrayList>(1000);
	m_trainingLabels = new TIntArrayList(1000);
	m_testData = new ArrayList<TDoubleArrayList>(100);
	m_testLabels = new TIntArrayList(100);
	m_devData = new ArrayList<TDoubleArrayList>(100);
	m_devLabels = new TIntArrayList(100);
	savedValues = new TObjectDoubleHashMap<String>(1000);
	m_savedFormulas = new ArrayList<LogFormula>(FORMULA_LIST_INITIAL_CAPACITY);
	m_current = 0;
	m_savedLLFormulas = new ArrayList<LazyLookupLogFormula>(LLFORMULA_LIST_INITIAL_CAPACITY);
	m_llcurrent = 0;
	mLookupChart = new THashMap<Integer,LogFormula>(PARAMETER_TABLE_INITIAL_CAPACITY);
}
 
Example #11
Source File: Win32FsCache.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
FileAttributes getAttributes(@Nonnull VirtualFile file) {
  VirtualFile parent = file.getParent();
  int parentId = parent instanceof VirtualFileWithId ? ((VirtualFileWithId)parent).getId() : -((VirtualFileWithId)file).getId();
  TIntObjectHashMap<THashMap<String, FileAttributes>> map = getMap();
  THashMap<String, FileAttributes> nestedMap = map.get(parentId);
  String name = file.getName();
  FileAttributes attributes = nestedMap != null ? nestedMap.get(name) : null;

  if (attributes == null) {
    if (nestedMap != null && !(nestedMap instanceof IncompleteChildrenMap)) {
      return null; // our info from parent doesn't mention the child in this refresh session
    }
    FileInfo info = myKernel.getInfo(file.getPath());
    if (info == null) {
      return null;
    }
    attributes = info.toFileAttributes();
    if (nestedMap == null) {
      nestedMap = new IncompleteChildrenMap<>(FileUtil.PATH_HASHING_STRATEGY);
      map.put(parentId, nestedMap);
    }
    nestedMap.put(name, attributes);
  }
  return attributes;
}
 
Example #12
Source File: PaperEvaluation.java    From semafor-semantic-parser with GNU General Public License v3.0 6 votes vote down vote up
public static void convertGoldJohanssonToFramesFile()
{
	String goldFile = malRootDir+"/testdata/semeval.fulltest.sentences.frame.elements";
	String outFile = malRootDir+"/testdata/file.frame.elements";
	ArrayList<String> inLines = ParsePreparation.readSentencesFromFile(goldFile);
	ArrayList<String> outLines = new ArrayList<String>();
	THashMap<String,THashSet<String>> frameMap = (THashMap<String,THashSet<String>>)SerializedObjects.readSerializedObject("lrdata/framenet.original.map");
	for(String inLine: inLines)
	{	
		String[] toks = inLine.split("\t");
		if(!frameMap.contains(toks[1]))
				continue;
		String outLine = "1\t"+toks[1]+"\t"+toks[2]+"\t"+toks[3]+"\t"+toks[4]+"\t"+toks[5];
		outLines.add(outLine);
	}
	ParsePreparation.writeSentencesToTempFile(outFile, outLines);
}
 
Example #13
Source File: AbstractCollectionBinding.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private synchronized Map<Class<?>, Binding> getElementBindings() {
  if (itemBindings == null) {
    Binding binding = XmlSerializerImpl.getBinding(itemType);
    if (annotation == null || annotation.elementTypes().length == 0) {
      itemBindings = binding == null ? Collections.<Class<?>, Binding>emptyMap() : Collections.<Class<?>, Binding>singletonMap(itemType, binding);
    }
    else {
      itemBindings = new THashMap<Class<?>, Binding>();
      if (binding != null) {
        itemBindings.put(itemType, binding);
      }
      for (Class aClass : annotation.elementTypes()) {
        Binding b = XmlSerializerImpl.getBinding(aClass);
        if (b != null) {
          itemBindings.put(aClass, b);
        }
      }
      if (itemBindings.isEmpty()) {
        itemBindings = Collections.emptyMap();
      }
    }
  }
  return itemBindings;
}
 
Example #14
Source File: UpdateFoldRegionsOperation.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
  EditorFoldingInfo info = EditorFoldingInfo.get(myEditor);
  FoldingModelEx foldingModel = (FoldingModelEx)myEditor.getFoldingModel();
  Map<TextRange, Boolean> rangeToExpandStatusMap = new THashMap<>();

  removeInvalidRegions(info, foldingModel, rangeToExpandStatusMap);

  Map<FoldRegion, Boolean> shouldExpand = new THashMap<>();
  Map<FoldingGroup, Boolean> groupExpand = new THashMap<>();
  List<FoldRegion> newRegions = addNewRegions(info, foldingModel, rangeToExpandStatusMap, shouldExpand, groupExpand);

  applyExpandStatus(newRegions, shouldExpand, groupExpand);

  foldingModel.clearDocumentRangesModificationStatus();
}
 
Example #15
Source File: LogicalRootsManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private synchronized  Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> getRoots(final ModuleManager moduleManager) {
  if (myRoots == null) {
    myRoots = new THashMap<Module, MultiValuesMap<LogicalRootType, LogicalRoot>>();

    final Module[] modules = moduleManager.getModules();
    for (Module module : modules) {
      final MultiValuesMap<LogicalRootType, LogicalRoot> map = new MultiValuesMap<LogicalRootType, LogicalRoot>();
      for (Map.Entry<LogicalRootType, Collection<NotNullFunction>> entry : myProviders.entrySet()) {
        final Collection<NotNullFunction> functions = entry.getValue();
        for (NotNullFunction function : functions) {
          map.putAll(entry.getKey(), (List<LogicalRoot>) function.fun(module));
        }
      }
      myRoots.put(module, map);
    }
  }

  return myRoots;
}
 
Example #16
Source File: HaxeSymbolIndex.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
@Override
@NotNull
public Map<String, Void> map(@NotNull final FileContent inputData) {
  final PsiFile psiFile = inputData.getPsiFile();
  final List<HaxeClass> classes = HaxeResolveUtil.findComponentDeclarations(psiFile);
  if (classes.isEmpty()) {
    return Collections.emptyMap();
  }
  final Map<String, Void> result = new THashMap<>();
  for (HaxeClass haxeClass : classes) {
    final String className = haxeClass.getName();
    if (className == null) {
      continue;
    }
    result.put(className, null);
    for (HaxeNamedComponent namedComponent : getNamedComponents(haxeClass)) {
      result.put(namedComponent.getName(), null);
    }
  }
  return result;
}
 
Example #17
Source File: BTreeEnumeratorTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void testAddEqualStringsAndMuchGarbage() throws IOException {
  final Map<Integer,String> strings = new THashMap<Integer, String>(10001);
  String s = "IntelliJ IDEA";
  final int index = myEnumerator.enumerate(s);
  strings.put(index, s);

  // clear strings and nodes cache
  for (int i = 0; i < 10000; ++i) {
    final String v = Integer.toString(i) + "Just another string";
    final int idx = myEnumerator.enumerate(v);
    assertEquals(v, myEnumerator.valueOf(idx));
    strings.put(idx, v);
  }

  for(Map.Entry<Integer, String> e:strings.entrySet()) {
    assertEquals((int)e.getKey(), myEnumerator.enumerate(e.getValue()));
  }

  final Set<String> enumerated = new HashSet<String>(myEnumerator.getAllDataObjects(null));
  assertEquals(new HashSet<String>(strings.values()), enumerated);
}
 
Example #18
Source File: ConfigEntityTypeAnnotationIndex.java    From idea-php-drupal-symfony2-bridge with MIT License 6 votes vote down vote up
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
    return inputData -> {
        final Map<String, String> map = new THashMap<>();

        PsiFile psiFile = inputData.getPsiFile();
        if(!(psiFile instanceof PhpFile)) {
            return map;
        }

        if(!IndexUtil.isValidForIndex(inputData, psiFile)) {
            return map;
        }

        psiFile.accept(new MyPsiRecursiveElementWalkingVisitor(map));

        return map;
    };
}
 
Example #19
Source File: ProduceLargerFrameDistribution.java    From semafor-semantic-parser with GNU General Public License v3.0 6 votes vote down vote up
public static THashMap<String, THashMap<String, Double>> 
	readTrainDistFile(String trainDistFile) {
	THashMap<String, THashMap<String, Double>> result = 
		new THashMap<String, THashMap<String, Double>>();
	ArrayList<String> sents = ParsePreparation.readSentencesFromFile(trainDistFile);
	for (String sent: sents) {
		sent = sent.trim();
		String[] toks = sent.split("\t");
		String pred = toks[0];
		String[] toks1 = toks[1].trim().split(" ");
		THashMap<String, Double> map = new THashMap<String, Double>();
			for (int i = 0; i < toks1.length; i = i + 2) {
			String frame = toks1[i];
			double prob = new Double(toks1[i+1]);
			map.put(frame, prob);
		}
			result.put(pred, map);
	}
	return result;
}
 
Example #20
Source File: MapInputDataDiffBuilder.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void processAllKeysAsDeleted(final RemovedKeyProcessor<? super Key> removeProcessor) throws StorageException {
  if (myMap instanceof THashMap) {
    final StorageException[] exception = new StorageException[]{null};
    ((THashMap<Key, Value>)myMap).forEachEntry(new TObjectObjectProcedure<Key, Value>() {
      @Override
      public boolean execute(Key k, Value v) {
        try {
          removeProcessor.process(k, myInputId);
        }
        catch (StorageException e) {
          exception[0] = e;
          return false;
        }
        return true;
      }
    });
    if (exception[0] != null) throw exception[0];
  }
  else {
    for (Key key : myMap.keySet()) {
      removeProcessor.process(key, myInputId);
    }
  }
}
 
Example #21
Source File: DefaultInspectionToolPresentation.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private Map<CommonProblemDescriptor, RefEntity> getProblemToElements() {
  synchronized (lock) {
    if (myProblemToElements == null) {
      myProblemToElements = Collections.synchronizedMap(new THashMap<CommonProblemDescriptor, RefEntity>());
    }
    return myProblemToElements;
  }
}
 
Example #22
Source File: EnvironmentUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static Map<String, String> getSystemEnv() {
  if (SystemInfo.isWindows) {
    return unmodifiableMap(new THashMap<String, String>(System.getenv(), CaseInsensitiveStringHashingStrategy.INSTANCE));
  }
  else {
    return System.getenv();
  }
}
 
Example #23
Source File: FixTokenization.java    From semafor-semantic-parser with GNU General Public License v3.0 5 votes vote down vote up
public static THashMap<String,String> readConversions(String file)
{
	ArrayList<String> list = ParsePreparation.readSentencesFromFile(file);
	int size = list.size();
	THashMap<String,String> map = new THashMap<String,String>();
	for(int i = 0; i < size; i ++)
	{
		StringTokenizer st = new StringTokenizer(list.get(i),"\t");
		String american = st.nextToken();
		String british = st.nextToken();
		map.put(british, american);
	}
	return map;
}
 
Example #24
Source File: TwigControllerStubIndex.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return inputData -> {
        PsiFile psiFile = inputData.getPsiFile();
        if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject()) || !(psiFile instanceof TwigFile)) {
            return Collections.emptyMap();
        }

        final Map<String, Void> map = new THashMap<>();
        TwigUtil.visitControllerFunctions(psiFile, pair -> map.put(pair.getFirst(), null));
        return map;
    };

}
 
Example #25
Source File: LexicalUnitsFrameExtraction.java    From semafor-semantic-parser with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Populates the given map object with frames (as keys) and sets of target words that evoke 
 * those frames in the given corresponding sentences (as values)
 * @param map
 * @param frames
 * @param sentences
 * @author dipanjan
 */
public static void fillMap(THashMap<String,THashSet<String>> map, ArrayList<String> frames, ArrayList<String> sentences)
{
	int size = frames.size();
	for(int i = 0; i < size; i ++)
	{
		String line = frames.get(i);
		String[] toks = line.split("\t");
		int sentenceNum = new Integer(toks[toks.length-1]);
		String storedSentence = sentences.get(sentenceNum);
		String frame = toks[0];
		String tokenNums = toks[2];
		String[] nums = tokenNums.split("_");
		String lexicalUnits = getTokens(storedSentence,nums);
		THashSet<String> set = map.get(frame);	
		if(set==null)
		{
			set = new THashSet<String>();
			set.add(lexicalUnits);
			map.put(frame, set);
		}
		else
		{
			if(!set.contains(lexicalUnits))
			{
				set.add(lexicalUnits);
			}
		}
	}
}
 
Example #26
Source File: RequiredDataCreation.java    From semafor-semantic-parser with GNU General Public License v3.0 5 votes vote down vote up
public static Map<String, String> getHVLemmas(FNModelOptions options) {
	String fmFile = options.frameNetMapFile.get();
	String wnConfigFile = options.wnConfigFile.get();
	String stopFile = options.stopWordsFile.get();
	THashMap<String, THashSet<String>> frameMap = 
		(THashMap<String, THashSet<String>>)
		SerializedObjects.readSerializedObject(fmFile);
	WordNetRelations wnr = new WordNetRelations(stopFile, wnConfigFile);
	Map<String, String> lemmaMap = new THashMap<String, String>();
	Set<String> keySet = frameMap.keySet();
	for(String frame: keySet)
	{
		THashSet<String> hus = frameMap.get(frame);
		for(String hUnit: hus)
		{
			String[] hiddenToks = hUnit.split(" ");
			String hiddenUnitTokens="";
			String hiddenUnitLemmas="";
			for(int i = 0; i < hiddenToks.length; i ++)
			{
				String[] arr = hiddenToks[i].split("_");
				hiddenUnitTokens+=arr[0]+" ";
				String lowerCaseLemma = wnr.getLemmaForWord(arr[0], arr[1]).toLowerCase();
				lemmaMap.put(arr[0] + "_" + arr[1], lowerCaseLemma);
				hiddenUnitLemmas+=wnr.getLemmaForWord(arr[0], arr[1]).toLowerCase()+" ";
			}
			hiddenUnitTokens=hiddenUnitTokens.trim();
			hiddenUnitLemmas=hiddenUnitLemmas.trim();
			System.out.println("Processed:"+hiddenUnitLemmas);
		}
	}
	SerializedObjects.writeSerializedObject(lemmaMap, options.lemmaCacheFile.get());
	return lemmaMap;
	
}
 
Example #27
Source File: ThriftDeclarationIndex.java    From intellij-thrift with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public Map<String, Void> map(FileContent inputData) {
  Map<String, Void> result = new THashMap<String, Void>();
  for (PsiElement child : inputData.getPsiFile().getChildren()) {
    if (child instanceof ThriftTopLevelDeclaration) {
      String name = ((ThriftDeclaration)child).getName();
      if (name != null) {
        result.put(name, null);
      }
    }
  }

  return result;
}
 
Example #28
Source File: Win32FsCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private TIntObjectHashMap<THashMap<String, FileAttributes>> getMap() {
  TIntObjectHashMap<THashMap<String, FileAttributes>> map = com.intellij.reference.SoftReference.dereference(myCache);
  if (map == null) {
    map = new TIntObjectHashMap<THashMap<String, FileAttributes>>();
    myCache = new SoftReference<TIntObjectHashMap<THashMap<String, FileAttributes>>>(map);
  }
  return map;
}
 
Example #29
Source File: LexicalUnitsFrameExtraction.java    From semafor-semantic-parser with GNU General Public License v3.0 5 votes vote down vote up
/**
 * From flat-text files with frame element occurrence information, 
 * creates a map from frame names to a set of names of frame element 
 * (argument) roles observed for that frame with overt fillers
 * and stores that map as a serialized object
 * @author Nathan Schneider (nschneid)
 */
public static void writeMapOfFrameElements() {
	String[] filePrefixes = {"lrdata/framenet.original", 
			"lrdata/semeval.fulltrain",
			"lrdata/semeval.fulldev",
			"lrdata/semeval.fulltest"};
	for (int j=0; j<filePrefixes.length; j++) {	// treat framenet.original, semeval.fulltrain, and semeval.fulldev separately
		String filePrefix = filePrefixes[j];
		
		String trainFrameElementsFile = filePrefix + ".sentences.frame.elements";
		String trainParseFile = filePrefix + ".sentences.all.tags";
		ArrayList<String> frameElementLines = ParsePreparation.readSentencesFromFile(trainFrameElementsFile);
		ArrayList<String> frameParseLines = ParsePreparation.readSentencesFromFile(trainParseFile);
		
		THashMap<String,THashSet<String>> framesToFEs = new THashMap<String,THashSet<String>>(/*new TObjectIdentityHashingStrategy<String>()*/);
		
		for (int l=0; l<frameElementLines.size()-1; l++) {
			String frameElementsLine = frameElementLines.get(l);
			int sentenceNum = Integer.parseInt(frameElementsLine.split("\t")[5]);
			//TODO: above should be = DataPointWithElements.parseFrameNameAndSentenceNum(frameElementsLine).getSecond();
			String frameParseLine = frameParseLines.get(sentenceNum);
			DataPointWithElements dp = new DataPointWithElements(frameParseLine, frameElementsLine);
			
			if (!framesToFEs.containsKey(dp.getFrameName())) {
				framesToFEs.put(dp.getFrameName(), new THashSet<String>(/*new TObjectIdentityHashingStrategy<String>()*/));
			}
			String[] feNames = dp.getOvertFilledFrameElementNames();
			for (String feName : feNames)
				framesToFEs.get(dp.getFrameName()).add(feName);
		}
		
		System.out.println(framesToFEs.size());
		String mapFile = filePrefix + ".frame.elements.map";
		SerializedObjects.writeSerializedObject(framesToFEs, mapFile);
	}
}
 
Example #30
Source File: JSColorSettings.java    From Custom-Syntax-Highlighter with MIT License 5 votes vote down vote up
private static Map<String, TextAttributesKey> createAdditionalHlAttrs() {
  final Map<String, TextAttributesKey> descriptors = new THashMap<>();
  descriptors.put("keyword", JSColorSettings.JSKEYWORD);
  descriptors.put("function", JSColorSettings.FUNCTION);
  descriptors.put("function_name", JSColorSettings.FUNCTION_NAME);
  descriptors.put("val", JSColorSettings.VAL);
  descriptors.put("local_variable", JSColorSettings.VARIABLE);
  descriptors.put("this", JSColorSettings.THIS_SUPER);
  descriptors.put("null", JSColorSettings.NULL);
  descriptors.put("debugger", JSColorSettings.DEBUGGER);
  descriptors.put("import", JSColorSettings.MODULE);

  return descriptors;
}