Some useful code for loading a triple file (in tab-delimited text format)

//--------------------------------------------------------------------------//
//--------------------------------------------------------------------------//
// Load the action sequences from the give file
//--------------------------------------------------------------------------//
//--------------------------------------------------------------------------//
	
	protected void loadActionSequences(String filename)
	{
		FileInputStream input;

		try {
		    input = new FileInputStream(filename);
		    
		    loadActionSequences(input);
		}
		catch (IOException e)
		{
			System.out.println("Cannot find/load script file: " + filename);
			
			e.printStackTrace();
		}
	}
	
	
	private void loadActionSequences(InputStream stream)
	{
		String line = null;
		
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(stream, "UTF8"));
			
			input.readLine();  // skip header
			
			while ( (line = input.readLine()) != null)  // Read a line at a time
			{
				int tab1 = line.indexOf((int)'\t'), tab2 = line.indexOf((int)'\t', tab1+1), tab3 = line.indexOf((int)'\t', tab2+1);
				
				if (tab1 > 0 && tab2 > tab1 && tab3 > tab2)
				{
					String starts   = line.substring(0, tab1).trim();
					String middles  = line.substring(tab1+1, tab2).trim();
					String ends     = line.substring(tab2+1, tab3).trim();
					
					StringTokenizer middleTokens = new StringTokenizer(middles, ", ");
					
					while (middleTokens.hasMoreTokens())
					{
						String middle = middleTokens.nextToken().trim().intern();
						
						StringTokenizer startTokens = new StringTokenizer(starts, ", ");
						
						while (startTokens.hasMoreTokens())
						{
							String start = startTokens.nextToken().trim().intern();
							
							StringTokenizer endTokens = new StringTokenizer(ends, ", ");
							
							while (endTokens.hasMoreTokens())
							{
								String end = endTokens.nextToken().trim().intern();
								
								addSequence(start, middle, end);
							}
						}
					}				
				}
			}
			
			input.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}



// assumes existence of multiple hashtables for multiple indexing possibilities

	public void addSequence(String start, String middle, String end)
	{
		String triple = (start + ":" + middle + ":" + end).intern();
		
		if (allSequences.contains(start, triple)) // already present
			return;  
		
		if (startingActions.get(triple) == null)
			sequenceList.add(triple);
		
		startingActions.put(triple, start);
		 middleActions.put(triple, middle);
		 endingActions.put(triple, end);
		
		allSequences.put(start, triple);
		allSequences.put(middle, triple);
		allSequences.put(end, triple);
		
		startSequences.put(start, triple);
		middleSequences.put(middle, triple);
		finalSequences.put(end, triple);
		
		priorActionCounts.put(middle, start);
		priorActionCounts.put(end, middle);
		
		nextActionCounts.put(start, middle);
		nextActionCounts.put(middle, end);
		
		priorActions.put(middle, start);
		priorActions.put(end, middle);
		
		nextActions.put(start, middle);
		nextActions.put(middle, end);
	}

Image: 

Scholarly Lite is a free theme, contributed to the Drupal Community by More than Themes.