private void initIFDS() {
Scene.v().setCallGraph(new CallGraph());
this.jumpFunctions = new JumpFunctions<Unit,FlowAbstraction,IFDSSolver.BinaryDomain>(IFDSSolver.getAllTop());
this.endSum = HashBasedTable.create();
this.inc = HashBasedTable.create();
this.icfg = new JitIcfg(new ArrayList<SootMethod>()) {
@Override
public Set<SootMethod> getCalleesOfCallAt(Unit u) {
if (currentTask != null)
return currentTask.calleesOfCallAt(u);
else // Empty by default (same behavIoUr as L1)
return new HashSet<SootMethod>();
}
};
this.reporter.setIFDS(icfg,jumpFunctions);
}
private static Table<String,String,String> loadSHRMapping() {
if (!USE_SHR_EXTENSIONS) {
// don't bother creating the table unless we need it
return null;
}
Table<String,String> mappingTable = HashBasedTable.create();
List<LinkedHashMap<String,String>> csvData;
try {
csvData = SimpleCSV.parse(Utilities.readResource("shr_mapping.csv"));
} catch (IOException e) {
e.printstacktrace();
return null;
}
for (LinkedHashMap<String,String> line : csvData) {
String system = line.get("SYstem");
String code = line.get("CODE");
String url = line.get("URL");
mappingTable.put(system,code,url);
}
return mappingTable;
}
项目:powsybl-core
文件:MathUtil.java
public static Table<String,Float> parseMatrix(Reader reader) throws IOException {
Table<String,Float> table = HashBasedTable.create();
try (ICsvListReader csvReader = new CsvListReader(reader,CsvPreference.STANDARD_PREFERENCE)) {
List<String> columnHeaders = csvReader.read();
List<String> row;
while ((row = csvReader.read()) != null) {
String rowHeader = row.get(0);
for (int i = 1; i < row.size(); i++) {
String columnHeader = columnHeaders.get(i);
String value = row.get(i);
table.put(rowHeader,columnHeader,value == null ? Float.NaN : Float.parseFloat(value));
}
}
}
return table;
}
/**
* 将配置项构造成一个二维表,[配置名称,Profile ID,配置项]
*
* @param configItemList
* @return
*/
private Table<String,Integer,List<BuildConfigItem>> getConfigItemTable(List<BuildConfigItem> configItemList) {
Table<String,List<BuildConfigItem>> configItemTable = HashBasedTable.create();
List<BuildConfigItem> listByNameAndProfile = null;
for (BuildConfigItem configItem : configItemList) {
listByNameAndProfile = configItemTable.get(configItem.getConfigName(),configItem.getProfileId());
if (listByNameAndProfile == null) {
listByNameAndProfile = new ArrayList<>();
configItemTable.put(configItem.getConfigName(),configItem.getProfileId(),listByNameAndProfile);
}
listByNameAndProfile.add(configItem);
}
return configItemTable;
}
项目:hue
文件:PlanGenerator.java
private List<Optimizedplan> getPlansForDimensions() {
cm.sortForDimensions();
HashBasedTable<Table,Expressible,PlanPath> matrix = cm.getMatrix();
ArrayList<Table> sk = cm.getSortedKeys();
logger.debug(cm.toString());
List<Expressible> dims = matrix.columnKeySet().stream().filter((vn) -> {
return (vn instanceof Dimension);
}).collect(Collectors.toList());
Optimizedplan op = new Optimizedplan();
int count = 0;
double cost = 0;
for(Entry<Expressible,PlanPath> v : matrix.row(sk.get(0)).entrySet()){
dims.remove(v.getKey());
op.addpath(v.getValue());
cost += v.getValue().getCost();
count++;
}
op.setPlanCost(cost/count);
op.adddisjointedplans(getdisjoinPlans(dims,op));
return Lists.newArrayList(op);
}
public void buildPropertyValueTable(Map<Map<IProperty,Comparable>,BlockState.StateImplementation> map)
{
if (this.propertyValueTable != null)
{
throw new IllegalStateException();
}
else
{
Table<IProperty,Comparable,IBlockState> table = HashBasedTable.<IProperty,IBlockState>create();
for (IProperty <? extends Comparable > iproperty : this.properties.keySet())
{
for (Comparable comparable : iproperty.getAllowedValues())
{
if (comparable != this.properties.get(iproperty))
{
table.put(iproperty,comparable,map.get(this.getPropertiesWithValue(iproperty,comparable)));
}
}
}
this.propertyValueTable = ImmutableTable.<IProperty,IBlockState>copyOf(table);
}
}
项目:BaseClient
文件:BlockState.java
public void buildPropertyValueTable(Map<Map<IProperty,IBlockState>copyOf(table);
}
}
项目:MicroServiceProject
文件:SparseTensor.java
/**
* retrieve a rating matrix from the tensor. Warning: it assumes there is at most one entry for each (user,item)
* pair.
*
* @return a sparse rating matrix
*/
public SparseMatrix rateMatrix() {
Table<Integer,Double> dataTable = HashBasedTable.create();
Multimap<Integer,Integer> colMap = HashMultimap.create();
for (TensorEntry te : this) {
int u = te.key(userDimension);
int i = te.key(itemDimension);
dataTable.put(u,i,te.get());
colMap.put(i,u);
}
return new SparseMatrix(dimensions[userDimension],dimensions[itemDimension],dataTable,colMap);
}
项目:url-classifier
文件:MediaTypeClassifierBuilder.java
MediaTypeClassifierImpl(Iterable<? extends MediaType> mts) {
Table<String,Set<MediaType>> typeTable =
HashBasedTable.<String,Set<MediaType>>create();
for (MediaType mt : mts) {
String type = mt.type();
String subtype = mt.subtype();
Set<MediaType> typeSet = typeTable.get(type,subtype);
if (typeSet == null) {
typeSet = Sets.newLinkedHashSet();
typeTable.put(type,subtype,typeSet);
}
typeSet.add(mt);
}
ImmutableTable.Builder<String,ImmutableSet<MediaType>> b =
ImmutableTable.builder();
for (Table.Cell<String,Set<MediaType>> cell
: typeTable.cellSet()) {
b.put(cell.getRowKey(),cell.getColumnKey(),ImmutableSet.copyOf(cell.getValue()));
}
this.types = b.build();
}
项目:cakes
文件:HashBasedTableDemo.java
@Test
public void testCreate() {
HashBasedTable<String,String> table = HashBasedTable.create();
table.put("cbooy","vm","10.94.97.94");
table.put("cbooy","name","haoc");
table.put("hello","hi");
table.put("hello","10999");
System.out.println(table);
// 遍历
table.cellSet().forEach(cell -> {
String columnKey = cell.getColumnKey();
String rowKey = cell.getRowKey();
String value = cell.getValue();
System.out.println(String.format("%s-%s-%s",rowKey,columnKey,value));
});
}
项目:dremio-oss
文件:ImmutableCollectionSerializers.java
public static void register(final Kryo kryo) {
// register list
final ImmutableListSerializer serializer = new ImmutableListSerializer();
kryo.register(ImmutableList.class,serializer);
kryo.register(ImmutableList.of().getClass(),serializer);
kryo.register(ImmutableList.of(Integer.valueOf(1)).getClass(),serializer);
kryo.register(ImmutableList.of(Integer.valueOf(1),Integer.valueOf(2),Integer.valueOf(3)).subList(1,2).getClass(),serializer);
kryo.register(ImmutableList.of().reverse().getClass(),serializer);
kryo.register(Lists.charactersOf("dremio").getClass(),serializer);
final HashBasedTable baseTable = HashBasedTable.create();
baseTable.put(Integer.valueOf(1),Integer.valueOf(3));
baseTable.put(Integer.valueOf(4),Integer.valueOf(5),Integer.valueOf(6));
ImmutableTable table = ImmutableTable.copyOf(baseTable);
kryo.register(table.values().getClass(),serializer);
}
项目:CustomWorldGen
文件:BlockStateContainer.java
public void buildPropertyValueTable(Map < Map < IProperty<?>,Comparable<? >>,BlockStateContainer.StateImplementation > map)
{
if (this.propertyValueTable != null)
{
throw new IllegalStateException();
}
else
{
Table < IProperty<?>,Comparable<?>,IBlockState > table = HashBasedTable. < IProperty<?>,IBlockState > create();
for (Entry < IProperty<?>,Comparable<? >> entry : this.properties.entrySet())
{
IProperty<?> iproperty = (IProperty)entry.getKey();
for (Comparable<?> comparable : iproperty.getAllowedValues())
{
if (comparable != entry.getValue())
{
table.put(iproperty,comparable)));
}
}
}
this.propertyValueTable = ImmutableTable. < IProperty<?>,IBlockState > copyOf(table);
}
}
项目:bioasq
文件:ClassifierPredictor.java
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
String candidateProviderName = UimaContextHelper
.getConfigParameterStringValue(context,"candidate-provider");
candidateProvider = ProviderCache.getProvider(candidateProviderName,CandidateProvider.class);
String scorerNames = UimaContextHelper.getConfigParameterStringValue(context,"scorers");
scorers = ProviderCache.getProviders(scorerNames,scorer.class).stream()
.map(scorer -> (scorer<? super T>) scorer).collect(toList());
String classifierName = UimaContextHelper.getConfigParameterStringValue(context,"classifier");
classifier = ProviderCache.getProvider(classifierName,ClassifierProvider.class);
if ((featureFilename = UimaContextHelper.getConfigParameterStringValue(context,"feature-file",null)) != null) {
feat2value = HashBasedTable.create();
}
}
项目:bioasq
文件:CVPredictLoader.java
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
String candidateProviderName = UimaContextHelper
.getConfigParameterStringValue(context,CandidateProvider.class);
// load cv
String cvPredictFile = UimaContextHelper.getConfigParameterStringValue(context,"cv-predict-file");
List<String> lines;
try {
lines = Resources.readLines(getClass().getResource(cvPredictFile),Charsets.UTF_8);
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
qid2uri2score = HashBasedTable.create();
lines.stream().map(line -> line.split("\t"))
.forEach(segs -> qid2uri2score.put(segs[0],segs[1],Double.parseDouble(segs[2])));
}
项目:asglogic
文件:TableSynthesis.java
protected EspressoTable createEspressoTable() {
int num = stategraph.getAllSignals().size();
if(resetname != null) {
num++;
}
int i = 0;
String[] inputs = new String[num];
if(resetname != null) {
inputs[i++] = resetname;
}
for(Signal sig : stategraph.getAllSignals()) {
inputs[i++] = sig.getName();
}
Table<EspressoTerm,Espressovalue> table = HashBasedTable.create();
fillTable(num,inputs,table);
return new EspressoTable(inputs,table);
}
项目:factions-top
文件:ChunkLoader.java
private Table<Integer,Material,Integer> loadChunkMaterial() throws sqlException {
Table<Integer,Integer> target = HashBasedTable.create();
ResultSet resultSet = selectChunkMaterial.executeQuery();
while (resultSet.next()) {
int id = resultSet.getInt("id");
int chunkId = resultSet.getInt("chunk_id");
int materialId = resultSet.getInt("material_id");
int count = resultSet.getInt("count");
identityCache.setChunkMaterialId(chunkId,materialId,id);
identityCache.getMaterial(materialId).ifPresent(material ->
target.put(chunkId,material,count));
}
resultSet.close();
return target;
}
项目:factions-top
文件:ChunkLoader.java
private Table<Integer,EntityType,Integer> loadChunkSpawner() throws sqlException {
Table<Integer,Integer> target = HashBasedTable.create();
ResultSet resultSet = selectChunkSpawner.executeQuery();
while (resultSet.next()) {
int id = resultSet.getInt("id");
int chunkId = resultSet.getInt("chunk_id");
int spawnerId = resultSet.getInt("spawner_id");
int count = resultSet.getInt("count");
identityCache.setChunkSpawnerId(chunkId,spawnerId,id);
identityCache.getSpawner(spawnerId).ifPresent(spawner ->
target.put(chunkId,spawner,WorthType,Double> loadChunkWorth() throws sqlException {
Table<Integer,Double> target = HashBasedTable.create();
ResultSet resultSet = selectChunkWorth.executeQuery();
while (resultSet.next()) {
int id = resultSet.getInt("id");
int chunkId = resultSet.getInt("chunk_id");
int worthId = resultSet.getInt("worth_id");
double worth = resultSet.getDouble("worth");
identityCache.setChunkWorthId(chunkId,worthId,id);
identityCache.getWorthType(worthId).ifPresent(worthType ->
target.put(chunkId,worthType,worth));
}
resultSet.close();
return target;
}
private Table<String,ResourceType,Response<Map<String,String>>> getAllFromredis(Set<String> userIds) {
if (userIds.size() == 0) {
return HashBasedTable.create();
}
try (Jedis jedis = jedisSource.getJedis()) {
Table<String,String>>> responseTable =
ArrayTable.create(userIds,new ArrayIterator<>(ResourceType.values()));
Pipeline p = jedis.pipelined();
for (String userId : userIds) {
for (ResourceType r : ResourceType.values()) {
responseTable.put(userId,r,p.hgetAll(userKey(userId,r)));
}
}
p.sync();
return responseTable;
} catch (Exception e) {
log.error("Storage exception reading all entries.",e);
}
return null;
}
RunningContainers(twillRuntimeSpecification twillRuntimeSpec,String appId,twillRunResources appMasterResources,ZKClient zookeeperClient,Location applicationLocation,Map<String,RuntimeSpecification> runnables,EventHandler eventHandler) {
containers = HashBasedTable.create();
runnableInstances = Maps.newHashMap();
completedContainerCount = Maps.newHashMap();
startSequence = Lists.newLinkedList();
containerLock = new reentrantlock();
containerChange = containerLock.newCondition();
resourceReport = new DefaultResourceReport(appId,appMasterResources);
zkClient = zookeeperClient;
containerStats = HashMultimap.create();
this.applicationLocation = applicationLocation;
this.runnableNames = runnables.keySet();
this.logLevels = new TreeMap<>();
this.maxRetries = Maps.newHashMap(twillRuntimeSpec.getMaxRetries());
this.numRetries = Maps.newHashMap();
this.eventHandler = eventHandler;
}
/**
* Creates an instance.
*
* @param config Configuration of the yarn cluster
* @param zkConnect ZooKeeper connection string
* @param locationFactory Factory to create {@link Location} instances that are readable and writable by this service
*/
public YarntwillRunnerService(YarnConfiguration config,String zkConnect,LocationFactory locationFactory) {
this.yarnConfig = config;
this.locationFactory = locationFactory;
this.zkClientService = getZKClientService(zkConnect);
this.controllers = HashBasedTable.create();
this.serviceDelegate = new AbstractIdleService() {
@Override
protected void startUp() throws Exception {
YarntwillRunnerService.this.startUp();
}
@Override
protected void shutDown() throws Exception {
YarntwillRunnerService.this.shutDown();
}
};
}
项目:excel2javabeans
文件:ExcelImages.java
private static Table<Integer,ImageData> readAllCellImages(hssfPatriarch patriarch,Sheet sheet) {
val images = HashBasedTable.<Integer,ImageData>create();
val allPictures = sheet.getWorkbook().getAllPictures();
for (val shape : patriarch.getChildren()) {
if (!(shape instanceof hssfPicture && shape.getAnchor() instanceof hssfClientAnchor)) continue;
val picture = (hssfPicture) shape;
val imageData = createImageData(allPictures.get(picture.getPictureIndex() - 1));
val axisRow = computeAxisRowIndex(sheet,picture);
val axisCol = computeAxisColIndex(sheet,picture);
images.put(axisRow,axisCol,imageData);
}
return images;
}
项目:excel2javabeans
文件:ExcelImages.java
private static Table<Integer,ImageData> readAllCellImages(XSSfdrawing drawing,ImageData>create();
for (val shape : drawing.getShapes()) {
if (!(shape instanceof XSSFPicture)) continue;
val picture = (XSSFPicture) shape;
val imageData = createImageData(picture.getPictureData());
val axisRow = computeAxisRowIndex(sheet,imageData);
}
return images;
}
项目:hybris-connector
文件:GenderProvider.java
@Override
protected HashBasedTable<Optional<String>,Optional<Locale>,String> getAttributeValue(final Collection<Locale> locales,final ProductModel product,final MetaAttributeData MetaAttribute)
{
final HashBasedTable<Optional<String>,String> table = HashBasedTable.create();
if (product instanceof ApparelProductModel)
{
final List<Gender> genders = ((ApparelProductModel) product).getGenders();
if (genders != null && !genders.isEmpty())
{
for (final Gender gender : genders)
{
addValues(table,null,gender.getCode(),MetaAttribute);
}
}
}
return table;
}
项目:hybris-connector
文件:AbstractAttributeProvider.java
@Override
public Collection<FhAttributeData> getAttribute(final ProductModel product,final MetaAttributeData MetaAttribute,final Collection<Locale> locales)
{
final HashBasedTable<Optional<String>,String> values = getAttributeValue(locales,product,MetaAttribute);
if (values != null && !values.isEmpty())
{
final FhAttributeData attributeData = new FhAttributeData(MetaAttribute.getBaseType());
attributeData.setAttributeId(MetaAttribute.getAttributeId());
attributeData.setItemId(getSanitizeIdStrategy().sanitizeId(product.getCode()));
attributeData.setValues(values);
return Arrays.asList(attributeData);
}
return Collections.emptyList();
}
项目:hybris-connector
文件:ImageUrlProvider.java
@Override
protected HashBasedTable<Optional<String>,String> table = HashBasedTable.create();
final MediaFormatModel mediaFormatModel = getMediaService().getFormat(getMediaFormat());
if (mediaFormatModel != null)
{
final MediaModel media = findMedia(product,mediaFormatModel);
if (media != null)
{
addValues(table,media.getURL(),MetaAttribute);
}
}
return table;
}
@Override
public Collection<sqlInjectionAnalyzerEntry> getEntries() throws IOException {
failIfClosed();
List<sqlInjectionAnalyzerEntry> uncombinedEntries = getUncombinedEntriesFromDB();
Table<String,sqlInjectionAnalyzerEntry> buffer = HashBasedTable.create();
uncombinedEntries.stream()
.forEach((e) -> {
sqlInjectionAnalyzerEntry oldEntry = buffer.get(e.getEntryPoint(),e.getStatement());
if (oldEntry != null) {
oldEntry.mergeStatementCall(e);
} else {
buffer.put(e.getEntryPoint(),e.getStatement(),e);
}
});
return Collections.unmodifiableCollection(buffer.values());
}
项目:beam
文件:ApexStateInternals.java
@Override
public ApexStateInternals<K> stateInternalsForKey(K key) {
final Slice keyBytes;
try {
keyBytes = (key != null) ? new Slice(CoderUtils.encodetoByteArray(keyCoder,key)) :
new Slice(null);
} catch (CoderException e) {
throw new RuntimeException(e);
}
HashBasedTable<String,byte[]> stateTable = perKeyState.get(keyBytes);
if (stateTable == null) {
stateTable = HashBasedTable.create();
perKeyState.put(keyBytes,stateTable);
}
return new ApexStateInternals<>(key,stateTable);
}
项目:guava-demo
文件:TableSample.java
public static void main(String[] args) {
String[] names = {"Bob","Alice","Andy","Carol","Ben"};
// Table of names
Table<Character,String> table = HashBasedTable.create();
// First letter is a row key,length is a column key
for (String name : names) {
table.put(name.charat(0),name.length(),name);
}
// Value corresponding to the given row and column keys
table.get('A',5); // -> Alice
table.get('B',3); // -> Ben
// Set of column keys that have one or more values in the table
table.columnKeySet(); // -> [4,5,3]
// View of all mappings that have the given row key
table.row('A'); // -> {4=Andy,5=Alice}
}
项目:turnus
文件:TraceEvaluator.java
/**
* Constructor. Create a new trace builder.
*
* @param traceFile
* @throws TurnusException
*/
public TraceEvaluator(Network network,File traceFile) throws TurnusException {
try {
writer = new TraceWriter(traceFile);
writer.start();
} catch (TurnusException e) {
throw e;
}
this.network = network;
lastSharedVarStore = new HashMap<>();
lastSharedVarLoad = new HashMap<>();
lastScheduledFsm = new HashMap<>();
lastvarStore = HashBasedTable.create();
lastvarLoad = HashBasedTable.create();
lastPortWrite = HashBasedTable.create();
lastPortRead = HashBasedTable.create();
actionsFirings = HashMultiset.create();
actionsIncomings = HashMultiset.create();
actionsOutgoings = HashMultiset.create();
dependenciesKind = HashMultiset.create();
}
项目:turnus
文件:AverageTraceWeighter.java
/**
* Create a weighter (average values) given the network weights
*
* @param networkWeights
*/
public AverageTraceWeighter(NetworkWeight networkWeights) {
this.networkWeights = networkWeights;
weightTable = HashBasedTable.create();
varianceTable = HashBasedTable.create();
for (Cell<String,ClockCycles> cell : networkWeights.asTable().cellSet()) {
String actor = cell.getRowKey();
String action = cell.getColumnKey();
ClockCycles w = cell.getValue();
double avg = w.getMeanClockCycles();
double min = Math.min(w.getMinClockCycles(),avg);
double max = Math.max(avg,w.getMaxClockCycles());
double variance = Math.pow(((max - min) / 6.0),2);
weightTable.put(actor,action,avg);
varianceTable.put(actor,variance);
}
}
/**
* Create a normal distribution weighter given the network weights
*
* @param networkWeights
*/
public normaldistributionTraceWeighter(NetworkWeight networkWeights) {
this.networkWeights = networkWeights;
weightTable = HashBasedTable.create();
varianceTable = HashBasedTable.create();
for (Cell<String,w.getMaxClockCycles());
double weight = (min + 4 * avg + max) / 6.0;
double variance = Math.pow(((max - min) / 6.0),weight);
varianceTable.put(actor,variance);
}
}
项目:ALEA
文件:SpliceJunctionHelper.java
/**
* Combine junctions from both strands. Used for Sashimi plot.
* Note: Flanking depth arrays are not combined.
*/
private List<SpliceJunctionFeature> combinestrandJunctionsMaps() {
// Start with all + junctions
Table<Integer,SpliceJunctionFeature> combinedStartEndJunctionsMap = HashBasedTable.create(posstartEndJunctionsMap);
// Merge in - junctions
for (Table.Cell<Integer,SpliceJunctionFeature> negJunctionCell : negStartEndJunctionsMap.cellSet()) {
int junctionStart = negJunctionCell.getRowKey();
int junctionEnd = negJunctionCell.getColumnKey();
SpliceJunctionFeature negFeat = negJunctionCell.getValue();
SpliceJunctionFeature junction = combinedStartEndJunctionsMap.get(junctionStart,junctionEnd);
if (junction == null) {
// No existing (+) junction here,just add the (-) one\
combinedStartEndJunctionsMap.put(junctionStart,junctionEnd,negFeat);
} else {
int newJunctionDepth = junction.getJunctionDepth() + negFeat.getJunctionDepth();
junction.setJunctionDepth(newJunctionDepth);
}
}
return new ArrayList<SpliceJunctionFeature>(combinedStartEndJunctionsMap.values());
}
protected static Table<Character,Character,Character> getDegeneracyTable() {
if (degeneracyTable == null) {
degeneracyTable = HashBasedTable.create(5,5);
Map<String,String> iupacMap = ParsingUtils.loadIUPACMap();
for (String s : iupacMap.values()) {
s = s.replace("[","").replace("]","").toLowerCase();
//System.out.println(s);
String[] tokens = s.split(",");
if (tokens.length != 3) continue;
char a = tokens[1].trim().charat(0);
char b = tokens[2].trim().charat(0);
char c = tokens[0].trim().charat(0);
degeneracyTable.put(a,b,c);
degeneracyTable.put(b,a,c);
}
}
return degeneracyTable;
}
项目:keystone4j
文件:FileScanner.java
public Table<Type,String> read() throws IOException {
logger.debug("Readig from file.");
Table<Type,String> table = HashBasedTable.create();
Scanner scanner = new Scanner(url.openStream());
try {
Config.Type type = Config.Type.keystone_authtoken;
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if (!line.startsWith("#") && !line.isEmpty()) {
if (line.startsWith("[") && line.endsWith("]")) {
type = Config.Type.valueOf(line.substring(1,line.length() - 1));
continue;
}
String[] split = line.split("=",2);
if (split.length == 2) {
table.put(type,split[0].trim(),split[1].trim());
}
}
}
} finally {
scanner.close();
}
logger.debug("Text read in: " + table);
return table;
}
项目:keystone4j
文件:FileScanner.java
public Table<Type,String> table = HashBasedTable.create();
Scanner scanner = new Scanner(url.openStream());
try {
Config.Type type = Config.Type.DEFAULT;
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if (!line.startsWith("#") && !line.isEmpty()) {
if (line.startsWith("[") && line.endsWith("]")) {
type = Config.Type.valueOf(line.substring(1,split[1].trim());
}
}
}
} finally {
scanner.close();
}
logger.debug("Text read in: " + table);
return table;
}
项目:recalot.com
文件:SparseTensor.java
项目:EasySRL
文件:ChartCell.java
public ChartCellNbestFactory(final int nbest,final double nbestBeam,final int maxSentenceLength,final Collection<Category> categories) {
super();
this.nbest = nbest;
this.nbestBeam = nbestBeam;
final Random randomGenerator = new Random();
// Build a hash for every possible dependency
categoryToArgumentToHeadToModifierToHash = HashBasedTable.create();
for (final Category c : categories) {
for (int i = 1; i <= c.getNumberOfArguments(); i++) {
final int[][] array = new int[maxSentenceLength][maxSentenceLength];
categoryToArgumentToHeadToModifierToHash.put(c,array);
for (int head = 0; head < maxSentenceLength; head++) {
for (int child = 0; child < maxSentenceLength; child++) {
array[head][child] = randomGenerator.nextInt();
}
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。