Link to home
Start Free TrialLog in
Avatar of InteractiveMind
InteractiveMindFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Character frequency paragraph

Do you enjoy boring and tedious jobs for which the only pay is a few measly expert points and my eternal gratitude? If so, then:

Please write as short a paragraph as you can, which:

  a) contains at least 2 of every letter in the alphabet, and
  b) is coherent (so gibberish doesn't count).

I've done some myself, but it's taking me ages now and I can't think of anything to write about except physics or programming (how boring I am) - I'd like a mix of topics (films, poets, history, languages, anything that comes to mind really!) - also, I'm running low on words containing x's, z's, q's, etc.

Points will be split equally.


If you're interested in why I want this: I wish to analyse the typing style of different people, and require a text corpus (with plenty of the less frequent letters) for each subject to type up into my software (which will then analyse them).

(For anyone with Java installed, you can use the attached code to count the number of letters used.)

Much appreciated!!
//This Java program will count the number of letters used in your text as you type it...
//Excuse the poor programming
import javax.swing.*;
import java.awt.*;
public class Corpus extends JFrame implements Runnable
{
	public JTextArea area=null;
	public JTextArea count=null;
	private String[]alpha=new String[]{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
	private int[]adder=new int[alpha.length];
	
	public Corpus()
	{
		super();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLayout(new GridLayout(1,2));
		area=new JTextArea(30,30);
		area.setText("Type here...");
		count=new JTextArea(30,10);
		add(new JScrollPane(area));
		add(new JScrollPane(count));
		area.setLineWrap(true);
		pack();
		setLocationRelativeTo(null);
		setVisible(true);
		new Thread(this).start();
	}
	
	public void run()
	{
		for(;;)
		{
			update();
			try{Thread.sleep(100);}catch(Exception e){}
		}
	}
	
	public void update()
	{
		for(int i=0; i<adder.length; i++)
		{
			adder[i]=0;
		}
		String T=area.getText().toUpperCase();
		for(int i=0; i<T.length(); i++)
		{
			String C=T.substring(i,i+1);
			for(int j=0; j<alpha.length; j++)
			{
				if(alpha[j].equals(C))
				{
					adder[j]++;
				}
			}
		}
		
		String S="";
		for(int i=0; i<adder.length; i++)
		{
			S+=alpha[i]+"\t"+adder[i];
			if(adder[i]>=2)S+=" #";
			S+="\n";
		}
		count.setText(S);
	}
	
	public static void main(String[]a)
	{
		new Corpus();
	}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>(Differences in .
oops! sorry, editing and not reading properly.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of InteractiveMind

ASKER

I think I now have enough to close this thread actually.

Thank you fhillyer1, that was fast!

And thank you, ozo, I'd never heard of pangrams!
http://en.wikipedia.org/wiki/List_of_pangrams  =)

RobinD: I had programmed something similar before to identify the language used (I used the Chi-square test to compare the observed letter frequency to that of a large text corpus). With this project however, I'm analysing typing style so as to identify someone based on how they type (rather than what they type).

Thanks everyone!