<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with matchall() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=matchall%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:13:02 +0000</pubDate>
         <description>Tagged with matchall() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedmatchall%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Use 2D array to find coincidences of words</title>
      <link>https://forum.processing.org/two/discussion/27481/use-2d-array-to-find-coincidences-of-words</link>
      <pubDate>Thu, 29 Mar 2018 18:41:07 +0000</pubDate>
      <dc:creator>Rayle</dc:creator>
      <guid isPermaLink="false">27481@/two/discussions</guid>
      <description><![CDATA[<p>I am triying to discover how many times words from a list appear together in the sentences of a given text. The first thing I did was to find the sentences with a particular word (law in the example below), make an array with them, and count the times the other words appear with an <code>IntDict</code>.</p>

<p>This is the code</p>

<pre><code>StringList results;
IntDict coincidence;

void setup() {

  String [] text = loadStrings("text.txt");
  String onePhrase = join(text, " ").toLowerCase();
  String [] phrases = splitTokens(onePhrase, ".?!");
  String search = "\\blaw.?\\b";
  String [] wordList = loadStrings("wordList.txt");

for (int i = 0; i&lt;phrases.length; i ++) {
      String [] matching = match(phrases[i], search);
      if (matching != null) {
        results.append(phrases[i]); 
    }
  }

   String [] resultsArray = results.array();

   String joinResults = join(resultsArray, " ");
   String [] splitResults = splitTokens(joinResults, " -,.:;¿?¿!/_");

    for(int i = 0; i &lt; splitResults.length; i++) {
    for (String searching : wordList) {
      if (splitResults[i].equals(searching)){
      coincidence.increment(splitResults[i]);
    }
   }
  }
</code></pre>

<p>But if I want to count how many times each word of the list appears together with the other ones, I need to remake the process a lot of times.</p>

<p>I tried with <code>Array[][]</code> but it doesn't work. Now I am stuck with the problem and I don't know how to proceed. I would appreciate any idea.</p>

<pre><code>StringList list;
String [] search;

void setup() {

  String [] text = loadStrings("text.txt");
  String onePhrase = join(text, " ").toLowerCase();
  String [] phrases = splitTokens(onePhrase, ".?!");

  Table table = loadTable("listOfWords.csv", "header");

  for (int i = 0; i &lt;table.getRowCount(); i ++) {
   TableRow row = table.getRow(i);
   list.append(row.getString("Word"));
   search = list.array();
  }

  for (int i = 0; i &lt; phrases.length; i ++) {
    for (int j = 0; j &lt; search.length; j ++) {
      String [][] matching = matchAll(phrases[i], search[j]);

       printArray(matching);
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to make sketch look through string + make a println showing number of occurrences of each vowel?</title>
      <link>https://forum.processing.org/two/discussion/13750/how-to-make-sketch-look-through-string-make-a-println-showing-number-of-occurrences-of-each-vowel</link>
      <pubDate>Wed, 02 Dec 2015 21:11:41 +0000</pubDate>
      <dc:creator>TheTurtle413</dc:creator>
      <guid isPermaLink="false">13750@/two/discussions</guid>
      <description><![CDATA[<p>I need to make the sketch search through the string "The unusually quick brown fox jumps over the lazy family dog repeatedly." and make a (println) output report showing the number of occurrences for each vowel (a,e,i,o,u). I made some code, but I got stuck. For example, the println showed 9 for the vowel a even though the vowel a occurs four times in the string. What am I doing wrong? Thanks.</p>

<pre>String sentence = "The unusually quick brown fox jumps over the lazy family dog repeatedly.";
println(sentence.indexOf("a"));
println(sentence.indexOf("e"));
println(sentence.indexOf("i"));
println(sentence.indexOf("o"));
println(sentence.indexOf("u"));
noLoop();</pre>
]]></description>
   </item>
   </channel>
</rss>