SHARE
TWEET

Untitled

a guest Sep 20th, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.BufferedReader;
  2. import java.io.FileReader;
  3. import java.io.IOException;
  4. import java.util.ArrayList;
  5. import java.util.regex.Matcher;
  6. import java.util.regex.Pattern;
  7.  
  8. public class Main {
  9.  
  10.     public static void main(String[] args) throws IOException {
  11.     {
  12.         String content_grund = "";
  13.         BufferedReader file_grund = new BufferedReader(new FileReader("texter_grundskola.txt"));
  14.         String line_grund = file_grund.readLine();
  15.         while (line_grund != null) {
  16.             content_grund = content_grund + line_grund;
  17.             line_grund = file_grund.readLine();
  18.         }
  19.  
  20.         String content_gym = "";
  21.         BufferedReader file_gym = new BufferedReader(new FileReader("texter_gymnasium.txt"));
  22.         String line_gym = file_gym.readLine();
  23.         while (line_gym != null) {
  24.             content_gym = content_gym + line_gym;
  25.             line_gym = file_gym.readLine();
  26.         }
  27.  
  28.         String content_eftergym = "";
  29.         BufferedReader file_eftergym = new BufferedReader(new FileReader("texter_eftergymnasialt.txt"));
  30.         String line_eftergym = file_eftergym.readLine();
  31.         while (line_eftergym != null) {
  32.             content_eftergym = content_eftergym + line_eftergym;
  33.             line_eftergym = file_eftergym.readLine();
  34.         }
  35.  
  36.         ArrayList konjunktionerArray = new ArrayList();
  37.  
  38.         BufferedReader file_konjunktioner = new BufferedReader(new FileReader("konjunktioner.txt"));
  39.         String line_konjunktioner = file_konjunktioner.readLine();
  40.         while (line_konjunktioner != null) {
  41.             konjunktionerArray.add(line_konjunktioner);
  42.             line_konjunktioner = file_konjunktioner.readLine();
  43.         }
  44. //        String a = (String) konjunktionerArray.get(1); a little bit of test code
  45. //        System.out.println(a);
  46.  
  47.         konjunktionerArray.trimToSize(); //make sure this doesn't cause issues if things don't work
  48.  
  49.         int i = 0;
  50.         for (int counter = 0; counter <= konjunktionerArray.size(); counter++) {
  51.             String word = (String) konjunktionerArray.get(i);
  52.             Pattern myPattern = Pattern.compile(word);
  53.             Matcher myMatcher = myPattern.matcher(content_grund);
  54.             i++;
  55.  
  56.             int konjunktionFrekvens = 0;
  57.             while (myMatcher.find()) {
  58.                 konjunktionFrekvens++;
  59.             }
  60.  
  61.             System.out.println(konjunktionFrekvens);
  62.         }
  63.         //OKAY PLEASE FUCKING TEST YOUR CODE WITH A TEXT SAMPLE TO MAKE SURE IT GETS THE JOB DONE
  64.     }
  65.  
  66.  
  67.         //String grundArray[] = new String[1]; this is just to remember how one makes an array :)
  68.  
  69.  
  70.         //A BUNCH OF UNUSED SPAGHETTI CODE DON'T LOOK UNLESS YOU HAVE TO
  71.  
  72.  
  73.     }
  74. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top