├── LICENSE
├── NOC
├── CODE
│ ├── tabular
│ │ ├── AnalogicalMapping.java
│ │ ├── AtomicCounter.java
│ │ ├── BucketTable.java
│ │ ├── CorpusAnalyzer.java
│ │ ├── CountTable.java
│ │ ├── ListParser.java
│ │ ├── RandomSelector.java
│ │ ├── SymbolCounter.java
│ │ ├── SymbolLink.java
│ │ ├── SymbolMap.java
│ │ ├── TableFileIndex.java
│ │ ├── TwoTieredTable.java
│ │ └── WordTable.java
│ └── twitterbotics
│ │ ├── AffectiveMetaphorizer.java
│ │ ├── AffectiveProfile.java
│ │ ├── BestOfBotWorlds.java
│ │ ├── BotOnBotAction.java
│ │ ├── CelebrityTweetGenerator.java
│ │ ├── CellularAutomaton.java
│ │ ├── ColorAutomaton.java
│ │ ├── ColorLexicon.java
│ │ ├── ColorLoverPalette.java
│ │ ├── DessertMaker.java
│ │ ├── DreamCaster.java
│ │ ├── Dribbler.java
│ │ ├── KnowledgeBaseModule.java
│ │ ├── Lexinomicron.java
│ │ ├── MetaphorMagnet.java
│ │ ├── PaintedCanvas.java
│ │ ├── PersonOfInterest.java
│ │ ├── TweetEmojifier.java
│ │ ├── TweetLaunchpad.java
│ │ ├── TweetLaunchpadWithEmoji.java
│ │ ├── TweetSearcher.java
│ │ ├── TwitterbotTrigger.java
│ │ └── VennDiagram.java
├── DATA
│ ├── TSV Lists
│ │ ├── List of desserts.txt
│ │ ├── List of ingredients.txt
│ │ ├── Veale's Category Hierarchy.txt
│ │ ├── Veale's Inter-Category Relationships.txt
│ │ ├── Veale's The NOC List.txt
│ │ ├── Veale's Typical Activities.txt
│ │ ├── Veale's affordances.txt
│ │ ├── Veale's category actions.txt
│ │ ├── Veale's clothing line.txt
│ │ ├── Veale's creations.txt
│ │ ├── Veale's domains.txt
│ │ ├── Veale's fictional worlds.txt
│ │ ├── Veale's location listing.txt
│ │ ├── Veale's place elements.txt
│ │ ├── Veale's quality inventory.txt
│ │ ├── Veale's vehicle fleet.txt
│ │ ├── Veale's weapon arsenal.txt
│ │ ├── antonyms.txt
│ │ ├── category list.txt
│ │ ├── comparatives.txt
│ │ ├── past perfects.txt
│ │ ├── superlatives.txt
│ │ └── verb list.txt
│ └── Veale's NOC List
│ │ ├── Past Perfects.xlsx
│ │ ├── Veale's Fictional Worlds.xlsx
│ │ ├── Veale's The NOC List.xlsx
│ │ ├── Veale's Typical Activities.xlsx
│ │ ├── Veale's affordances.xlsx
│ │ ├── Veale's category hierarchy.xlsx
│ │ ├── Veale's clothing line.xlsx
│ │ ├── Veale's creations.xlsx
│ │ ├── Veale's domains.xlsx
│ │ ├── Veale's location listing.xlsx
│ │ ├── Veale's vehicle fleet.xlsx
│ │ ├── Veale's weapon arsenal.xlsx
│ │ ├── Veales place elements.xlsx
│ │ └── superlatives.xlsx
└── README
│ └── Postcards from the Edge.pdf
└── README.md
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/NOC/CODE/tabular/AnalogicalMapping.java:
--------------------------------------------------------------------------------
1 | package tabular;
2 |
3 | import java.util.Vector;
4 |
5 |
6 |
7 | public class AnalogicalMapping extends SymbolMap
8 | {
9 | private BucketTable slots = new BucketTable("slot to fillers");
10 |
11 | private SymbolMap kb = null;
12 | private SymbolMap coordinates = null;
13 | private BucketTable referenceSet = null;
14 |
15 | private String currentSrc = null;
16 |
17 |
18 | //-----------------------------------------------------------------//
19 | //-----------------------------------------------------------------//
20 | // Constructors
21 | //-----------------------------------------------------------------//
22 | //-----------------------------------------------------------------//
23 |
24 | public AnalogicalMapping(SymbolMap kb, SymbolMap coordinates)
25 | {
26 | super("analogical mapping");
27 |
28 | this.kb = kb;
29 | this.coordinates = coordinates;
30 | }
31 |
32 |
33 | public AnalogicalMapping(String kbname, String coordname)
34 | {
35 | super("analogical mapping");
36 |
37 | this.kb = new SymbolMap("terms to their content");
38 | this.coordinates = new SymbolMap("terms to coordinated terms");
39 |
40 | System.out.print("Loading knowledge-base ...");
41 |
42 | this.kb.loadMap(kbname);
43 |
44 | System.out.print(" Loaded. \nLoading coordinates ...");
45 |
46 | this.coordinates.loadMap(coordname);
47 |
48 | System.out.println(" Loaded.\n");
49 | }
50 |
51 |
52 | public void setReferenceSet(BucketTable refset)
53 | {
54 | referenceSet = refset;
55 | }
56 |
57 |
58 | //-----------------------------------------------------------------//
59 | //-----------------------------------------------------------------//
60 | // Find similes within a given similarity threshold
61 | //-----------------------------------------------------------------//
62 | //-----------------------------------------------------------------//
63 |
64 | public void findSimilesWithinLimits(int minSim)
65 | {
66 | Vector srcs = kb.getKeyList(), tgts = null, overlap = null;
67 |
68 | String src = null, from = null, to = null;
69 |
70 | if (srcs == null) return;
71 |
72 | SymbolCounter tgt = null, common = null;
73 |
74 | for (int i = 0; i < srcs.size(); i++)
75 | {
76 | src = (String)srcs.elementAt(i);
77 |
78 | tgts = coordinates.get(src);
79 |
80 | if (tgts == null) continue;
81 |
82 | for (int j = 0; j < tgts.size(); j++)
83 | {
84 | tgt = (SymbolCounter)tgts.elementAt(j);
85 |
86 | if (tgt.value() < minSim) break;
87 |
88 | overlap = kb.getOverlappingValues(src, tgt.getSymbol());
89 |
90 | if (overlap != null && overlap.size() > 0)
91 | {
92 | from = src + ":" + tgt.getSymbol();
93 | to = tgt.getSymbol() + ":" + src;
94 |
95 | for (int k = 0; k < overlap.size(); k++)
96 | {
97 | common = (SymbolCounter)overlap.elementAt(k);
98 |
99 | put(from, "share:" + common.getSymbol(), common.value());
100 | put(to, "share:" + common.getSymbol(), common.value());
101 | }
102 |
103 | System.out.println(getKeyList().size()/2 + ". " + src + " : " + tgt + " share " + overlap);
104 | }
105 | }
106 | }
107 | }
108 |
109 |
110 | //-----------------------------------------------------------------//
111 | //-----------------------------------------------------------------//
112 | // Find similes within a given similarity threshold
113 | //-----------------------------------------------------------------//
114 | //-----------------------------------------------------------------//
115 |
116 | public void findAnalogiesWithinLimits(int minSubjSim, int minObjSim)
117 | {
118 | Vector srcs = kb.getKeyList(), targets = null, tgtContent = null;
119 |
120 | String src = null;
121 |
122 | if (srcs == null) return;
123 |
124 | SymbolCounter tgt = null, relation = null;
125 |
126 | for (int i = 0; i < srcs.size(); i++)
127 | {
128 | src = (String)srcs.elementAt(i);
129 |
130 | targets = coordinates.get(src);
131 |
132 | if (targets == null) continue;
133 |
134 | setSource(src);
135 |
136 | for (int j = 0; j < targets.size(); j++)
137 | {
138 | tgt = (SymbolCounter)targets.elementAt(j);
139 |
140 | if (tgt.value() < minSubjSim) break;
141 |
142 | tgtContent = kb.get(tgt.getSymbol());
143 |
144 | if (tgtContent == null) continue;
145 |
146 | for (int k = 0; k < tgtContent.size(); k++)
147 | {
148 | relation = (SymbolCounter)tgtContent.elementAt(k);
149 |
150 | findAnalogiesFor(src, tgt.getSymbol(), relation.getSymbol(), minObjSim);
151 | }
152 | }
153 | }
154 | }
155 |
156 |
157 | private void findAnalogiesFor(String src, String tgt, String tgtRelation, int minSim)
158 | {
159 | int colon = tgtRelation.indexOf((int)':'), sim = 0;
160 |
161 | if (colon <= 0) return;
162 |
163 | String pred = tgtRelation.substring(0, colon);
164 | String tgtObject = tgtRelation.substring(colon+1);
165 | String srcObject = null;
166 |
167 | String from = null;
168 | String to = null;
169 |
170 | Vector srcObjects = slots.get(pred);
171 |
172 | if (srcObjects == null) return;
173 |
174 | for (int i = 0; i < srcObjects.size(); i++)
175 | {
176 | srcObject = (String)srcObjects.elementAt(i);
177 |
178 | if (srcObject.equals(tgt)) continue;
179 | if (tgtObject.equals(src)) continue;
180 |
181 | if (!referenceSet.contains(src, srcObject) && !referenceSet.contains(srcObject, src))
182 | continue;
183 |
184 | if (!referenceSet.contains(tgt, tgtObject) && !referenceSet.contains(tgtObject, tgt))
185 | continue;
186 |
187 | sim = coordinates.getCount(srcObject, tgtObject);
188 |
189 | if (sim < minSim)
190 | continue;
191 |
192 | if (from == null) from = src + ":" + tgt;
193 | if (to == null) to = tgt + ":" + src;
194 |
195 | put(from, "map:" + pred + ":" + srcObject + ":" + tgtObject, sim);
196 | put(to, "map:" + pred + ":" + tgtObject + ":" + srcObject, sim);
197 |
198 | System.out.println(getKeyList().size()/2 + ". " + src + " : " + tgt + " map "
199 | + pred + ":" + srcObject + " to " + pred + ":" + tgtObject + " (" + sim + ")");
200 | }
201 | }
202 |
203 | //-----------------------------------------------------------------//
204 | //-----------------------------------------------------------------//
205 | // Useful methods
206 | //-----------------------------------------------------------------//
207 | //-----------------------------------------------------------------//
208 |
209 | public void setSource(String term)
210 | {
211 | if (currentSrc == null || !currentSrc.equals(term))
212 | {
213 | if (currentSrc != null)
214 | clearSlots();
215 |
216 | setSlotsOf(term);
217 | }
218 |
219 | currentSrc = term;
220 | }
221 |
222 |
223 | public void setSlotsOf(String term)
224 | {
225 | Vector relations = kb.get(term);
226 |
227 | if (relations == null) return;
228 |
229 | String rel = null, pred = null, object = null;
230 |
231 | int colon = 0;
232 |
233 | for (int i = 0; i < relations.size(); i++)
234 | {
235 | rel = ((SymbolCounter)relations.elementAt(i)).getSymbol();
236 |
237 | colon = rel.indexOf((int)':');
238 |
239 | if (colon <= 0) continue;
240 |
241 | pred = rel.substring(0, colon);
242 | object = rel.substring(colon+1);
243 |
244 | slots.put(pred, object);
245 | }
246 | }
247 |
248 |
249 | public void clearSlots()
250 | {
251 | Vector slotnames = slots.getKeyList(), values = null;
252 |
253 | if (slotnames == null) return;
254 |
255 | for (int i = 0; i < slotnames.size(); i++)
256 | {
257 | values = slots.get((String)slotnames.elementAt(i));
258 |
259 | if (values != null)
260 | values.setSize(0);
261 | }
262 | }
263 |
264 |
265 | //-----------------------------------------------------------------//
266 | //-----------------------------------------------------------------//
267 | // Main application stub
268 | //-----------------------------------------------------------------//
269 | //-----------------------------------------------------------------//
270 |
271 | public static void main(String[] args)
272 | {
273 |
274 | }
275 | }
276 |
--------------------------------------------------------------------------------
/NOC/CODE/tabular/AtomicCounter.java:
--------------------------------------------------------------------------------
1 |
2 | package tabular;
3 |
4 | // This class implements atomic increment and decrement operations on an integer
5 | // wrapped in an object shell
6 |
7 | // Consider it a version of Integer than permits changes to its contents
8 |
9 | //(c) Tony Veale 2007
10 |
11 |
12 | public class AtomicCounter implements java.io.Serializable
13 | {
14 | int counter = 0;
15 |
16 | //-----------------------------------------------------------------//
17 | // Constructors
18 | //-----------------------------------------------------------------//
19 |
20 | public AtomicCounter()
21 | {
22 | counter = 0;
23 | }
24 |
25 | public AtomicCounter(int start)
26 | {
27 | counter = start;
28 | }
29 |
30 | //-----------------------------------------------------------------//
31 | // Display Behavior
32 | //-----------------------------------------------------------------//
33 |
34 |
35 | public String toString()
36 | {
37 | return "[" + counter + "]";
38 | }
39 |
40 |
41 | //-----------------------------------------------------------------//
42 | // Accessors
43 | //-----------------------------------------------------------------//
44 |
45 |
46 | synchronized public int value()
47 | {
48 | return counter;
49 | }
50 |
51 |
52 | //-----------------------------------------------------------------//
53 | // Modifiers
54 | //-----------------------------------------------------------------//
55 |
56 |
57 | synchronized public int inc()
58 | {
59 | counter++;
60 |
61 | return counter;
62 | }
63 |
64 |
65 |
66 | synchronized public int inc(int delta)
67 | {
68 | counter += delta;
69 |
70 | return counter;
71 | }
72 |
73 |
74 |
75 |
76 | synchronized public int dec()
77 | {
78 | if (counter > 0)
79 | return --counter;
80 | else
81 | return 0;
82 | }
83 |
84 |
85 | synchronized public int dec(int delta)
86 | {
87 | counter -= delta;
88 |
89 | return counter;
90 | }
91 |
92 |
93 | synchronized public int set(int value)
94 | {
95 | counter = value;
96 |
97 | return value;
98 | }
99 |
100 |
101 |
102 | synchronized public int setMin(int value)
103 | {
104 | counter = Math.min(counter, value);
105 |
106 | return counter;
107 | }
108 |
109 |
110 |
111 | synchronized public int setMax(int value)
112 | {
113 | counter = Math.max(counter, value);
114 |
115 | return counter;
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/NOC/CODE/tabular/CountTable.java:
--------------------------------------------------------------------------------
1 |
2 | package tabular;
3 |
4 | // This package provides extended Hashtable structures
5 |
6 | import java.io.BufferedReader;
7 | import java.io.FileInputStream;
8 | import java.io.FileOutputStream;
9 | import java.io.IOException;
10 | import java.io.InputStream;
11 | import java.io.InputStreamReader;
12 | import java.io.ObjectInputStream;
13 | import java.io.ObjectOutputStream;
14 | import java.io.OutputStreamWriter;
15 | import java.util.Enumeration;
16 | import java.util.Hashtable;
17 | import java.util.StringTokenizer;
18 | import java.util.Vector;
19 |
20 | // This class implements a hash table that maps symbols to counters that
21 | // track how many times a symbol has been entered
22 |
23 |
24 | public class CountTable
25 | {
26 | private boolean symbolical = false;
27 |
28 | private Hashtable table = new Hashtable();
29 |
30 | private int maxCount = 0;
31 |
32 | private int threshold = 1000000000;
33 |
34 | private String tableName = null;
35 |
36 | private Vector maxElements = new Vector(0);
37 |
38 | private Vector topElements = new Vector(0);
39 |
40 | private Vector keys = new Vector();
41 |
42 | //---------------------------------------------------------------------------//
43 | //---------------------------------------------------------------------------//
44 | // Constructors
45 | //---------------------------------------------------------------------------//
46 | //---------------------------------------------------------------------------//
47 |
48 | public CountTable()
49 | {
50 | this(false);
51 | }
52 |
53 |
54 | public CountTable(boolean bindSymbols)
55 | {
56 | symbolical = bindSymbols;
57 | }
58 |
59 |
60 |
61 | public CountTable(String name)
62 | {
63 | this.tableName = name;
64 | }
65 |
66 |
67 |
68 | public CountTable(String name, int threshold)
69 | {
70 | this(name);
71 |
72 | this.threshold = threshold;
73 | }
74 |
75 |
76 |
77 | public CountTable(String dir, String filename)
78 | {
79 | this(filename);
80 |
81 | loadTable(dir + filename);
82 | }
83 |
84 | //---------------------------------------------------------------------------//
85 | //---------------------------------------------------------------------------//
86 | // Accessors
87 | //---------------------------------------------------------------------------//
88 | //---------------------------------------------------------------------------//
89 |
90 | public String getName()
91 | {
92 | return tableName;
93 | }
94 |
95 |
96 | public int size()
97 | {
98 | return table.size();
99 | }
100 |
101 |
102 | public AtomicCounter get(String key)
103 | {
104 | return (AtomicCounter)table.get(key);
105 | }
106 |
107 |
108 | public Enumeration keys()
109 | {
110 | return table.keys();
111 | }
112 |
113 |
114 | public Enumeration elements()
115 | {
116 | return table.elements();
117 | }
118 |
119 |
120 | public boolean contains(String key)
121 | {
122 | return table.get(key) != null;
123 | }
124 |
125 |
126 | public boolean contains(String key, int value)
127 | {
128 | AtomicCounter contents = get(key);
129 |
130 | if (contents == null)
131 | return false;
132 | else
133 | return contents.value() >= value;
134 | }
135 |
136 |
137 | public int getCount(String key)
138 | {
139 | AtomicCounter contents = get(key);
140 |
141 | if (contents == null)
142 | return 0;
143 | else
144 | return contents.value();
145 | }
146 |
147 |
148 |
149 | public int getMaxCount()
150 | {
151 | return maxCount;
152 | }
153 |
154 |
155 | public Vector getMaxElements()
156 | {
157 | return maxElements;
158 | }
159 |
160 |
161 | public Vector getThreshold()
162 | {
163 | return maxElements;
164 | }
165 |
166 |
167 | public Vector getTopElements()
168 | {
169 | return topElements;
170 | }
171 |
172 |
173 | public Vector getKeyList()
174 | {
175 | return keys;
176 | }
177 |
178 |
179 | public String getMostFrequent(String term1, String term2)
180 | {
181 | if (getCount(term1) > getCount(term2))
182 | return term1;
183 | else
184 | return term2;
185 | }
186 |
187 |
188 | public String getMostFrequent(String term1, String term2, String term3)
189 | {
190 | return getMostFrequent(getMostFrequent(term1, term2), term3);
191 | }
192 |
193 |
194 | public String getMostFrequent(String term1, String term2, String term3, String term4)
195 | {
196 | return getMostFrequent(getMostFrequent(term1, term2), getMostFrequent(term3, term4));
197 | }
198 |
199 |
200 | //---------------------------------------------------------------------------//
201 | //---------------------------------------------------------------------------//
202 | // Modifiers
203 | //---------------------------------------------------------------------------//
204 | //---------------------------------------------------------------------------//
205 |
206 |
207 | public void setSymbolize(boolean ymbolize)
208 | {
209 | symbolical = ymbolize;
210 | }
211 |
212 |
213 | public int setThreshold(int value)
214 | {
215 | threshold = value;
216 |
217 | return value;
218 | }
219 |
220 |
221 | public Object remove(String key)
222 | {
223 | return table.remove(key);
224 | }
225 |
226 |
227 | public boolean remove(String key, int value)
228 | {
229 | AtomicCounter contents = get(key);
230 |
231 | if (contents == null)
232 | return false;
233 |
234 | if (value > contents.value())
235 | remove(key);
236 | else
237 | contents.set(contents.value()-value);
238 |
239 | return true;
240 | }
241 |
242 |
243 |
244 | public void clear()
245 | {
246 | table.clear();
247 | topElements.setSize(0);
248 | maxElements.setSize(0);
249 | }
250 |
251 |
252 | public AtomicCounter put(String key)
253 | {
254 | return put(key, 1);
255 | }
256 |
257 |
258 |
259 | public AtomicCounter put(String key, int value)
260 | {
261 | AtomicCounter contents = get(key);
262 |
263 | if (contents == null)
264 | return set(key, value);
265 | else
266 | return set(key, value + contents.value());
267 | }
268 |
269 |
270 | public AtomicCounter putMax(String key, int value)
271 | {
272 | AtomicCounter contents = get(key);
273 |
274 | if (contents == null || value > contents.value())
275 | return set(key, value);
276 | else
277 | return contents;
278 | }
279 |
280 |
281 | public AtomicCounter set(String key, int value)
282 | {
283 | key = key.intern();
284 |
285 | AtomicCounter contents = get(key);
286 |
287 | if (contents == null)
288 | {
289 | if (symbolical)
290 | contents = new SymbolCounter(key, 0);
291 | else
292 | contents = new AtomicCounter(0);
293 |
294 | table.put(key, contents);
295 |
296 | if (symbolical)
297 | keys.add(contents);
298 | else
299 | keys.add(key);
300 | }
301 |
302 | contents.set(value);
303 |
304 | if (value > maxCount)
305 | {
306 | maxCount = value;
307 | maxElements.setSize(0);
308 | maxElements.addElement(key);
309 | }
310 | else
311 | if (value == maxCount)
312 | maxElements.addElement(key);
313 |
314 | if (value == threshold)
315 | topElements.addElement(key);
316 |
317 | return contents;
318 | }
319 |
320 |
321 |
322 | //---------------------------------------------------------------------------//
323 | //---------------------------------------------------------------------------//
324 | // Load and Save Behavior
325 | //---------------------------------------------------------------------------//
326 | //---------------------------------------------------------------------------//
327 |
328 |
329 | public void saveTable(String fname)
330 | {
331 | if (!symbolical) return;
332 |
333 | try {
334 | OutputStreamWriter output = new OutputStreamWriter(new FileOutputStream(fname));
335 |
336 | SymbolCounter key = null;
337 |
338 | Vector counter = null;
339 |
340 | for (int i = 0; i < keys.size(); i++)
341 | {
342 | key = (SymbolCounter)keys.elementAt(i);
343 |
344 | output.write(key.getSymbol() + "\t" + key.value() + "\n");
345 | }
346 |
347 | output.close();
348 | }
349 | catch (Exception e)
350 | {
351 | e.printStackTrace();
352 | }
353 | }
354 |
355 |
356 |
357 | public void loadTable(String filename)
358 | {
359 | String line = null;
360 |
361 | try {
362 | BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
363 |
364 | String token = null, count = null;
365 |
366 | int tab = 0;
367 |
368 | while ( (line = input.readLine()) != null) // Read a line at a time
369 | {
370 | tab = line.indexOf((int)'\t');
371 |
372 | if (tab < 0) continue;
373 |
374 | token = line.substring(0, tab);
375 | count = line.substring(tab+1);
376 |
377 | put(token, Integer.parseInt(count));
378 | }
379 |
380 | input.close(); // close connection to the data source
381 | }
382 | catch (IOException e)
383 | {
384 | System.out.println("Exception while reading CountTable file:\n " + e.toString());
385 |
386 | e.printStackTrace();
387 | }
388 | }
389 |
390 |
391 |
392 | //---------------------------------------------------------------------------//
393 | //---------------------------------------------------------------------------//
394 | // Main
395 | //---------------------------------------------------------------------------//
396 | //---------------------------------------------------------------------------//
397 |
398 | public static void main(String[] args)
399 | {
400 | }
401 |
402 |
403 | }
--------------------------------------------------------------------------------
/NOC/CODE/tabular/ListParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Created on May 1, 2006
3 | *
4 | * Parse a LISP-like list into a Vector format
5 | */
6 |
7 | package tabular;
8 |
9 | /**
10 | * @author Tony Veale
11 | *
12 | */
13 |
14 | import java.io.BufferedReader;
15 | import java.io.FileInputStream;
16 | import java.io.IOException;
17 | import java.io.InputStream;
18 | import java.io.InputStreamReader;
19 | import java.util.Vector;
20 |
21 |
22 | public class ListParser
23 | {
24 | //-------------------------------------------------------------------//
25 | //-------------------------------------------------------------------//
26 | // Print Behaviour
27 | //-------------------------------------------------------------------//
28 | //-------------------------------------------------------------------//
29 |
30 | public static String toString(Object obj)
31 | {
32 | if (obj == null)
33 | return "()";
34 | else
35 | if (obj instanceof Vector)
36 | return toString((Vector)obj, new StringBuffer());
37 | else
38 | return obj.toString();
39 | }
40 |
41 |
42 | public static String toString(Vector list, StringBuffer buff)
43 | {
44 | if (list == null || list.size() == 0)
45 | return "()";
46 |
47 | buff.append("(");
48 |
49 | Object item = null;
50 |
51 | for (int i = 0; i < list.size(); i++)
52 | {
53 | if (i > 0)
54 | buff.append(" ");
55 |
56 | item = list.elementAt(i);
57 |
58 | if (item == null)
59 | buff.append("()");
60 | else
61 | if (item instanceof Vector)
62 | buff.append(toString((Vector)item));
63 | else
64 | buff.append(item.toString());
65 | }
66 |
67 | buff.append(")");
68 |
69 | return buff.toString();
70 | }
71 |
72 |
73 | //-------------------------------------------------------------------//
74 | //-------------------------------------------------------------------//
75 | // List Comparator
76 | //-------------------------------------------------------------------//
77 | //-------------------------------------------------------------------//
78 |
79 | public static boolean areSameSet(Vector list1, Vector list2)
80 | {
81 | if (list1 == null) return list2 == null;
82 | if (list2 == null) return list1 == null;
83 |
84 | if (list1.size() != list2.size()) return false;
85 |
86 | Object element = null;
87 |
88 | for (int i = 0; i < list1.size(); i++)
89 | {
90 | element = list1.elementAt(i);
91 |
92 | if (!list2.contains(element)) return false;
93 | }
94 |
95 | return true;
96 | }
97 |
98 | //-------------------------------------------------------------------//
99 | //-------------------------------------------------------------------//
100 | // List parser
101 | //-------------------------------------------------------------------//
102 | //-------------------------------------------------------------------//
103 |
104 | public static Object parse(String list)
105 | {
106 | Vector gather = new Vector();
107 |
108 | if (list == null || list.length() == 0) return gather;
109 |
110 | String text = list.trim();
111 |
112 | if (text.length() == 0) return gather;
113 |
114 | parse(text, gather, 0, 0);
115 |
116 | if (gather != null && gather.size() > 0)
117 | return gather.elementAt(0);
118 | else
119 | return null;
120 | }
121 |
122 |
123 | public static Vector parseFile(String fname)
124 | {
125 | Vector gather = new Vector();
126 |
127 | parse(loadText(fname), gather, 0, 0);
128 |
129 | return gather;
130 | }
131 |
132 |
133 | private static int parse(String text, Vector list, int pos, int level)
134 | {
135 | int len = text.length(), start = -1, quoted = 0;
136 |
137 | char curr = ' ';
138 |
139 | boolean literal = false;
140 |
141 | while (pos < len)
142 | {
143 | curr = text.charAt(pos);
144 |
145 | if (curr == '"')
146 | {
147 | if (!literal)
148 | {
149 | literal = true;
150 |
151 | if (start >= 0 && start < pos)
152 | {
153 | list.addElement(addQuotes(quoted, text.substring(start, pos).intern()));
154 |
155 | quoted=0;
156 |
157 | start = -1;
158 | }
159 |
160 | start = pos+1;
161 | }
162 | else
163 | {
164 | if (start >= 0 && start < pos)
165 | {
166 | list.addElement(addQuotes(quoted, text.substring(start, pos).intern()));
167 |
168 | quoted=0;
169 |
170 | start = -1;
171 | }
172 |
173 | literal = false;
174 | }
175 | }
176 | else
177 | if (literal)
178 | {
179 | pos++;
180 |
181 | continue;
182 | }
183 | else
184 | if (curr == ' ' || curr == ',' || curr == '\t' || curr == '\n')
185 | {
186 | if (start >= 0 && start < pos)
187 | {
188 | list.addElement(addQuotes(quoted, text.substring(start, pos).intern()));
189 |
190 | quoted=0;
191 |
192 | start = -1;
193 | }
194 | }
195 | else
196 | if (curr == '\'')
197 | {
198 | quoted++;
199 | }
200 | else
201 | if (curr == '(' || curr == '[')
202 | {
203 | if (start >= 0 && start < pos)
204 | {
205 | list.addElement(addQuotes(quoted, text.substring(start, pos).intern()));
206 |
207 | quoted=0;
208 | start = -1;
209 | }
210 |
211 | Vector sub = new Vector();
212 |
213 | list.add(addQuotes(quoted, sub));
214 |
215 | quoted = 0;
216 |
217 | pos = parse(text, sub, pos+1, level+1);
218 | }
219 | else
220 | if (curr == ')' || curr == ']')
221 | {
222 | if (start >= 0 && start < pos)
223 | {
224 | list.addElement(addQuotes(quoted, text.substring(start, pos).intern()));
225 |
226 | quoted=0;
227 |
228 | start = -1;
229 | }
230 |
231 | if (level == 0)
232 | System.out.println("Too Many Right Parens: "
233 | + text.substring(0, pos)
234 | + "***" + text.substring(pos));
235 | else
236 | return pos;
237 | }
238 | else
239 | {
240 | if (start < 0) start = pos;
241 | }
242 |
243 | pos++;
244 | }
245 |
246 | if (start >= 0)
247 | list.addElement(addQuotes(quoted, text.substring(start, text.length()).intern()));
248 |
249 | return pos;
250 | }
251 |
252 |
253 | private static Object addQuotes(int numQuotes, Object item)
254 | {
255 | item = castRepresentation(item);
256 |
257 | if (numQuotes == 0)
258 | return item;
259 |
260 | Vector wrap = new Vector();
261 |
262 | wrap.addElement("quote");
263 |
264 | wrap.addElement(addQuotes(numQuotes-1, item));
265 |
266 | return wrap;
267 | }
268 |
269 |
270 |
271 | // generate an Integer or Double or Boolean entry for string
272 |
273 | private static Object castRepresentation(Object form)
274 | {
275 | if (form == null || !(form instanceof String))
276 | return form;
277 |
278 | if (form == "true")
279 | return new Boolean(true);
280 | else
281 | if (form == "false")
282 | return new Boolean(false);
283 |
284 | String text = (String)form;
285 |
286 | if (text.length() == 0)
287 | return text;
288 |
289 | if (!text.startsWith(".") && !Character.isDigit(text.charAt(0)))
290 | return text;
291 |
292 | if (!Character.isDigit(text.charAt(text.length()-1)))
293 | return text;
294 |
295 | try {
296 | if (text.indexOf((int)'.') >= 0)
297 | return new Double(Double.parseDouble(text));
298 | else
299 | return new Integer(Integer.parseInt(text));
300 | }
301 | catch (Exception e)
302 | {
303 | return text;
304 | }
305 | }
306 |
307 | //--------------------------------------------------------------------//
308 | //--------------------------------------------------------------------//
309 | // Load a text file into memory as a large String of text
310 | //--------------------------------------------------------------------//
311 | //--------------------------------------------------------------------//
312 |
313 | private static String loadText(String filename)
314 | {
315 | FileInputStream input;
316 |
317 | try {
318 | input = new FileInputStream(filename);
319 |
320 | return loadText(input);
321 | }
322 | catch (IOException e)
323 | {
324 | System.out.println("Cannot find/load text file: " + filename);
325 |
326 | e.printStackTrace();
327 | }
328 |
329 | return "";
330 | }
331 |
332 |
333 |
334 | private static String loadText(InputStream stream)
335 | {
336 | String line = null;
337 |
338 | StringBuffer store = new StringBuffer();
339 |
340 | try {
341 | BufferedReader input = new BufferedReader(new InputStreamReader(stream));
342 |
343 | while ( (line = input.readLine()) != null) // Read a line at a time
344 | {
345 | int comment = line.indexOf("//");
346 |
347 | if (comment == 0)
348 | continue;
349 | else
350 | if (comment > 0)
351 | store.append(line.substring(0, comment)).append("\n");
352 | else
353 | store.append(line).append("\n");
354 | }
355 |
356 | input.close(); // close connection to the data source
357 | }
358 | catch (IOException e)
359 | {
360 | System.out.println("Exception while reading text file:\n " + e.toString());
361 |
362 | e.printStackTrace();
363 | }
364 |
365 | store.append(" ");
366 |
367 | return store.toString();
368 | }
369 |
370 |
371 | //-------------------------------------------------------------------//
372 | //-------------------------------------------------------------------//
373 | // Main routine for test purposes
374 | //-------------------------------------------------------------------//
375 | //-------------------------------------------------------------------//
376 |
377 | public static void main(String[] args)
378 | {
379 | String dir = "/Users/tonyveale/Desktop/Lexical Resources/";
380 |
381 | String catDir = dir + "Categories/Fingerprints/";
382 |
383 | String example = " ((a) '(b 1.5 true 10 \"c d\"))";
384 |
385 | Object list = ListParser.parse(example);
386 |
387 | System.out.println("in: " + example);
388 | System.out.println("mid: " + list);
389 | System.out.println("out: " + ListParser.toString(list));
390 |
391 | Vector flist = ListParser.parseFile(catDir + "similes.list");
392 |
393 | System.out.println("\nFile: " + flist);
394 |
395 | System.out.println("\nFile: " + ListParser.toString(flist));
396 |
397 | }
398 | }
399 |
--------------------------------------------------------------------------------
/NOC/CODE/tabular/RandomSelector.java:
--------------------------------------------------------------------------------
1 | package tabular;
2 |
3 | import java.util.Random;
4 |
5 |
6 |
7 | // Randomly select one of a given selection set
8 |
9 | public class RandomSelector
10 | {
11 | private Random dice = new Random(System.currentTimeMillis());
12 |
13 |
14 | //------------------------------------------------------------//
15 | //------------------------------------------------------------//
16 | // Constructors
17 | //------------------------------------------------------------//
18 | //------------------------------------------------------------//
19 |
20 | // empty constructor
21 |
22 | public RandomSelector() {}
23 |
24 |
25 | // Select one of two choices
26 |
27 | public Object either(Object choice1, Object choice2)
28 | {
29 | if (dice.nextInt() % 2 == 0)
30 | return choice1;
31 | else
32 | return choice2;
33 | }
34 |
35 |
36 | //------------------------------------------------------------//
37 | //------------------------------------------------------------//
38 | // Main method, with simple demo
39 | //------------------------------------------------------------//
40 | //------------------------------------------------------------//
41 |
42 | public static void main(String[] args)
43 | {
44 | RandomSelector choose = new RandomSelector();
45 |
46 | int numTimesHasBoy = 0, numTimesTwoBoys = 0, numTimesBoySeen = 0;
47 |
48 | while (numTimesHasBoy < 1000)
49 | {
50 | String child1 = (String)choose.either("boy", "girl"),
51 | child2 = (String)choose.either("boy", "girl");
52 |
53 | if (child1 == child2)
54 | {
55 | child1 = child1 + "1";
56 | child2 = child2 + "2";
57 | }
58 |
59 | String seenChild = (String)choose.either(child1, child2);
60 |
61 | boolean hasBoy = child1.startsWith("boy") || child2.startsWith("boy");
62 |
63 | if (hasBoy)
64 | {
65 | numTimesHasBoy++;
66 |
67 | if (seenChild.startsWith("boy"))
68 | {
69 | numTimesBoySeen++;
70 |
71 | if (child1.charAt(0) == child2.charAt(0)) // both boys
72 | numTimesTwoBoys++;
73 |
74 | if (seenChild == child1)
75 | System.out.println(numTimesBoySeen + ". see " + child1 + ", other " + child2
76 | + " " + (1000*numTimesTwoBoys)/numTimesBoySeen);
77 | else
78 | System.out.println(numTimesBoySeen + ". see " + child2 + ", other " + child1
79 | + " " + (1000*numTimesTwoBoys)/numTimesBoySeen);
80 | }
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/NOC/CODE/tabular/SymbolCounter.java:
--------------------------------------------------------------------------------
1 |
2 | package tabular;
3 |
4 | // This class implements atomic increment and decrement operations on an integer
5 | // wrapped in an object shell
6 |
7 | // Consider it a version of Integer than permits changes to its contents
8 |
9 | //(c) Tony Veale 2007
10 |
11 | import java.util.Vector;
12 |
13 | public class SymbolCounter extends AtomicCounter implements Comparable
14 | {
15 | String symbol = null;
16 |
17 | //-----------------------------------------------------------------//
18 | //-----------------------------------------------------------------//
19 | // Constructors
20 | //-----------------------------------------------------------------//
21 | //-----------------------------------------------------------------//
22 |
23 | public SymbolCounter(String symbol)
24 | {
25 | this(symbol, 0);
26 | }
27 |
28 | public SymbolCounter(String symbol, int start)
29 | {
30 | super(start);
31 |
32 | set(start);
33 |
34 | this.symbol = symbol.intern();
35 | }
36 |
37 | //-----------------------------------------------------------------//
38 | //-----------------------------------------------------------------//
39 | // Comparable Behavior
40 | //-----------------------------------------------------------------//
41 | //-----------------------------------------------------------------//
42 |
43 | public int compareTo(Object other)
44 | {
45 | if (other == null || !(other instanceof SymbolCounter))
46 | return 0;
47 |
48 | SymbolCounter otherSym = (SymbolCounter)other;
49 |
50 | if (value() < otherSym.value())
51 | return -1;
52 | else
53 | if (value() > otherSym.value())
54 | return +1;
55 | else
56 | return 0;
57 | }
58 |
59 |
60 | //-----------------------------------------------------------------//
61 | // Display Behavior
62 | //-----------------------------------------------------------------//
63 |
64 |
65 | public String toString()
66 | {
67 | return symbol + "(" + counter + ")";
68 | }
69 |
70 |
71 | //-----------------------------------------------------------------//
72 | // Accessors
73 | //-----------------------------------------------------------------//
74 |
75 | public boolean equals(Object other)
76 | {
77 | if (other == null || !(other instanceof SymbolCounter))
78 | return false;
79 |
80 | SymbolCounter comp = (SymbolCounter)other;
81 |
82 | if (symbol != comp.getSymbol())
83 | return false;
84 |
85 | return (counter == comp.value());
86 | }
87 |
88 |
89 | public boolean inList(Vector list)
90 | {
91 | if (list == null) return false;
92 |
93 | for (int i = list.size()-1; i >= 0; i--)
94 | {
95 | if (this.equals(list.elementAt(i)))
96 | return true;
97 | }
98 |
99 | return false;
100 | }
101 |
102 |
103 |
104 | public SymbolCounter copy()
105 | {
106 | return new SymbolCounter(symbol, counter);
107 | }
108 |
109 |
110 | public String getSymbol()
111 | {
112 | return symbol;
113 | }
114 |
115 |
116 | public void setSymbol(String sym)
117 | {
118 | symbol = sym.intern();
119 | }
120 |
121 |
122 |
123 | public boolean contains(char ch)
124 | {
125 | return symbol.indexOf((char)ch) > 0;
126 | }
127 |
128 |
129 | public String getModifier()
130 | {
131 | int dash = symbol.indexOf((int)'_');
132 |
133 | if (dash > 0)
134 | return symbol.substring(0, dash);
135 | else
136 | return symbol;
137 | }
138 |
139 |
140 | public String getHead()
141 | {
142 | int dash = symbol.lastIndexOf((int)'_');
143 |
144 | if (dash > 0)
145 | return symbol.substring(dash+1);
146 | else
147 | return symbol;
148 | }
149 |
150 |
151 | public String getPrefix()
152 | {
153 | int dash = symbol.indexOf((int)':');
154 |
155 | if (dash > 0)
156 | return symbol.substring(0, dash).intern();
157 | else
158 | return null;
159 | }
160 |
161 |
162 | public String getBody()
163 | {
164 | int dash = symbol.lastIndexOf((int)':');
165 |
166 | if (dash > 0)
167 | return symbol.substring(dash+1).intern();
168 | else
169 | return symbol;
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/NOC/CODE/tabular/SymbolLink.java:
--------------------------------------------------------------------------------
1 |
2 | package tabular;
3 |
4 | // This class implements atomic increment and decrement operations on an integer
5 | // wrapped in an object shell
6 |
7 | // This extension allows SymbolCounter objects to be linked in a list
8 |
9 | public class SymbolLink extends SymbolCounter
10 | {
11 | private SymbolLink next = null;
12 |
13 | //-----------------------------------------------------------------//
14 | //-----------------------------------------------------------------//
15 | // Constructors
16 | //-----------------------------------------------------------------//
17 | //-----------------------------------------------------------------//
18 |
19 | public SymbolLink(String symbol)
20 | {
21 | this(symbol, null, 0);
22 | }
23 |
24 | public SymbolLink(String symbol, int start)
25 | {
26 | this(symbol, null, start);
27 | }
28 |
29 |
30 | public SymbolLink(String symbol, SymbolLink next, int start)
31 | {
32 | super(symbol, start);
33 |
34 | this.next = next;
35 | }
36 |
37 | //-----------------------------------------------------------------//
38 | //-----------------------------------------------------------------//
39 | // Maintain next pointer
40 | //-----------------------------------------------------------------//
41 | //-----------------------------------------------------------------//
42 |
43 | public SymbolLink next()
44 | {
45 | return next;
46 | }
47 |
48 |
49 | public void setNext(SymbolLink next)
50 | {
51 | this.next = next;
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/NOC/CODE/tabular/TwoTieredTable.java:
--------------------------------------------------------------------------------
1 | package tabular;
2 |
3 | import java.util.Hashtable;
4 | import java.util.Vector;
5 |
6 | // Implements a two-level index via hashtables and vectors
7 |
8 | public class TwoTieredTable
9 | {
10 | private Hashtable table = new Hashtable();
11 |
12 | private Vector keys = new Vector();
13 |
14 | private String name = null;
15 |
16 | //---------------------------------------------------------------------//
17 | //---------------------------------------------------------------------//
18 | // Constructors
19 | //---------------------------------------------------------------------//
20 | //---------------------------------------------------------------------//
21 |
22 | public TwoTieredTable(String name)
23 | {
24 | this.name = name;
25 | }
26 |
27 |
28 | //---------------------------------------------------------------------//
29 | //---------------------------------------------------------------------//
30 | // Accessors
31 | //---------------------------------------------------------------------//
32 | //---------------------------------------------------------------------//
33 |
34 | public String getName()
35 | {
36 | return name;
37 | }
38 |
39 |
40 | public Vector getKeys()
41 | {
42 | return keys;
43 | }
44 |
45 |
46 | public boolean contains(String level1, String level2, String entry)
47 | {
48 | if (level1 == null || level2 == null || entry == null)
49 | return false;
50 |
51 | level1 = level1.intern();
52 | level2 = level2.intern();
53 | entry = entry.intern();
54 |
55 | Vector top = (Vector)table.get(level1),
56 | low = null;
57 |
58 | if (top == null) return false;
59 |
60 | for (int i = 0; i < top.size(); i++)
61 | {
62 | low = (Vector)top.elementAt(i);
63 |
64 | if (low == null || low.size() == 0 || low.elementAt(0) != level2)
65 | continue;
66 |
67 | for (int j = 1; j < low.size(); j++)
68 | if (low.elementAt(j) == entry)
69 | return true;
70 |
71 | return false;
72 | }
73 |
74 | // no top entry
75 |
76 | return false;
77 | }
78 |
79 |
80 |
81 | public boolean contains(String level1, String level2)
82 | {
83 | if (level1 == null || level2 == null)
84 | return false;
85 |
86 | level1 = level1.intern();
87 | level2 = level2.intern();
88 |
89 | Vector top = (Vector)table.get(level1),
90 | low = null;
91 |
92 | if (top == null) return false;
93 |
94 | for (int i = 0; i < top.size(); i++)
95 | {
96 | low = (Vector)top.elementAt(i);
97 |
98 | if (low != null && low.size() > 0 && low.elementAt(0) == level2)
99 | return true;
100 | }
101 |
102 | return false;
103 | }
104 |
105 |
106 | public Vector get(String level1, String level2)
107 | {
108 | if (level1 == null || level2 == null)
109 | return null;
110 |
111 | level1 = level1.intern();
112 | level2 = level2.intern();
113 |
114 | Vector top = (Vector)table.get(level1),
115 | low = null;
116 |
117 | if (top == null) return null;
118 |
119 | for (int i = 0; i < top.size(); i++)
120 | {
121 | low = (Vector)top.elementAt(i);
122 |
123 | if (low != null && low.size() > 0 && low.elementAt(0) == level2)
124 | {
125 | Vector copy = new Vector(low.size()-1);
126 |
127 | for (int j = 1; j < low.size(); j++)
128 | copy.addElement(low.elementAt(j));
129 |
130 | return copy;
131 | }
132 | }
133 |
134 | return null;
135 | }
136 |
137 |
138 | public Vector getSubkeys(String level1)
139 | {
140 | Vector top = (Vector)table.get(level1),
141 | low = null;
142 |
143 | if (top == null)
144 | return null;
145 |
146 | Vector subs = new Vector();
147 |
148 | for (int i = 0; i < top.size(); i++)
149 | {
150 | low = (Vector)top.elementAt(i);
151 |
152 | if (low != null && low.size() > 0)
153 | subs.addElement(low.elementAt(0));
154 | }
155 |
156 | return subs;
157 | }
158 |
159 |
160 | public Vector get(String key)
161 | {
162 | return (Vector)table.get(key);
163 | }
164 |
165 | //---------------------------------------------------------------------//
166 | //---------------------------------------------------------------------//
167 | // Modifiers
168 | //---------------------------------------------------------------------//
169 | //---------------------------------------------------------------------//
170 |
171 | public Vector put(String level1, String level2, String entry)
172 | {
173 | if (level1 == null || level2 == null || entry == null)
174 | return null;
175 |
176 | level1 = level1.intern();
177 | level2 = level2.intern();
178 | entry = entry.intern();
179 |
180 | Vector top = (Vector)table.get(level1),
181 | low = null;
182 |
183 | if (top == null)
184 | {
185 | top = new Vector();
186 | table.put(level1, top);
187 | keys.addElement(level1);
188 | }
189 |
190 | for (int i = 0; i < top.size(); i++)
191 | {
192 | low = (Vector)top.elementAt(i);
193 |
194 | if (low == null || low.size() == 0 || low.elementAt(0) != level2)
195 | continue;
196 |
197 | for (int j = 1; j < low.size(); j++)
198 | if (low.elementAt(j) == entry)
199 | return low;
200 |
201 | // if here, then entry is not present
202 |
203 | low.addElement(entry);
204 |
205 | return low;
206 | }
207 |
208 | // no top entry
209 |
210 | Vector branch = new Vector();
211 |
212 | branch.addElement(level2);
213 | branch.addElement(entry);
214 |
215 | top.addElement(branch);
216 |
217 | return branch;
218 | }
219 |
220 |
221 |
222 | public Vector remove(String level1, String level2, String entry)
223 | {
224 | if (level1 == null || level2 == null || entry == null)
225 | return null;
226 |
227 | level1 = level1.intern();
228 | level2 = level2.intern();
229 | entry = entry.intern();
230 |
231 | Vector top = (Vector)table.get(level1),
232 | low = null;
233 |
234 | if (top == null) return null;
235 |
236 | for (int i = 0; i < top.size(); i++)
237 | {
238 | low = (Vector)top.elementAt(i);
239 |
240 | if (low == null || low.size() == 0 || low.elementAt(0) != level2)
241 | continue;
242 |
243 | for (int j = 1; j < low.size(); j++)
244 | if (low.elementAt(j) == entry)
245 | {
246 | low.removeElementAt(j);
247 | return low;
248 | }
249 |
250 | return low;
251 | }
252 |
253 | return null;
254 | }
255 |
256 |
257 |
258 | public Vector remove(String level1, String level2)
259 | {
260 | if (level1 == null || level2 == null)
261 | return null;
262 |
263 | level1 = level1.intern();
264 | level2 = level2.intern();
265 |
266 | Vector top = (Vector)table.get(level1),
267 | low = null;
268 |
269 | if (top == null) return null;
270 |
271 | for (int i = 0; i < top.size(); i++)
272 | {
273 | low = (Vector)top.elementAt(i);
274 |
275 | if (low == null || low.size() == 0 || low.elementAt(0) != level2)
276 | continue;
277 |
278 | top.removeElementAt(i);
279 |
280 | return top;
281 | }
282 |
283 | return null;
284 | }
285 |
286 |
287 |
288 | public Vector remove(String level1)
289 | {
290 | if (level1 == null)
291 | return null;
292 |
293 | level1 = level1.intern();
294 |
295 | Vector top = (Vector)table.get(level1);
296 |
297 | if (top != null)
298 | {
299 | table.remove(level1);
300 | keys.remove(level1);
301 | }
302 |
303 | return top;
304 | }
305 | }
306 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/AffectiveProfile.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.InputStreamReader;
5 | import java.net.URL;
6 | import java.net.URLConnection;
7 | import java.util.Hashtable;
8 | import java.util.Vector;
9 |
10 | import tabular.CountTable;
11 | import tabular.SymbolMap;
12 |
13 | // Acquire affective dimensions of a Twitter user from a web-site
14 |
15 | public class AffectiveProfile
16 | {
17 | private final String baseURL = "http://analyzewords.com/index.php?handle=";
18 |
19 | private final String labelPrefix = "\"return nd();\">";
20 | private final String labelSuffix = " (";
21 |
22 | private final String valuePrefix = "title=\"";
23 | private final String valueSuffix = "\">";
24 |
25 | private CountTable dimensions = new CountTable(true);
26 |
27 | private String handle = null;
28 |
29 | //--------------------------------------------------------------------------//
30 | //--------------------------------------------------------------------------//
31 | // Constructors
32 | //--------------------------------------------------------------------------//
33 | //--------------------------------------------------------------------------//
34 |
35 | public AffectiveProfile(String handle)
36 | {
37 | if (handle.startsWith("@"))
38 | handle = handle.substring(1);
39 |
40 | this.handle = handle;
41 |
42 | scrapeAffectWebsite(baseURL + handle);
43 | }
44 |
45 |
46 | public AffectiveProfile(String handle, KnowledgeBaseModule transformulas)
47 | {
48 | this(handle);
49 |
50 | calculateTransFormulas(transformulas);
51 | }
52 |
53 | //--------------------------------------------------------------------------//
54 | //--------------------------------------------------------------------------//
55 | // Access Methods
56 | //--------------------------------------------------------------------------//
57 | //--------------------------------------------------------------------------//
58 |
59 | public String getHandle()
60 | {
61 | return handle;
62 | }
63 |
64 |
65 | public int getValue(String dimName)
66 | {
67 | return dimensions.getCount(dimName);
68 | }
69 |
70 |
71 | public Vector getSortedDimensions()
72 | {
73 | return SymbolMap.getSorted(dimensions.getKeyList());
74 | }
75 |
76 |
77 | public Vector getDimensions()
78 | {
79 | return dimensions.getKeyList();
80 | }
81 |
82 | //--------------------------------------------------------------------------//
83 | //--------------------------------------------------------------------------//
84 | // Calculate derived (jnferred) qualities using transformational formulas
85 | //--------------------------------------------------------------------------//
86 | //--------------------------------------------------------------------------//
87 |
88 |
89 | private void calculateTransFormulas(KnowledgeBaseModule transformulas)
90 | {
91 | Vector quals = transformulas.getAllFrames();
92 |
93 | for (int q = 0; q < quals.size(); q++)
94 | {
95 | String quality = (String)quals.elementAt(q);
96 |
97 | Vector formulas = transformulas.getFieldValues("Formulas", quality);
98 |
99 | if (formulas == null) continue;
100 |
101 | int prev = getValue(quality);
102 |
103 | for (int f = 0; f < formulas.size(); f++)
104 | {
105 | String formula = (String)formulas.elementAt(f);
106 |
107 | int value = calculateFormula(formula);
108 |
109 | System.out.println(quality + " (" + formula + ") = " + value);
110 |
111 | if (value > prev)
112 | dimensions.putMax(quality, value);
113 | }
114 | }
115 | }
116 |
117 |
118 | private int calculateFormula(String formula)
119 | {
120 | int amp = formula.indexOf((int)'&');
121 |
122 | if (amp > 0)
123 | return Math.min(calculateFormula(formula.substring(0, amp)),
124 | calculateFormula(formula.substring(amp+1)));
125 |
126 | if (formula.startsWith("-"))
127 | return 100 - calculateFormula(formula.substring(1));
128 |
129 | return getValue(formula);
130 | }
131 |
132 | //--------------------------------------------------------------------------//
133 | //--------------------------------------------------------------------------//
134 | // Scrape the relevant website
135 | //--------------------------------------------------------------------------//
136 | //--------------------------------------------------------------------------//
137 |
138 | private void scrapeAffectWebsite(String pageURL)
139 | {
140 | try {
141 | URL website = new URL(pageURL);
142 |
143 | URLConnection conn = website.openConnection();
144 |
145 | conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2");
146 |
147 | BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
148 |
149 | String inputLine = null;
150 |
151 | System.out.println(pageURL);
152 |
153 | while ((inputLine = in.readLine()) != null)
154 | {
155 | //System.out.println(inputLine);
156 |
157 | int labpfixPos = inputLine.indexOf(labelPrefix);
158 |
159 | while (labpfixPos >= 0)
160 | {
161 | int labsfixPos = inputLine.indexOf(labelSuffix, labpfixPos + labelPrefix.length());
162 |
163 | if (labsfixPos > 0)
164 | {
165 | int valpfixPos = inputLine.indexOf(valuePrefix, labsfixPos + labelSuffix.length());
166 |
167 | if (valpfixPos > 0)
168 | {
169 | int valsfixPos = inputLine.indexOf(valueSuffix, valpfixPos + valuePrefix.length());
170 |
171 | if (valsfixPos > 0)
172 | {
173 | setDimension(inputLine.substring(labpfixPos + labelPrefix.length(), labsfixPos),
174 | inputLine.substring(valpfixPos + valuePrefix.length(), valsfixPos));
175 | }
176 | }
177 | }
178 |
179 | labpfixPos = inputLine.indexOf(labelPrefix, labpfixPos+1);
180 | }
181 | }
182 | }
183 | catch (Exception e) {
184 | e.printStackTrace();
185 | }
186 | }
187 |
188 |
189 |
190 | private void setDimension(String dimName, String dimValue)
191 | {
192 | if (dimValue == null || dimValue.length() < 1 || !Character.isDigit(dimValue.charAt(0)))
193 | return;
194 |
195 | int slash = dimName.indexOf((int)'/');
196 |
197 | if (slash > 0)
198 | {
199 | setDimension(dimName.substring(0, slash), dimValue);
200 | setDimension(dimName.substring(slash+1), dimValue);
201 | }
202 | else
203 | dimensions.put(cleanDmmensionName(dimName), Integer.parseInt(dimValue));
204 | }
205 |
206 |
207 | private String cleanDmmensionName(String dimName)
208 | {
209 | StringBuffer clean = new StringBuffer(dimName.toLowerCase());
210 |
211 | for (int c = 0; c < clean.length(); c++)
212 | if (dimName.charAt(c) == '-' || dimName.charAt(c) == ' ')
213 | clean.setCharAt(c, '_');
214 |
215 | return clean.toString();
216 | }
217 |
218 |
219 | //--------------------------------------------------------------------------//
220 | //--------------------------------------------------------------------------//
221 | // Main application stub
222 | //--------------------------------------------------------------------------//
223 | //--------------------------------------------------------------------------//
224 |
225 | public static void main(String[] args)
226 | {
227 | String handle = "@MetaphorMagnet";
228 | String kdir = "/Users/tonyveale/Dropbox/CodeCamp2016/NOC/DATA/TSV Lists/";
229 |
230 | KnowledgeBaseModule transformulas = new KnowledgeBaseModule(kdir + "Veale's ranked quality classifications.txt");
231 |
232 | AffectiveProfile profile = new AffectiveProfile(handle, transformulas);
233 |
234 | System.out.println("Upbeat" + " = " + profile.getValue("upbeat"));
235 | System.out.println("Worried" + " = " + profile.getValue("worried"));
236 | System.out.println("Angry" + " = " + profile.getValue("angry"));
237 | System.out.println("Depressed" + " = " + profile.getValue("depressed"));
238 | System.out.println("Plugged In" + " = " + profile.getValue("plugged_in"));
239 | System.out.println("Personable" + " = " + profile.getValue("personable"));
240 | System.out.println("Arrogant" + " = " + profile.getValue("arrogant"));
241 | System.out.println("Distant" + " = " + profile.getValue("distant"));
242 | System.out.println("Spacy" + " = " + profile.getValue("spacy"));
243 | System.out.println("Analytic" + " = " + profile.getValue("analytic"));
244 | System.out.println("Sensory" + " = " + profile.getValue("sensory"));
245 | System.out.println("In-the-moment" + " = " + profile.getValue("in_the_moment"));
246 |
247 | System.out.println(profile.getSortedDimensions());
248 |
249 | }
250 |
251 | }
252 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/BestOfBotWorlds.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 |
4 | public class BestOfBotWorlds
5 | {
6 | private static String CONSUMER_KEY = "EOnEROGRPUfRIAhCbAoIyMiCe";
7 | private static String ACCESS_TOKEN = "3434394268-uY9T1FaztoPfThqv09vzExrVAYJXsCelQpeYYsX";
8 |
9 |
10 | //--------------------------------------------------------------------------------------------------//
11 | //--------------------------------------------------------------------------------------------------//
12 | // Main Application Stub
13 | //--------------------------------------------------------------------------------------------------//
14 | //--------------------------------------------------------------------------------------------------//
15 |
16 | // In Documents/Workspace/WordNetBrowser
17 |
18 |
19 | public static void main(String[] args)
20 | {
21 | String dir = "/Users/tonyveale/Desktop/Lexical Resources/Moods/";
22 |
23 | TweetLaunchpadWithEmoji generator = new TweetLaunchpadWithEmoji(dir, CONSUMER_KEY,
24 | args[0], // CONSUMER_SECRET,
25 | ACCESS_TOKEN,
26 | args[1]); // ACCESS_SECRET;
27 |
28 | generator.loadSpace(dir + "Venn diagram 1 tweets.idx", "Venn 1");
29 | generator.loadSpace(dir + "Venn diagram 2 tweets.idx", "Venn 2");
30 | generator.loadSpace(dir + "Venn diagram 3 tweets.idx", "Venn 3");
31 | generator.loadSpace(dir + "Venn diagram 4 tweets.idx", "Venn 4");
32 | generator.loadSpace(dir + "Venn diagram 5 tweets.idx", "Venn 5");
33 | generator.loadSpace(dir + "narrative 5-step joint tweets.idx", "Venn joint");
34 | generator.loadSpace(dir + "Yoda transformation tweets.idx", "Yoda transformation");
35 | generator.loadSpace(dir + "Jesus transformation tweets.idx", "Jesus transformation");
36 | generator.loadSpace(dir + "Buddha transformation tweets.idx", "Buddha transformation");
37 | generator.loadSpace(dir + "Lamarck transformation tweets.idx", "Lamarck transformation");
38 | generator.loadSpace(dir + "Jesus contrast tweets.idx", "Jesus contrast");
39 | generator.loadSpace(dir + "Boromir walking tweets.idx", "Boromir");
40 | generator.loadSpace(dir + "every Islam tweet.idx", "Islam");
41 | generator.loadSpace(dir + "NOC epitaph tweets.idx", "epitaphs");
42 | generator.loadSpace(dir + "Jesus 3-gram tweets.idx", "3-grams");
43 | generator.loadSpace(dir + "Jesus 4-gram tweets.idx", "4-grams");
44 | generator.loadSpace(dir + "every religion tweet.idx", "generic");
45 | generator.loadSpace(dir + "every business tweet.idx", "business");
46 | generator.loadSpace(dir + "narrative karmic animal tweets.idx", "karma");
47 | generator.loadSpace(dir + "Hulk smash tweets.idx", "Hulk");
48 | generator.loadSpace(dir + "NOC Hulk tweets.idx", "Hulk NOC");
49 | generator.loadSpace(dir + "Successful habits tweets.idx", "habits");
50 | generator.loadSpace(dir + "Commandment tweets.idx", "Moses");
51 | generator.loadSpace(dir + "narrative animal scripted tweets.idx", "animal scripts");
52 | generator.loadSpace(dir + "narrative animal pairs tweets.idx", "animal sequences");
53 | generator.loadSpace(dir + "narrative animal emoji tweets.idx", "animal emoji");
54 | generator.loadSpace(dir + "narrative recursive NOC tweets.idx", "animal NOC emoji"); // "recursive" was "animal"
55 | generator.loadSpace(dir + "theme identity tweets.idx", "thematic identities");
56 | generator.loadSpace(dir + "theme identity 3 tweets.idx", "thematic identities 3");
57 | generator.loadSpace(dir + "theme identity 4 tweets.idx", "thematic identities 4");
58 | generator.loadSpace(dir + "theme identity 3 tweets with actors.idx", "thematic identities 3 actors");
59 | generator.loadSpace(dir + "theme identity 4 tweets with actors.idx", "thematic identities 4 actors");
60 | generator.loadSpace(dir + "criss-cross tweets.idx", "criss-cross");
61 | generator.loadSpace(dir + "narrative 5-step full tweets.idx", "Venn full");
62 | generator.loadSpace(dir + "narrative 4-step others tweets.idx", "Venn 4-others");
63 | generator.loadSpace(dir + "RGB NOC color tweets.idx", "RGB NOC");
64 | generator.loadSpace(dir + "RGB stereo color tweets.idx", "RGB stereo");
65 |
66 | String[] tweetTypes = {"RGB NOC", "RGB stereo", "Venn 4-others", "Venn full", "Venn joint", "Venn 1", "Venn 2", "Venn 3", "Venn 4", "Venn 5",
67 | "thematic identities", "thematic identities 3 actors", "thematic identities 4 actors", "thematic identities 3",
68 | "thematic identities 4", "animal NOC emoji", "animal emoji", "business", "animal scripts", "Moses", "habits", "Hulk NOC|Hulk",
69 | "Boromir", "Lamarck transformation", "epitaphs", //"generic", "animal sequences",
70 | "business", "Buddha transformation", "Islam", "karma", "Jesus contrast", "3-grams", "4-grams",
71 | "Yoda transformation", "Jesus transformation"};
72 |
73 | System.out.println("\n\nTweet Generator version: " + TweetLaunchpad.VERSION + "\n");
74 |
75 |
76 | generator.analyzeTimeline("BestOfBotWorlds", 10);
77 |
78 | generator.startTweeting(1000000, 60*60*1000, tweetTypes);
79 |
80 | /*
81 | for (int t = 0; t < 1; t++) //tweetTypes.length
82 | {
83 | for (int i = 0 ; i < 100; i++)
84 | {
85 | String next = generator.getLeastRecentRandomCandidate(tweetTypes[t], 100), setup = null, followup = null;
86 |
87 | int divider = next.indexOf((int)'\t');
88 |
89 | if (divider > 0)
90 | {
91 | setup = next.substring(0, divider);
92 | followup = next.substring(setup.length()+1);
93 | }
94 | else
95 | {
96 | setup = next;
97 | followup = next;
98 | }
99 |
100 | System.out.println("\nTweet " + i + ":\n" + setup);
101 |
102 | if (!followup.equals(setup))
103 | System.out.println(followup);
104 |
105 | generator.advanceCounter();
106 |
107 | generator.updateCounts(next);
108 | }
109 | }
110 |
111 | */
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/BotOnBotAction.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 |
4 | public class BotOnBotAction
5 | {
6 | private static String CONSUMER_KEY = "ArBtWs6QeIOrDU6cNj4TTmWJK";
7 | private static String ACCESS_TOKEN = "752908753721237504-KrZ3GaCG30jokaDhYKLGxRvonadZMbm";
8 |
9 | //--------------------------------------------------------------------------------------------------//
10 | //--------------------------------------------------------------------------------------------------//
11 | // Main Application Stub
12 | //--------------------------------------------------------------------------------------------------//
13 | //--------------------------------------------------------------------------------------------------//
14 |
15 | // In Documents/Workspace/WordNetBrowser
16 |
17 | // Command Line: /usr/bin/java -classpath ../:./:../twitter4j-4.0.1/lib/twitter4j-core-4.0.1.jar:../twitter4j-4.0.1/lib/twitter4j-stream-4.0.1.jar twitterbotics.BotOnBotAction
18 |
19 |
20 | public static void main(String[] args)
21 | {
22 | String dir = "/Users/tonyveale/Desktop/Lexical Resources/Moods/";
23 |
24 | TweetLaunchpad generator = new TweetLaunchpad(CONSUMER_KEY,
25 | args[0], // CONSUMER_SECRET,
26 | ACCESS_TOKEN,
27 | args[1]); // ACCESS_SECRET;
28 |
29 | generator.loadSpace(dir + "Venn diagram 1 tweets.idx", "Venn 1");
30 | generator.loadSpace(dir + "Venn diagram 2 tweets.idx", "Venn 2");
31 | generator.loadSpace(dir + "Venn diagram 3 tweets.idx", "Venn 3");
32 | generator.loadSpace(dir + "Venn diagram 4 tweets.idx", "Venn 4");
33 | generator.loadSpace(dir + "Venn diagram 5 tweets.idx", "Venn 5");
34 | generator.loadSpace(dir + "narrative 4-step tweets.idx", "Venn 4-step");
35 | generator.loadSpace(dir + "narrative 5-step tweets.idx", "Venn 5-step");
36 | generator.loadSpace(dir + "narrative 5-step joint tweets.idx", "Venn joint");
37 | generator.loadSpace(dir + "narrative 5-step full tweets.idx", "Venn full");
38 | generator.loadSpace(dir + "narrative 5-step workplace tweets.idx", "Venn workplace");
39 | generator.loadSpace(dir + "narrative 5-step nesting tweets.idx", "Venn nesting");
40 | generator.loadSpace(dir + "narrative 5-step left tweets.idx", "Venn left");
41 | generator.loadSpace(dir + "narrative 5-step right tweets.idx", "Venn right");
42 | generator.loadSpace(dir + "narrative 5-step marriage tweets.idx", "Venn marriage");
43 | generator.loadSpace(dir + "narrative 5-step divorce tweets.idx", "Venn divorce");
44 | generator.loadSpace(dir + "narrative 4-step label tweets.idx", "Venn 4-label");
45 | generator.loadSpace(dir + "narrative 4-step others tweets.idx", "Venn 4-others");
46 | generator.loadSpace(dir + "RGB 2 color tweets.idx", "RGB 2-color");
47 | generator.loadSpace(dir + "RGB NOC color tweets.idx", "RGB NOC");
48 | generator.loadSpace(dir + "RGB stereo color tweets.idx", "RGB stereo");
49 | generator.loadSpace(dir + "RGB colourlovers tweets.idx", "RGB lovers");
50 | generator.loadSpace(dir + "RGB monochromatic wallpaper tweets.idx", "RGB monochrome");
51 |
52 | String[] tweetTypes = {"RGB lovers", "RGB stereo", "RGB NOC", "RGB 2-color", "Venn 4-others", "Venn 4-label",
53 | "Venn left", "Venn nesting", "Venn full", "Venn joint", "Venn 5-step", "Venn 4-step", "Venn 1", "Venn 2", "Venn 3",
54 | "RGB NOC", "Venn right", "Venn 4", "RGB 2-color", "Venn workplace", "Venn 5", "RGB lovers", "RGB stereo",
55 | "Venn divorce", "Venn marriage"};
56 |
57 | System.out.println("\n\nTweet Generator version: " + TweetLaunchpad.VERSION + "\n");
58 |
59 | generator.analyzeTimeline("BotOnBotAction", 10);
60 |
61 | generator.startTweeting(1000000, 60*60*1000, tweetTypes);
62 |
63 | /*
64 | for (int t = 0; t < 1; t++) //tweetTypes.length
65 | {
66 | for (int i = 0 ; i < 100; i++)
67 | {
68 | String next = generator.getLeastRecentRandomCandidate(tweetTypes[t], 100), setup = null, followup = null;
69 |
70 | int divider = next.indexOf((int)'\t');
71 |
72 | if (divider > 0)
73 | {
74 | setup = next.substring(0, divider);
75 | followup = next.substring(setup.length()+1);
76 | }
77 | else
78 | {
79 | setup = next;
80 | followup = next;
81 | }
82 |
83 | System.out.println("\nTweet " + i + ":\n" + setup);
84 |
85 | if (!followup.equals(setup))
86 | System.out.println(followup);
87 |
88 | generator.advanceCounter();
89 |
90 | generator.updateCounts(next);
91 | }
92 | }
93 | */
94 |
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/CellularAutomaton.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | // Implement a simple 1-dimensional mult-istate cellular automaton that changes from
4 | // one generation (one line of neighboring cells) to the next
5 |
6 | import java.util.Random;
7 |
8 |
9 | public class CellularAutomaton {
10 |
11 | private Random RND = new Random();
12 |
13 | private int numStates = 0;
14 | private int numGenerations = 0;
15 | private int numCells = 0;
16 |
17 | private int[] rules = null;
18 | private int[][] generations = null;
19 |
20 | //--------------------------------------------------------------------------//
21 | //--------------------------------------------------------------------------//
22 | // Constructors
23 | //--------------------------------------------------------------------------//
24 | //--------------------------------------------------------------------------//
25 |
26 | public CellularAutomaton(int numStates, int numGenerations, int numCells)
27 | {
28 | this.numStates = numStates;
29 | this.numGenerations = numGenerations;
30 | this.numCells = numCells;
31 |
32 | rules = new int[numStates*numStates*numStates];
33 | generations = new int[numGenerations][numCells];
34 |
35 | run();
36 | }
37 |
38 |
39 | //--------------------------------------------------------------------------//
40 | //--------------------------------------------------------------------------//
41 | // Do a complete run of the automaton for all of the specified generations
42 | //--------------------------------------------------------------------------//
43 | //--------------------------------------------------------------------------//
44 |
45 | public void run()
46 | {
47 | initializeRandomRules();
48 | initializeGenerationZero();
49 | updateAllGenerations();
50 | }
51 |
52 | //--------------------------------------------------------------------------//
53 | //--------------------------------------------------------------------------//
54 | // Create Random rules
55 | // Each rule maps a triple of left-neighbor+cell+right-neighbor onto a state
56 | //--------------------------------------------------------------------------//
57 | //--------------------------------------------------------------------------//
58 |
59 | private void initializeRandomRules()
60 | {
61 | for (int r = 0; r < rules.length; r++)
62 | rules[r] = RND.nextInt(numStates);
63 | }
64 |
65 | //--------------------------------------------------------------------------//
66 | //--------------------------------------------------------------------------//
67 | // Initialize Generation 0 to a random set of states (one per cell)
68 | //--------------------------------------------------------------------------//
69 | //--------------------------------------------------------------------------//
70 |
71 | private void initializeGenerationZero()
72 | {
73 | for (int c = 0; c < numCells; c++)
74 | generations[0][c] = RND.nextInt(numStates);
75 | }
76 |
77 |
78 | //--------------------------------------------------------------------------//
79 | //--------------------------------------------------------------------------//
80 | // Access methods
81 | //--------------------------------------------------------------------------//
82 | //--------------------------------------------------------------------------//
83 |
84 | public int getNumGenerations() {
85 | return numGenerations;
86 | }
87 |
88 | public int getNumStates() {
89 | return numStates;
90 | }
91 |
92 | public int getNumCells() {
93 | return numCells;
94 | }
95 |
96 | //--------------------------------------------------------------------------//
97 | //--------------------------------------------------------------------------//
98 | // Access the cells in any generation
99 | //--------------------------------------------------------------------------//
100 | //--------------------------------------------------------------------------//
101 |
102 | public int getGenX(int generation, int cellX)
103 | {
104 | if (cellX < 0) // wrap around from far left to far right
105 | cellX = numCells + cellX;
106 |
107 | if (cellX >= numCells) // wrap around from far right to far left
108 | cellX = cellX - numCells;
109 |
110 | return generations[generation][cellX];
111 | }
112 |
113 |
114 | //--------------------------------------------------------------------------//
115 | //--------------------------------------------------------------------------//
116 | // Update cells in each and every generation
117 | //--------------------------------------------------------------------------//
118 | //--------------------------------------------------------------------------//
119 |
120 | private void updateAllGenerations()
121 | {
122 | for (int g = 1; g < numGenerations; g++)
123 | updateGeneration(g);
124 | }
125 |
126 |
127 |
128 | private void updateGeneration(int generation)
129 | {
130 | for (int c = 0; c < numCells; c++)
131 | updateCell(generation, c);
132 | }
133 |
134 |
135 |
136 | // Update the cell in generation g > 0
137 |
138 | private void updateCell(int generation, int cellX)
139 | {
140 | if (generation < 0 || generation >= numGenerations)
141 | return;
142 |
143 | int left = getGenX(generation-1, cellX-1), middle = getGenX(generation-1, cellX), right = getGenX(generation-1, cellX+1);
144 |
145 | int ruleNum = right + numStates*middle + numStates*numStates*left;
146 |
147 | generations[generation][cellX] = rules[ruleNum];
148 | }
149 |
150 |
151 | //--------------------------------------------------------------------------//
152 | //--------------------------------------------------------------------------//
153 | // Print all generations from top (gen 0) to bottom (last gen)
154 | //--------------------------------------------------------------------------//
155 | //--------------------------------------------------------------------------//
156 |
157 | public void printGeneration(int generation)
158 | {
159 | for (int c = 0; c < numCells; c++)
160 | System.out.print(generations[generation][c]);
161 |
162 | System.out.println();
163 | }
164 |
165 |
166 |
167 | public void printGenerations()
168 | {
169 | for (int g = 0; g < numGenerations; g++)
170 | printGeneration(g);
171 | }
172 |
173 |
174 | //--------------------------------------------------------------------------//
175 | //--------------------------------------------------------------------------//
176 | // Return the percentage of the state with the smallest presence overall
177 | //--------------------------------------------------------------------------//
178 | //--------------------------------------------------------------------------//
179 |
180 |
181 | public int getSmallestPercentage()
182 | {
183 | int[] states = new int[numStates];
184 |
185 | for (int g = 0; g < numGenerations; g++)
186 | for (int c = 0; c < numCells; c++)
187 | states[generations[g][c]]++;
188 |
189 | int max = numGenerations*numCells, min = max;
190 |
191 | for (int s = 0; s < numStates; s++)
192 | if (states[s] < min)
193 | min = states[s];
194 |
195 | return (min*100)/max;
196 | }
197 |
198 |
199 | //--------------------------------------------------------------------------//
200 | //--------------------------------------------------------------------------//
201 | // Main stub for testing
202 | //--------------------------------------------------------------------------//
203 | //--------------------------------------------------------------------------//
204 |
205 | public static void main(String[] args)
206 | {
207 | CellularAutomaton celly = new CellularAutomaton(2, 35, 50);
208 |
209 | while (celly.getSmallestPercentage() < 25)
210 | celly.run();
211 |
212 | celly.printGenerations();
213 | }
214 | }
215 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/ColorLexicon.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | // Maintain a random-access lexicon of color stereotypes (e.g. lemon, sky, grass, blood, etc.)
4 |
5 | import java.awt.Color;
6 | import java.io.BufferedReader;
7 | import java.io.FileInputStream;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 | import java.io.InputStreamReader;
11 | import java.util.Hashtable;
12 | import java.util.Random;
13 | import java.util.StringTokenizer;
14 | import java.util.Vector;
15 |
16 | import tabular.BucketTable;
17 |
18 |
19 |
20 | public class ColorLexicon extends Dribbler
21 | {
22 | private static Random RND = new Random();
23 |
24 | private Hashtable stereoHues = new Hashtable();
25 |
26 | private Hashtable stereoHueRGB = new Hashtable();
27 |
28 | private Hashtable hueStereos = new Hashtable();
29 |
30 | private Vector stereoList = new Vector();
31 |
32 | //--------------------------------------------------------------------------//
33 | //--------------------------------------------------------------------------//
34 | // Constructors
35 | //--------------------------------------------------------------------------//
36 | //--------------------------------------------------------------------------//
37 |
38 | public ColorLexicon(String filename)
39 | {
40 | loadLexicon(filename);
41 | }
42 |
43 |
44 | //--------------------------------------------------------------------------//
45 | //--------------------------------------------------------------------------//
46 | // Access the Lexicon
47 | //--------------------------------------------------------------------------//
48 | //--------------------------------------------------------------------------//
49 |
50 | public void clear()
51 | {
52 | stereoHues.clear();
53 | stereoHueRGB.clear();
54 | stereoList.setSize(0);
55 | }
56 |
57 |
58 | public Vector getStereoList()
59 | {
60 | return stereoList;
61 | }
62 |
63 |
64 | public Vector getHuesFor(String stereo)
65 | {
66 | Vector hues = (Vector)stereoHues.get(stereo);
67 |
68 | // Deal with the complex situation in which the "stereo" is a multi-word proper-named individal
69 | if (hues == null)
70 | {
71 | int dash = stereo.indexOf((int)'_');
72 |
73 | if (dash < 0) return null;
74 |
75 | String fore = stereo.substring(0, dash), aft = stereo.substring(dash+1);
76 |
77 | if (getRGBFor(fore, aft) != null)
78 | {
79 | hues = new Vector();
80 | hues.add(aft);
81 | }
82 | }
83 |
84 | return hues;
85 | }
86 |
87 |
88 | public Vector getStereosFor(String hue)
89 | {
90 | return (Vector)hueStereos.get(hue);
91 | }
92 |
93 |
94 | public String getRGBFor(String stereo, String hue)
95 | {
96 | String rgb = (String)stereoHueRGB.get(stereo + "-" + hue);
97 |
98 | // Deal with the complex situation in which the "stereo" is a multi-word proper-named individal
99 | if (rgb == null)
100 | {
101 | int dash = stereo.indexOf((int)'_');
102 |
103 | if (dash < 0) return null;
104 |
105 | String fore = stereo.substring(0, dash), aft = stereo.substring(dash+1);
106 |
107 | if (aft.equals(hue))
108 | rgb = (String)stereoHueRGB.get(fore + "-" + aft);
109 | }
110 |
111 | return rgb;
112 | }
113 |
114 |
115 | public String getRandomStereoForHue(String hue)
116 | {
117 | Vector stereos = (Vector)hueStereos.get(hue);
118 |
119 | if (stereos == null) return null;
120 |
121 | if (stereos.size() == 0) return (String)stereos.elementAt(0);
122 |
123 | return (String)stereos.elementAt(RND.nextInt(stereos.size()));
124 | }
125 |
126 |
127 | public Vector getPaletteFrom(String tweet)
128 | {
129 | Vector palette = null;
130 |
131 | StringTokenizer tokens = new StringTokenizer(tweet.toLowerCase(), " \t\"'.,[]()-*&;");
132 |
133 | while (tokens.hasMoreTokens())
134 | {
135 | String token = tokens.nextToken();
136 |
137 | if (getStereosFor(token) == null) continue;
138 |
139 | token = token.intern();
140 |
141 | if (palette == null) palette = new Vector();
142 |
143 | if (!palette.contains(token))
144 | palette.add(token);
145 | }
146 |
147 | return palette;
148 | }
149 |
150 |
151 | //--------------------------------------------------------------------------//
152 | //--------------------------------------------------------------------------//
153 | // Some color names are complex and may be the names of proper individuals
154 | //--------------------------------------------------------------------------//
155 | //--------------------------------------------------------------------------//
156 |
157 |
158 | public boolean isColorName(String name)
159 | {
160 | Vector hues = (Vector)stereoHues.get(name);
161 |
162 | if (hues != null && hues.size() > 0) return true;
163 |
164 | int dash = name.indexOf((int)'_');
165 |
166 | if (dash > 0)
167 | {
168 | String fore = (String)name.substring(0, dash);
169 | String aft = (String)name.substring(dash+1);
170 |
171 | return getRGBFor(fore, aft) != null;
172 | }
173 |
174 | return false;
175 | }
176 |
177 |
178 | // E.g. Given Ed Wood #663300 the resolution of Wood (#663300) is Wood-brown
179 |
180 | public String resolveStereoHue(String stereo, String givenHue, String rgb)
181 | {
182 | String hue = resolveHue(givenHue, rgb);
183 |
184 | if (stereo.toLowerCase().endsWith(hue.toLowerCase()))
185 | return stereo;
186 | else
187 | if (stereo.endsWith("_" + givenHue) && hue.startsWith(givenHue + "-"))
188 | return stereo + hue.substring(givenHue.length());
189 | else
190 | return stereo + "-" + hue;
191 | }
192 |
193 |
194 |
195 | public String resolveHue(String givenHue, String rgb)
196 | {
197 | String hue = givenHue;
198 | Vector otherHues = (Vector)stereoHues.get(hue); // e.g. Simpson --> [yellow]
199 |
200 | if (otherHues == null && Character.isUpperCase(givenHue.charAt(0)))
201 | {
202 | hue = givenHue.toLowerCase(); // e.g. Wood --> wood
203 | otherHues = (Vector)stereoHues.get(hue); // e.g. wood --> [brown], moss --> [green]
204 | }
205 |
206 | if (otherHues == null) return givenHue;
207 |
208 | for (int rh = 0; rh < otherHues.size(); rh++)
209 | {
210 | String other = (String)otherHues.elementAt(rh); // e.g. wood --> brown, moss --> green
211 |
212 | String otherRGB = getRGBFor(hue, other); // e.g. wood,brown --> 663300
213 |
214 | if (rgb.equals(otherRGB))
215 | return givenHue + "-" + other;
216 | }
217 |
218 | return givenHue;
219 | }
220 |
221 |
222 |
223 | //--------------------------------------------------------------------------//
224 | //--------------------------------------------------------------------------//
225 | // Given a property (Adjective) return a list of apt color stereotypes
226 | //--------------------------------------------------------------------------//
227 | //--------------------------------------------------------------------------//
228 |
229 |
230 | public Vector getColorTermsForProperty(String property, BucketTable propertyModel)
231 | {
232 | Vector terms = null, candidates = propertyModel.get(property);
233 |
234 | if (candidates == null) return terms;
235 |
236 | for (int c = 0; c < candidates.size(); c++)
237 | {
238 | String candidate = (String)candidates.elementAt(c);
239 |
240 | if (isColorName(candidate))
241 | {
242 | if (terms == null)
243 | terms = new Vector();
244 |
245 | if (candidate.hashCode() < property.hashCode()) // vary the ordering of elements in the list
246 | terms.add(candidate);
247 | else
248 | terms.insertElementAt(candidate, 0);
249 | }
250 | }
251 |
252 | return terms;
253 | }
254 |
255 |
256 | //--------------------------------------------------------------------------//
257 | //--------------------------------------------------------------------------//
258 | // Determine how close two RGB colors are in 3D RGB space
259 | //--------------------------------------------------------------------------//
260 | //--------------------------------------------------------------------------//
261 |
262 | public int getDistanceBetween(String hex1, String hex2)
263 | {
264 | if (hex1.startsWith("#")) hex1 = hex1.substring(1);
265 | if (hex2.startsWith("#")) hex2 = hex2.substring(1);
266 |
267 | if (hex1.length() != 6 || hex2.length() != 6)
268 | return 0;
269 |
270 | int r1 = getHexValue(hex1.charAt(0))*16 + getHexValue(hex1.charAt(1));
271 | int g1 = getHexValue(hex1.charAt(2))*16 + getHexValue(hex1.charAt(3));
272 | int b1 = getHexValue(hex1.charAt(4))*16 + getHexValue(hex1.charAt(5));
273 |
274 | int r2 = getHexValue(hex2.charAt(0))*16 + getHexValue(hex2.charAt(1));
275 | int g2 = getHexValue(hex2.charAt(2))*16 + getHexValue(hex2.charAt(3));
276 | int b2 = getHexValue(hex2.charAt(4))*16 + getHexValue(hex2.charAt(5));
277 |
278 | return (int)Math.sqrt((r1-r2)*(r1-r2) + (b1-b2)*(b1-b2) + (g1-g2)*(g1-g2));
279 | }
280 |
281 |
282 | private int getHexValue(char code)
283 | {
284 | if (code >= 'A')
285 | return 10 + code - 'A';
286 |
287 | if (code >= '0')
288 | return code - '0';
289 |
290 | return 0;
291 | }
292 |
293 |
294 |
295 |
296 | //--------------------------------------------------------------------------//
297 | //--------------------------------------------------------------------------//
298 | // Load the Lexicon
299 | //--------------------------------------------------------------------------//
300 | //--------------------------------------------------------------------------//
301 |
302 |
303 | public Vector loadLexicon(String filename)
304 | {
305 | try {
306 | BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "UTF-8"));
307 |
308 | String line = null;
309 |
310 | while (input.ready()) // Read a line at a time
311 | {
312 | line = input.readLine();
313 |
314 | if (line == null || line.length() == 0 || line.startsWith("#"))
315 | continue;
316 |
317 | StringTokenizer tokens = new StringTokenizer(line, "\t\n,", false);
318 |
319 | while (tokens.hasMoreTokens())
320 | {
321 | String stereo = tokens.nextToken().trim().intern();
322 | String hue = tokens.nextToken().trim().intern();
323 | String rgb = tokens.nextToken().trim().intern();
324 |
325 | Vector huelist = (Vector)stereoHues.get(stereo);
326 |
327 | if (huelist == null)
328 | {
329 | huelist = new Vector();
330 | stereoHues.put(stereo, huelist);
331 | stereoList.add(stereo);
332 | }
333 |
334 | if (!huelist.contains(hue))
335 | huelist.add(hue);
336 |
337 | Vector stereoList = (Vector)hueStereos.get(hue);
338 |
339 | if (stereoList == null)
340 | {
341 | stereoList = new Vector();
342 | hueStereos.put(hue, stereoList);
343 | }
344 |
345 | if (!stereoList.contains(stereo))
346 | stereoList.add(stereo);
347 |
348 | stereoHueRGB.put(stereo + "-" + hue, rgb);
349 | }
350 | }
351 |
352 | input.close(); // close connection to the data source
353 | }
354 | catch (IOException e)
355 | {
356 | System.out.println("Cannot find/load lexicon file: " + filename);
357 |
358 | e.printStackTrace();
359 | }
360 |
361 | return null;
362 | }
363 |
364 |
365 |
366 | //--------------------------------------------------------------------------//
367 | //--------------------------------------------------------------------------//
368 | // Main test stub
369 | //--------------------------------------------------------------------------//
370 | //--------------------------------------------------------------------------//
371 |
372 | public static void main(String[] args)
373 | {
374 | String dir = "/Users/tonyveale/Desktop/Lexical Resources/Moods/";
375 |
376 | ColorLexicon lexicon = new ColorLexicon(dir + "color stereotype lexicon.idx");
377 |
378 | System.out.println(lexicon.getStereoList());
379 |
380 | System.out.println(lexicon.getHuesFor("almond"));
381 | System.out.println(lexicon.getRGBFor("almond", "brown"));
382 | System.out.println(lexicon.getRGBFor("almond", "orange"));
383 |
384 | System.out.println(lexicon.getHuesFor("bee"));
385 | System.out.println(lexicon.getRGBFor("bee", "yellow"));
386 | System.out.println(lexicon.getHuesFor("Coriolanus_Snow"));
387 |
388 | System.out.println(lexicon.resolveStereoHue("Coriolanus_Snow", "Snow", lexicon.getRGBFor("snow", "white")));
389 |
390 | System.out.println(lexicon.resolveHue("Moss", "#4A5D23"));
391 | }
392 | }
393 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/ColorLoverPalette.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | import java.awt.Color;
4 | import java.io.BufferedReader;
5 | import java.io.InputStreamReader;
6 | import java.net.MalformedURLException;
7 | import java.net.URL;
8 | import java.net.URLConnection;
9 | import java.util.Random;
10 | import java.util.StringTokenizer;
11 | import java.util.Vector;
12 |
13 | // A Color palette obtained from ColourLovers.com
14 |
15 | public class ColorLoverPalette
16 | {
17 | private static Random RND = new Random();
18 |
19 | private static String BaseURL = "http://www.colourlovers.com/palette/";
20 |
21 | private static String palIntro = "var _paletteColorsUI = '{\"_x\":380,\"_y\":195,\"_colors\":[";
22 | private static String palClose = "],";
23 |
24 | private static String nameIntro = "";
26 | private static String nameCredit= " color palette by ";
27 |
28 | private static String loveIntro = "
Loves
";
29 | private static String loveClose = "<";
30 |
31 | private Color[] colors = null;
32 | private Vector hexCodes = new Vector();
33 |
34 | private String authorName = null;
35 | private String paletteName = null;
36 |
37 | private int numLoves = 0;
38 |
39 |
40 | //--------------------------------------------------------------------------//
41 | //--------------------------------------------------------------------------//
42 | // Constructors
43 | //--------------------------------------------------------------------------//
44 | //--------------------------------------------------------------------------//
45 |
46 | public ColorLoverPalette()
47 | {
48 | this(RND.nextInt(1000000));
49 | }
50 |
51 |
52 |
53 | public ColorLoverPalette(int number)
54 | {
55 | loadFromWeb(BaseURL + number);
56 | }
57 |
58 |
59 | //--------------------------------------------------------------------------//
60 | //--------------------------------------------------------------------------//
61 | // Access methods
62 | //--------------------------------------------------------------------------//
63 | //--------------------------------------------------------------------------//
64 |
65 | public int getNumLoves()
66 | {
67 | return numLoves;
68 | }
69 |
70 | public Color[] getColors()
71 | {
72 | return colors;
73 | }
74 |
75 | public Vector getHexCodes()
76 | {
77 | return hexCodes;
78 | }
79 |
80 | public String getName()
81 | {
82 | return paletteName;
83 | }
84 |
85 |
86 | public String getAuthor()
87 | {
88 | return authorName;
89 | }
90 |
91 | //--------------------------------------------------------------------------//
92 | //--------------------------------------------------------------------------//
93 | // Load Palette info from ColourLovers website
94 | //--------------------------------------------------------------------------//
95 | //--------------------------------------------------------------------------//
96 |
97 | private void loadFromWeb(String pageURL)
98 | {
99 | try {
100 | URL website = new URL(pageURL);
101 |
102 | URLConnection conn = website.openConnection();
103 |
104 | conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2");
105 |
106 | BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
107 |
108 | String inputLine = null;
109 |
110 | //System.out.println(pageURL);
111 |
112 | while ((inputLine = in.readLine()) != null)
113 | {
114 | int rgbPos = inputLine.indexOf(palIntro);
115 |
116 | int rgbEnd = inputLine.lastIndexOf(palClose);
117 |
118 | if (rgbPos >= 0 && rgbEnd > rgbPos)
119 | {
120 | //System.out.println(inputLine.substring(rgbPos, rgbEnd));
121 |
122 | StringTokenizer tokens = new StringTokenizer(inputLine.substring(rgbPos + palIntro.length(), rgbEnd), "\" ,", false);
123 |
124 | int numCols = tokens.countTokens();
125 |
126 | colors = new Color[numCols];
127 |
128 | for (int c = 0; c < numCols; c++)
129 | {
130 | String hex = tokens.nextToken();
131 | hexCodes.add(hex);
132 |
133 | colors[c] = PaintedCanvas.getRGBColor(hex);
134 | }
135 | }
136 |
137 | int namePos = inputLine.indexOf(nameIntro);
138 | int credPos = inputLine.indexOf(nameCredit);
139 | int nameEnd = inputLine.indexOf(nameClose);
140 |
141 | //if (namePos > 0) System.out.println("@@@" + inputLine);
142 |
143 | if (namePos >= 0 && credPos > namePos && nameEnd > credPos)
144 | {
145 | paletteName = inputLine.substring(namePos + nameIntro.length(), credPos).trim();
146 | authorName = inputLine.substring(credPos + nameCredit.length(), nameEnd).trim();
147 |
148 | if (authorName.endsWith("."))
149 | authorName = authorName.substring(0, authorName.length()-1);
150 | }
151 |
152 | int lovePos = inputLine.indexOf(loveIntro);
153 | int loveEnd = inputLine.indexOf(loveClose, lovePos + loveIntro.length());
154 |
155 | if (lovePos > 0 && loveEnd > lovePos) {
156 | numLoves = Integer.parseInt(inputLine.substring(lovePos + loveIntro.length(), loveEnd));
157 | }
158 | }
159 | }
160 | catch (Exception e)
161 | {
162 | System.out.println("Cannot load color info from: " + pageURL);
163 | e.printStackTrace();
164 | }
165 | }
166 |
167 |
168 | //--------------------------------------------------------------------------//
169 | //--------------------------------------------------------------------------//
170 | // Load a large range of palettes from ColorLovers and save to a file
171 | //--------------------------------------------------------------------------//
172 | //--------------------------------------------------------------------------//
173 |
174 | public void loadAndSaveMany(String filename, int secondsToWait)
175 | {
176 | Dribbler dribby = new Dribbler();
177 |
178 | dribby.openDribbleFile(filename);
179 |
180 | int count = 0;
181 |
182 | while (true)
183 | {
184 | ColorLoverPalette pally = new ColorLoverPalette();
185 |
186 | String author = cleanupName(pally.getAuthor());
187 | String name = cleanupName(pally.getName());
188 |
189 | if (author == null || name == null) continue;
190 |
191 | Vector rgbs = pally.getHexCodes();
192 |
193 | if (author == null || name == null || name.length() < 3 || name.length() > 20 || rgbs.size() < 2 || name.startsWith("_"))
194 | {
195 | System.out.println("Skip over: <" + pally.getAuthor() + "> and <" + name + "> with " + pally.getNumLoves() + " loves");
196 |
197 | waitFor(1);
198 |
199 | continue;
200 | }
201 |
202 | count++;
203 |
204 | dribby.printlnDribbleFile(count + ". " + author + "|" + name + "|" + pally.getNumLoves() + " " + rgbs);
205 |
206 | waitFor(secondsToWait);
207 | }
208 | }
209 |
210 |
211 | private void waitFor(int secondsToWait)
212 | {
213 | try {Thread.sleep(secondsToWait*1000);} catch (Exception e) {e.printStackTrace();}
214 | }
215 |
216 |
217 | private String cleanupName(String name)
218 | {
219 | if (name == null) return null;
220 |
221 | StringBuffer clean = new StringBuffer(name);
222 |
223 | for (int c = 0; c < name.length(); c++)
224 | {
225 | if (name.charAt(c) == ' ')
226 | clean.setCharAt(c, '_');
227 |
228 | if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '-?!".indexOf(name.charAt(c)) < 0)
229 | return null;
230 | }
231 |
232 | return clean.toString();
233 | }
234 |
235 | //--------------------------------------------------------------------------//
236 | //--------------------------------------------------------------------------//
237 | // Main application stub
238 | //--------------------------------------------------------------------------//
239 | //--------------------------------------------------------------------------//
240 |
241 | public static void main(String[] args)
242 | {
243 | ColorLoverPalette pally = new ColorLoverPalette();
244 |
245 | System.out.println(pally.getName() + " by " + pally.getAuthor() + " (" + pally.getNumLoves() + " loves): " + pally.getHexCodes());
246 |
247 | Color[] colors = pally.getColors();
248 |
249 | for (int c = 0; c < colors.length; c++)
250 | System.out.println(colors[c]);
251 |
252 | String dir = "/Users/tonyveale/Desktop/Lexical Resources/Moods/";
253 |
254 | pally.loadAndSaveMany(dir + "RGB palettes.idx", 1);
255 | }
256 |
257 | }
258 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/DessertMaker.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | import java.util.Random;
4 | import java.util.Vector;
5 |
6 | // A Simple class that makes a new (and horribly creative) dessert on demand
7 |
8 | public class DessertMaker
9 | {
10 | private Random RND = new Random();
11 |
12 | private KnowledgeBaseModule desserts = null;
13 | private KnowledgeBaseModule ingredients = null;
14 |
15 | //--------------------------------------------------------------------------//
16 | //--------------------------------------------------------------------------//
17 | // Constructors
18 | //--------------------------------------------------------------------------//
19 | //--------------------------------------------------------------------------//
20 |
21 | public DessertMaker(String resDir)
22 | {
23 | desserts = new KnowledgeBaseModule(resDir + "List of desserts.txt");
24 | ingredients = new KnowledgeBaseModule(resDir + "List of ingredients.txt");
25 | }
26 |
27 |
28 | //--------------------------------------------------------------------------//
29 | //--------------------------------------------------------------------------//
30 | // Make a random dessert by making a random ingredient substitution
31 | //--------------------------------------------------------------------------//
32 | //--------------------------------------------------------------------------//
33 |
34 | public String getRandomDessert()
35 | {
36 | return desserts.getAllFrames().elementAt(RND.nextInt(desserts.getAllFrames().size()));
37 | }
38 |
39 |
40 | public Vector getIngredientsFor(String dessert)
41 | {
42 | return desserts.getFieldValues("Ingredients", dessert);
43 | }
44 |
45 |
46 | public String getRandomIngredient(String dessert)
47 | {
48 | Vector elements = getIngredientsFor(dessert);
49 |
50 | if (elements == null || elements.size() == 0)
51 | return null;
52 |
53 | return elements.elementAt(RND.nextInt(elements.size()));
54 | }
55 |
56 |
57 | public String getRandomSubsitution(String ingredient)
58 | {
59 | Vector candidates = ingredients.getFieldValues("Substitutions", ingredient);
60 |
61 | if (candidates == null || candidates.size() == 0)
62 | return null;
63 |
64 | return candidates.elementAt(RND.nextInt(candidates.size()));
65 | }
66 |
67 |
68 | public String makeDessertVariant()
69 | {
70 | String dessert = getRandomDessert();
71 | String ingredient = getRandomIngredient(dessert);
72 | String substitute = getRandomSubsitution(ingredient);
73 |
74 | return dessert + " made with " + substitute + " instead of " + ingredient;
75 | }
76 |
77 |
78 | //--------------------------------------------------------------------------//
79 | //--------------------------------------------------------------------------//
80 | // Main test stub
81 | //--------------------------------------------------------------------------//
82 | //--------------------------------------------------------------------------//
83 |
84 | public static void main(String[] args)
85 | {
86 | String resDir = "/Users/tonyveale/Dropbox/CodeCamp2016/NOC/DATA/TSV Lists/";
87 |
88 | DessertMaker chef = new DessertMaker(resDir);
89 |
90 | for (int i = 0; i < 10; i++)
91 | System.out.println(chef.makeDessertVariant());
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/DreamCaster.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | import java.util.Random;
4 | import java.util.Vector;
5 |
6 | import tabular.BucketTable;
7 | import tabular.SymbolCounter;
8 | import tabular.SymbolMap;
9 |
10 |
11 |
12 | public class DreamCaster
13 | {
14 | static Random DICE = new Random();
15 |
16 | private String knowledgeDir = null; // directory where knowledge-base(s) can be found
17 |
18 | private KnowledgeBaseModule dreamKB = null;
19 | private KnowledgeBaseModule entryActions = null;
20 | private KnowledgeBaseModule exitActions = null;
21 |
22 | private BucketTable stereoModel = new BucketTable("stereotype concepts to their properties");
23 | private BucketTable stereoProperties = null;
24 | private BucketTable opposites = new BucketTable("properties to their opposites");
25 |
26 | private BucketTable entryMap = new BucketTable("entry actions to stereotypes");
27 | private BucketTable exitMap = new BucketTable("exit actions to stereotypes");
28 |
29 | private BucketTable statesToProperties = new BucketTable("states to their defining properties");
30 |
31 | //-----------------------------------------------------------------------------------------------//
32 | //-----------------------------------------------------------------------------------------------//
33 | // Constructors
34 | // -- Load the knowledge-base
35 | //-----------------------------------------------------------------------------------------------//
36 | //-----------------------------------------------------------------------------------------------//
37 |
38 |
39 | public DreamCaster(String kbDirectory, String dreamDirectory)
40 | {
41 | knowledgeDir = kbDirectory;
42 |
43 | dreamKB = new KnowledgeBaseModule(dreamDirectory + "Veale's Dream Symbols.txt", 0);
44 | entryActions = new KnowledgeBaseModule(dreamDirectory + "Veale's entry actions.txt", 0);
45 | exitActions = new KnowledgeBaseModule(dreamDirectory + "Veale's exit actions.txt", 0);
46 |
47 | stereoModel.loadTable(kbDirectory + "stereotype model.idx");
48 |
49 | stereoProperties = stereoModel.invertTable();
50 |
51 | opposites.loadTable(kbDirectory + "ADJ opposites.idx");
52 |
53 | entryMap.loadTable(kbDirectory + "stereotype entry conditions.idx");
54 | entryMap = entryMap.invertTable();
55 |
56 | exitMap.loadTable(kbDirectory + "stereotype exit conditions.idx");
57 | exitMap = exitMap.invertTable();
58 |
59 | statesToProperties.loadTable(kbDirectory + "states of properties");
60 |
61 | findDreamSituations(exitActions.getAllFrames());
62 | }
63 |
64 |
65 | //-----------------------------------------------------------------------------------------------//
66 | //-----------------------------------------------------------------------------------------------//
67 | // Find norm pairs that have dream interpretations
68 | //-----------------------------------------------------------------------------------------------//
69 | //-----------------------------------------------------------------------------------------------//
70 |
71 | private void findDreamSituations(Vector actions)
72 | {
73 | int counter = 0;
74 |
75 | for (int i = 0; i < actions.size(); i++)
76 | {
77 | String action = ((String)actions.elementAt(i)).trim();
78 | String verb = action.substring(0, action.indexOf((int)':'));
79 | String object = action.substring(verb.length()+1);
80 |
81 | Vector entrySubjects = entryMap.get(action);
82 | Vector exitSubjects = exitMap.get(action);
83 |
84 | Vector objDreams = dreamKB.getFieldValues("Interpretation", object);
85 |
86 | Vector anchoredSubjects = new Vector();
87 |
88 | if (entrySubjects != null)
89 | {
90 | for (int s = 0; s < entrySubjects.size(); s++)
91 | {
92 | String subject = (String)entrySubjects.elementAt(s);
93 |
94 | Vector subjDreams = dreamKB.getFieldValues("Interpretation", subject);
95 |
96 | if (subjDreams == null || subjDreams.size() == 0) continue;
97 |
98 | if (!anchoredSubjects.contains(subject))
99 | anchoredSubjects.add(subject);
100 | }
101 | }
102 |
103 | if (exitSubjects != null)
104 | {
105 | for (int s = 0; s < exitSubjects.size(); s++)
106 | {
107 | String subject = (String)exitSubjects.elementAt(s);
108 |
109 | Vector subjDreams = dreamKB.getFieldValues("Interpretation", subject);
110 |
111 | if (subjDreams == null || subjDreams.size() == 0) continue;
112 |
113 | if (!anchoredSubjects.contains(subject))
114 | anchoredSubjects.add(subject);
115 | }
116 | }
117 |
118 | if ((objDreams == null || objDreams.size() == 0) && anchoredSubjects.size() == 0)
119 | continue;
120 |
121 | System.out.print((++counter) + ". " + anchoredSubjects + " " + verb + " " + object);
122 |
123 | if (objDreams != null && objDreams.size() > 0)
124 | System.out.print("*");
125 |
126 | System.out.println();
127 | }
128 | }
129 |
130 |
131 |
132 | // Find apt subjects for a given action
133 |
134 | private Vector getAptSubjects(String verb, String object)
135 | {
136 | Vector properties = (Vector)statesToProperties.get(object);
137 |
138 | if (properties == null || properties.size() == 0) return null;
139 |
140 | Vector aptSubjects = new Vector();
141 |
142 | return aptSubjects;
143 |
144 |
145 | }
146 |
147 | //-----------------------------------------------------------------------------------------------//
148 | //-----------------------------------------------------------------------------------------------//
149 | // Application Stub
150 | //-----------------------------------------------------------------------------------------------//
151 | //-----------------------------------------------------------------------------------------------//
152 |
153 | public static void main(String[] args)
154 | {
155 | String ddir = "/Users/tonyveale/Dropbox/CC Course Helsinki/";
156 | String kdir = "/Users/tonyveale/Desktop/Lexical Resources/Moods/";
157 |
158 | DreamCaster dreamer = new DreamCaster(kdir, ddir);
159 |
160 |
161 | }
162 |
163 | }
164 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/Dribbler.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | import java.io.FileOutputStream;
4 | import java.io.OutputStreamWriter;
5 | import java.util.Random;
6 | import java.util.Vector;
7 |
8 | import Narrative.NLP;
9 | import Narrative.StoryAction;
10 | import Narrative.StoryObject;
11 |
12 | public class Dribbler
13 | {
14 | static Random RND = new Random();
15 | static Boolean ONLY_TO_SCREEN = false;
16 |
17 |
18 | //--------------------------------------------------------------------------//
19 | //--------------------------------------------------------------------------//
20 | // Simple Constructor
21 | //--------------------------------------------------------------------------//
22 | //--------------------------------------------------------------------------//
23 |
24 |
25 | public Dribbler()
26 | {
27 | }
28 |
29 |
30 | //--------------------------------------------------------------------------//
31 | //--------------------------------------------------------------------------//
32 | // Manage a dribble file for recording output
33 | //--------------------------------------------------------------------------//
34 | //--------------------------------------------------------------------------//
35 |
36 | private FileOutputStream dribbleStream = null;
37 | private OutputStreamWriter dribbleFile = null;
38 |
39 |
40 | protected void openDribbleFile(String filename)
41 | {
42 | try {
43 | if (!ONLY_TO_SCREEN)
44 | {
45 | dribbleStream = new FileOutputStream(filename);
46 | dribbleFile = new OutputStreamWriter(dribbleStream, "UTF-8");
47 | }
48 | }
49 | catch (Exception e)
50 | {
51 | e.printStackTrace();
52 | }
53 | }
54 |
55 |
56 |
57 | protected void closeDribbleFile()
58 | {
59 | try {
60 | if (dribbleFile != null)
61 | {
62 | dribbleFile.flush();
63 | dribbleFile.close();
64 | }
65 | }
66 | catch (Exception e)
67 | {
68 | e.printStackTrace();
69 | }
70 | }
71 |
72 |
73 | protected long getDribblePosition()
74 | {
75 | try {
76 | if (dribbleStream == null)
77 | return 0;
78 | else
79 | return dribbleStream.getChannel().position();
80 | }
81 | catch (Exception e)
82 | {
83 | e.printStackTrace();
84 |
85 | return -1;
86 | }
87 | }
88 |
89 |
90 | protected void printlnDribbleFile(String line)
91 | {
92 | try {
93 | if (dribbleFile != null)
94 | {
95 | dribbleFile.write(line);
96 | dribbleFile.write("\n");
97 | dribbleFile.flush();
98 | }
99 |
100 | System.out.println(line);
101 | }
102 | catch (Exception e)
103 | {
104 | e.printStackTrace();
105 | }
106 | }
107 |
108 |
109 | protected void printDribbleFile(String line)
110 | {
111 | try {
112 | if (dribbleFile != null)
113 | {
114 | dribbleFile.write(line);
115 | dribbleFile.flush();
116 | }
117 |
118 | System.out.print(line);
119 | }
120 | catch (Exception e)
121 | {
122 | e.printStackTrace();
123 | }
124 | }
125 |
126 |
127 | //--------------------------------------------------------------------------//
128 | //--------------------------------------------------------------------------//
129 | // Some useful text-processing / output routines
130 | //--------------------------------------------------------------------------//
131 | //--------------------------------------------------------------------------//
132 |
133 | static protected String capitalizeFirst(StoryObject object)
134 | {
135 | return capitalizeFirst(object.toString());
136 | }
137 |
138 |
139 | static protected String capitalizeFirst(StoryAction action)
140 | {
141 | return capitalizeFirst(action.toString());
142 | }
143 |
144 |
145 | static protected String capitalizeFirst(String phrase)
146 | {
147 | if (phrase == null || phrase.length() == 0)
148 | return phrase;
149 | else
150 | if (phrase.charAt(0) == '\"')
151 | return "\"" + capitalizeFirst(phrase.substring(1));
152 | else
153 | if (phrase.length() > 1 && phrase.charAt(0) == 'i' && Character.isUpperCase(phrase.charAt(1)))
154 | return phrase;
155 | else
156 | return Character.toUpperCase(phrase.charAt(0)) + phrase.substring(1);
157 | }
158 |
159 |
160 | static protected String capitalizeEach(String phrase)
161 | {
162 | StringBuffer capped = new StringBuffer(phrase);
163 |
164 | for (int i = 0; i < phrase.length(); i++)
165 | if (i == 0 || phrase.charAt(i-1) == ' ' || phrase.charAt(i-1) == '_')
166 | capped.setCharAt(i, Character.toUpperCase(phrase.charAt(i)));
167 |
168 | return capped.toString();
169 | }
170 |
171 | // Do in-line string replacement
172 |
173 | static protected String replaceWith(String whole, String before, String after)
174 | {
175 | int where = whole.indexOf(before);
176 |
177 | while (where >= 0)
178 | {
179 | whole = whole.substring(0, where) + after + whole.substring(where + before.length());
180 |
181 | where = whole.indexOf(before, where + after.length());
182 | }
183 |
184 | return whole;
185 | }
186 |
187 |
188 |
189 | static protected Vector randomize(Vector input)
190 | {
191 | if (input == null || input.size() < 2)
192 | return input;
193 |
194 | for (int i = 0; i < input.size(); i++)
195 | {
196 | int pos1 = RND.nextInt(input.size()), pos2 = RND.nextInt(input.size());
197 |
198 | Object obj1 = input.elementAt(pos1), obj2 = input.elementAt(pos2);
199 |
200 | input.setElementAt(obj2, pos1);
201 | input.setElementAt(obj1, pos2);
202 | }
203 |
204 | return input;
205 | }
206 |
207 |
208 | static protected Object[] randomize(Object[] input)
209 | {
210 | if (input == null || input.length < 2)
211 | return input;
212 |
213 | for (int i = 0; i < input.length; i++)
214 | {
215 | int pos1 = RND.nextInt(input.length), pos2 = RND.nextInt(input.length);
216 |
217 | Object obj1 = input[pos1], obj2 = input[pos2];
218 |
219 | input[pos1] = obj2;
220 | input[pos2] = obj1;
221 | }
222 |
223 | return input;
224 | }
225 | }
226 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/MetaphorMagnet.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 |
4 | public class MetaphorMagnet
5 | {
6 | private static String CONSUMER_KEY = "rJ179bgec98exA9DkSWk42Wpv";
7 | private static String ACCESS_TOKEN = "2428936177-QNvevcemjILj4ReDSN1kmUfBGcaYYDUroCMfNfp";
8 |
9 |
10 | //--------------------------------------------------------------------------------------------------//
11 | //--------------------------------------------------------------------------------------------------//
12 | // Main Application Stub
13 | //--------------------------------------------------------------------------------------------------//
14 | //--------------------------------------------------------------------------------------------------//
15 |
16 | // In Documents/Workspace/WordNetBrowser
17 |
18 | // Command Line: /usr/bin/java -classpath ../:./:../twitter4j-4.0.1/lib/twitter4j-core-4.0.1.jar:../twitter4j-4.0.1/lib/twitter4j-stream-4.0.1.jar twitterbotics.TweetGenerator
19 |
20 |
21 | public static void main(String[] args)
22 | {
23 | String dir = "/Users/tonyveale/Desktop/Lexical Resources/Moods/";
24 |
25 | TweetLaunchpadWithEmoji generator = new TweetLaunchpadWithEmoji(dir, CONSUMER_KEY,
26 | args[0], // CONSUMER_SECRET,
27 | ACCESS_TOKEN,
28 | args[1]); // ACCESS_SECRET;
29 |
30 | generator.loadSpace(dir + "Venn diagram 1 tweets.idx", "Venn 1");
31 | generator.loadSpace(dir + "Venn diagram 2 tweets.idx", "Venn 2");
32 | generator.loadSpace(dir + "Venn diagram 3 tweets.idx", "Venn 3");
33 | generator.loadSpace(dir + "Venn diagram 4 tweets.idx", "Venn 4");
34 | generator.loadSpace(dir + "Venn diagram 5 tweets.idx", "Venn 5");
35 | generator.loadSpace(dir + "narrative 5-step joint tweets.idx", "Venn joint");
36 | generator.loadSpace(dir + "Jesus transformation tweets.idx", "Jesus transformation");
37 | generator.loadSpace(dir + "Jesus contrast tweets.idx", "Jesus contrast");
38 | generator.loadSpace(dir + "NOC epitaph tweets.idx", "epitaphs");
39 | generator.loadSpace(dir + "group meme tweets.idx", "group meme");
40 | generator.loadSpace(dir + "group walk meme tweets.idx", "walk meme");
41 | generator.loadSpace(dir + "narrative group tweets.idx", "group narrative");
42 | generator.loadSpace(dir + "narrative 5-step nesting tweets.idx", "nesting");
43 | generator.loadSpace(dir + "narrative animal tweets.idx", "animal");
44 | generator.loadSpace(dir + "narrative remarkable animal tweets.idx", "remarkable animal");
45 | generator.loadSpace(dir + "narrative negative animal tweets.idx", "negative animal");
46 | generator.loadSpace(dir + "narrative 5-step divorce tweets.idx", "divorce");
47 | generator.loadSpace(dir + "Google question tweets.idx", "Google");
48 | generator.loadSpace(dir + "about simile tweets.idx", "Web simile");
49 | generator.loadSpace(dir + "narrative 5-step workplace tweets.idx", "workplace");
50 | generator.loadSpace(dir + "narrative 4-step label tweets.idx", "narrative 4-steps label");
51 | generator.loadSpace(dir + "narrative 5-step marriage tweets.idx", "narrative 5-steps marriage");
52 | generator.loadSpace(dir + "narrative 5-step left tweets.idx", "narrative 5-steps left");
53 | generator.loadSpace(dir + "narrative 5-step right tweets.idx", "narrative 5-steps right");
54 | generator.loadSpace(dir + "narrative 5-step tweets.idx", "narrative 5-steps");
55 | generator.loadSpace(dir + "narrative 4-step tweets.idx", "narrative 4-steps");
56 | generator.loadSpace(dir + "dream conflict tweets.idx", "dream conflict");
57 | generator.loadSpace(dir + "NOC blend tweets.idx", "NOC blends");
58 | generator.loadSpace(dir + "Nietzschean tweets.idx", "Nietzsche");
59 | generator.loadSpace(dir + "clothes maketh the man tweets.idx", "Shakespeare");
60 | generator.loadSpace(dir + "walk a mile tweets.idx", "walk a mile");
61 | generator.loadSpace(dir + "relative perspective tweets.idx", "relative perspective");
62 | generator.loadSpace(dir + "verb change tweets.idx", "change");
63 | generator.loadSpace(dir + "analogical alignment tweets.idx", "alignment");
64 | generator.loadSpace(dir + "superlative tweets.idx", "superlative");
65 | generator.loadSpace(dir + "what-if dream tweets.idx", "whatif_dream");
66 | generator.loadSpace(dir + "tweets from 4-grams with dreamers.idx", "dream 4-gram");
67 | generator.loadSpace(dir + "tweets from 3-grams with dreamers.idx", "dream 3-gram");
68 | generator.loadSpace(dir + "dream contrast tweets.idx", "dream contrast");
69 | generator.loadSpace(dir + "dream norm tweets.idx", "dream norm");
70 | generator.loadSpace(dir + "entry parallel tweets.idx", "dream parallel");
71 | generator.loadSpace(dir + "NOC 3 tweets.idx", "NOC3");
72 | generator.loadSpace(dir + "take 5 named tweets.idx", "Take5NOC");
73 | generator.loadSpace(dir + "NOC 1 tweets.idx", "NOC1");
74 | generator.loadSpace(dir + "NOC 2 tweets.idx", "NOC2");
75 | generator.loadSpace(dir + "necessary change tweets.idx", "necessities");
76 | generator.loadSpace(dir + "utopian and dystopian tweets.idx", "utopias");
77 | generator.loadSpace(dir + "what-if tweets.idx", "whatif");
78 | generator.loadSpace(dir + "not exactly tweets.idx", "not exactly");
79 | generator.loadSpace(dir + "take 5 metaphor tweets.idx", "take 5 metaphors");
80 | generator.loadSpace(dir + "ironic thematic contrast tweets.idx", "ironic themes");
81 | generator.loadSpace(dir + "state combination tweets.idx", "state combos");
82 | generator.loadSpace(dir + "possession contrast tweets.idx", "possessions");
83 | generator.loadSpace(dir + "property contrast tweets.idx", "verb+property contrasts");
84 | generator.loadSpace(dir + "entry and exit tweets.idx", "entry and exit");
85 | generator.loadSpace(dir + "tweets from 4-grams.idx", "4-grams");
86 | generator.loadSpace(dir + "tweets from 3-grams.idx", "3-grams");
87 | generator.loadSpace(dir + "tweets from 4-grams with actors.idx", "4-grams actors");
88 | generator.loadSpace(dir + "tweets from 3-grams with actors.idx", "3-grams actors");
89 | generator.loadSpace(dir + "simile tweets.idx", "similes");
90 | generator.loadSpace(dir + "theme identity tweets.idx", "thematic identities");
91 | generator.loadSpace(dir + "theme identity 3 tweets.idx", "thematic identities 3");
92 | generator.loadSpace(dir + "theme identity 4 tweets.idx", "thematic identities 4");
93 | generator.loadSpace(dir + "theme identity 3 tweets with actors.idx", "thematic identities 3 actors");
94 | generator.loadSpace(dir + "theme identity 4 tweets with actors.idx", "thematic identities 4 actors");
95 | generator.loadSpace(dir + "criss-cross tweets.idx", "criss-cross");
96 | generator.loadSpace(dir + "affective comparison tweets.idx", "affective comparison");
97 | generator.loadSpace(dir + "affective crisscross tweets.idx", "affective crisscross");
98 | generator.loadSpace(dir + "group membership tweets.idx", "group membership");
99 | generator.loadSpace(dir + "group antagonism tweets.idx", "collective noun");
100 | generator.loadSpace(dir + "tenor possibility tweets.idx", "tenor possibilities");
101 | generator.loadSpace(dir + "norm reasoning tweets.idx", "norm reasoning");
102 | generator.loadSpace(dir + "norm reasoning tweets choices.idx", "norm choices");
103 | generator.loadSpace(dir + "blended metaphor tweets.idx", "norm blends");
104 | generator.loadSpace(dir + "ironic contrast tweets.idx", "ironic contrasts");
105 | generator.loadSpace(dir + "ironic analogy tweets.idx", "ironic analogies");
106 | generator.loadSpace(dir + "ironic aboutness tweets.idx", "ironic about");
107 | generator.loadSpace(dir + "verb contrast tweets.idx", "verb contrasts");
108 | generator.loadSpace(dir + "take 5 tweets.idx", "take 5");
109 | generator.loadSpace(dir + "take 5 comparison tweets.idx", "take 5 comparisons");
110 | generator.loadSpace(dir + "Boromir walking tweets.idx", "Boromir");
111 | generator.loadSpace(dir + "Hulk smash tweets.idx", "Hulk");
112 | generator.loadSpace(dir + "NOC Hulk tweets.idx", "Hulk NOC");
113 | generator.loadSpace(dir + "Yoda transformation tweets.idx", "Yoda");
114 | generator.loadSpace(dir + "narrative animal scripted tweets.idx", "animal scripts");
115 | generator.loadSpace(dir + "narrative animal pairs tweets.idx", "animal sequences");
116 | generator.loadSpace(dir + "every business tweet.idx", "business");
117 | generator.loadSpace(dir + "narrative animal emoji tweets.idx", "animal emoji");
118 | generator.loadSpace(dir + "narrative recursive NOC tweets.idx", "animal NOC emoji"); // "recursive" was "animal"
119 | generator.loadSpace(dir + "narrative 5-step full tweets.idx", "Venn full");
120 | generator.loadSpace(dir + "narrative 4-step others tweets.idx", "Venn 4-others");
121 | generator.loadSpace(dir + "RGB 2 color tweets.idx", "RGB 2-color");
122 | generator.loadSpace(dir + "RGB NOC color tweets.idx", "RGB NOC");
123 | generator.loadSpace(dir + "RGB stereo color tweets.idx", "RGB stereo");
124 | generator.loadSpace(dir + "RGB visual metaphor tweets.idx", "RGB vismet");
125 |
126 | String[] tweetTypes = {"RGB stereo","RGB vismet", "Venn 4-others", "narrative 4-steps label", "narrative 5-steps left",
127 | "Venn 1", "Venn 2", "Venn 3", "Venn 4", "Venn 5", "narrative 5-steps", "Venn joint", "Venn full",
128 | "narrative 4-steps", "Take5NOC|take 5 comparisons|take 5", "animal NOC emoji", "RGB NOC", "workplace",
129 | "nesting", "business", "animal scripts", "Jesus transformation|Jesus contrast", "Yoda", // "RGB 2-color",
130 | "epitaphs|Nietzsche|Shakespeare|walk a mile|relative perspective", "RGB stereo", "ironic contrasts",
131 | "Boromir", "animal", "remarkable animal", "negative animal", "walk meme|group meme", "divorce",
132 | "narrative 5-steps marriage", "narrative 5-steps right", "Hulk NOC|Hulk",
133 | "dream conflict", "NOC blends", "change", "whatif_dream", "NOC3", "dream 4-gram|dream 3-gram",
134 | "thematic identities 3 actors", "thematic identities 4 actors", "RGB 2-color", "RGB NOC",
135 | "alignment", "superlative", "Web simile", "Google", "thematic identities",
136 | "group narrative", "similes", "possessions", "4-grams actors|4-grams actors|4-grams actors|3-grams actors", "NOC1",
137 | "verb+property contrasts","4-grams|4-grams|4-grams|3-grams", "collective noun", "dream norm",
138 | "verb contrasts", "norm blends", "affective comparison", "group membership", "state combos", "dream contrast",
139 | "whatif", "utopias", "not exactly", "ironic themes", "NOC2", "norm choices", "tenor possibilities", "ironic analogies",
140 | "norm reasoning", "affective crisscross", "ironic about", "criss-cross", "necessities",
141 | "thematic identities 3", "thematic identities 4", "dream parallel"};
142 |
143 | System.out.println("\n\nTweet Generator version: " + TweetLaunchpad.VERSION + "\n");
144 |
145 | generator.analyzeTimeline("MetaphorMagnet", 15);
146 |
147 | generator.startTweeting(1000000, 60*60*1000, tweetTypes);
148 |
149 |
150 | /*
151 | for (int t = 0; t < 1; t++) //tweetTypes.length
152 | {
153 | for (int i = 0 ; i < 100; i++)
154 | {
155 | String next = generator.getLeastRecentRandomCandidate(tweetTypes[t], 100);
156 |
157 | if (next == null) continue;
158 |
159 | StringTokenizer tweetset = new StringTokenizer(next, "\t");
160 |
161 | Vector orderedTweets = new Vector();
162 |
163 | while (tweetset.hasMoreTokens()) orderedTweets.add(tweetset.nextToken());
164 |
165 | System.out.println("\nStory " + (i+1) + ":");
166 |
167 | for (int tw = 0; tw < orderedTweets.size(); tw++)
168 | {
169 | String tweet = (String)orderedTweets.elementAt(tw);
170 |
171 | if (generator.hasNumberingSystem(tweet, 1, 3))
172 | tweet = generator.insertNumberEmoji(tweet, TweetEmojifier.TIMES, 1, 5);
173 |
174 | System.out.println("\n" + tweet);
175 | }
176 |
177 | generator.advanceCounter();
178 |
179 | generator.updateCounts(next);
180 | }
181 | }
182 | */
183 |
184 | /*
185 | for (int i = 0 ; i < 2; i++)
186 | {
187 | for (int j = 0 ; j < tweetTypes.length; j++)
188 | {
189 | String next = generator.getLeastRecentRandomCandidate(tweetTypes[j], 100), setup = null, followup = null;
190 |
191 | int divider = next.indexOf((int)'\t');
192 |
193 | if (divider > 0)
194 | {
195 | setup = next.substring(0, divider);
196 | followup = next.substring(setup.length()+1);
197 | }
198 | else
199 | {
200 | setup = next;
201 | followup = next;
202 | }
203 |
204 | System.out.println("\nTweet " + i + ":\n" + setup + " (" + setup.length() + ")");
205 |
206 | if (!followup.equals(setup))
207 | System.out.println(followup + " (" + followup.length() + ")");
208 |
209 | generator.advanceCounter();
210 |
211 | generator.updateCounts(next);
212 | }
213 | }
214 | */
215 | }
216 |
217 | }
218 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/TweetEmojifier.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | import java.util.Hashtable;
4 | import java.util.Random;
5 | import java.util.Vector;
6 |
7 |
8 | public class TweetEmojifier
9 | {
10 | static String WEDDING = "1F492";
11 | static String POO = "1F4A9";
12 |
13 | static String[] TIMES = {"1F55B", "1F558", "1F55B", "1F551", "1F55E", "1F554", "1F37E"};
14 | static String[] MOONS = {"1F315", "1F315", "1F316", "1F317", "1F318", "1F311", "1F320"};
15 | static String[] WEATHER = {"1F31E", "1F31E", "1F324", "1F32C", "1F329", "1F302", "1F308"};
16 | static String[] FACES = {"1F636", "1F914", "1F60F", "1F625", "1F623", "1F644", "1F602"};
17 | static String[] MARRIAGE = {"1F393", "1F6AA", "1F44B", "1F492", "1F49E", "1F494", "1F489"};
18 |
19 | private Random RND = new Random();
20 |
21 | private Vector numberingSchemes = new Vector();
22 |
23 | private Hashtable symbols = new Hashtable();
24 |
25 | private Vector allSymbols = new Vector();
26 | private Vector allAnimals = new Vector();
27 |
28 |
29 | //--------------------------------------------------------------------------------------------------//
30 | //--------------------------------------------------------------------------------------------------//
31 | // Constructors
32 | //--------------------------------------------------------------------------------------------------//
33 | //--------------------------------------------------------------------------------------------------//
34 |
35 | public TweetEmojifier()
36 | {
37 | numberingSchemes.add(TIMES);
38 | numberingSchemes.add(MOONS);
39 | numberingSchemes.add(WEATHER);
40 |
41 | addEmojiMappings();
42 | }
43 |
44 |
45 | //--------------------------------------------------------------------------------------------------//
46 | //--------------------------------------------------------------------------------------------------//
47 | // Set up useful symbol to unicode mappings
48 | //--------------------------------------------------------------------------------------------------//
49 | //--------------------------------------------------------------------------------------------------//
50 |
51 | private void addEmojiMappings()
52 | {
53 | addAnimal("panther", "1F63A");
54 | addAnimal("puma", "1F63A");
55 | addAnimal("jaguar", "1F638");
56 | addAnimal("fox", "1F63C");
57 | addAnimal("monkey", "1F435");
58 | addAnimal("lemur", "1F412");
59 | addAnimal("ape", "1F435");
60 | addAnimal("chimp", "1F435");
61 | addAnimal("chimpanzee", "1F435");
62 | addAnimal("dog", "1F436");
63 | addAnimal("hound", "1F415");
64 | addAnimal("poodle", "1F429");
65 | addAnimal("wolf", "1F43A");
66 | addAnimal("coyote", "1F43A");
67 | addAnimal("cat", "1F431");
68 | addAnimal("lion", "1F981");
69 | addAnimal("lioness", "1F981");
70 | addAnimal("tiger", "1F42F");
71 | addAnimal("tigress", "1F42F");
72 | addAnimal("horse", "1F434");
73 | addAnimal("pony", "1F434");
74 | addAnimal("stallion", "1F434");
75 | addAnimal("mare", "1F434");
76 | addAnimal("racehorse", "1F434");
77 | addAnimal("unicorn", "1F984");
78 | addAnimal("cow", "1F42E");
79 | addAnimal("bull", "1F403");
80 | addAnimal("pig", "1F437");
81 | addAnimal("hog", "1F437");
82 | addAnimal("swine", "1F437");
83 | addAnimal("boar", "1F417");
84 | addAnimal("warthog", "1F417");
85 | addAnimal("ram", "1F40F");
86 | addAnimal("sheep", "1F411");
87 | addAnimal("goat", "1F410");
88 | addAnimal("camel", "1F42A");
89 | addAnimal("camel", "1F42B");
90 | addAnimal("elephant", "1F418");
91 | addAnimal("mouse", "1F42D");
92 | addAnimal("mouse", "1F421");
93 | addAnimal("rat", "1F42D");
94 | addAnimal("rat", "1F400");
95 | addAnimal("hamster", "1F439");
96 | addAnimal("rabbit", "1F430");
97 | addAnimal("hare", "1F407");
98 | addAnimal("squirrel", "1F43F");
99 | addAnimal("bear", "1F43B");
100 | addAnimal("koala", "1F428");
101 | addAnimal("panda", "1F43C");
102 | addAnimal("turkey", "1F983");
103 | addAnimal("chicken", "1F414");
104 | addAnimal("hen", "1F414");
105 | addAnimal("cock", "1F413");
106 | addAnimal("cockerel", "1F413");
107 | addAnimal("rooster", "1F413");
108 | addAnimal("chick", "1F425");
109 | addAnimal("sparrow", "1F426");
110 | addAnimal("bluebird", "1F426");
111 | addAnimal("swallow", "1F426");
112 | addAnimal("penguin", "1F427");
113 | addAnimal("frog", "1F438");
114 | addAnimal("toad", "1F438");
115 | addAnimal("crocodile", "1F40A");
116 | addAnimal("alligator", "1F40A");
117 | addAnimal("turtle", "1F422");
118 | addAnimal("tortoise", "1F422");
119 | addAnimal("snake", "1F40D");
120 | addAnimal("serpent", "1F40D");
121 | addAnimal("cobra", "1F40D");
122 | addAnimal("viper", "1F40D");
123 | addAnimal("asp", "1F40D");
124 | addAnimal("rattler", "1F40D");
125 | addAnimal("rattlesnake", "1F40D");
126 | addAnimal("dragon", "1F432");
127 | addAnimal("lizard", "1F409");
128 | addAnimal("whale", "1F433");
129 | addAnimal("orca", "1F40B");
130 | addAnimal("dolphin", "1F42C");
131 | addAnimal("fish", "1F41F");
132 | addAnimal("trout", "1F41F");
133 | addAnimal("goldfish", "1F420");
134 | addAnimal("blowfish", "1F421");
135 | addAnimal("blobfish", "1F421");
136 | addAnimal("octopus", "1F419");
137 | addAnimal("crab", "1F980");
138 | addAnimal("slug", "1F41B");
139 | addAnimal("caterpiller", "1F41B");
140 | addAnimal("worm", "1F41B");
141 | addAnimal("ant", "1F41C");
142 | addAnimal("termite", "1F41C");
143 | addAnimal("snail", "1F40C");
144 | addAnimal("bee", "1F41D");
145 | addAnimal("honeybee", "1F41D");
146 | addAnimal("bumblebee", "1F41D");
147 | addAnimal("ladybird", "1F41E");
148 | addAnimal("spider", "1F577");
149 | addAnimal("black_widow", "1F577");
150 | addAnimal("black widow", "1F577");
151 | addAnimal("tarantula", "1F577");
152 | addAnimal("scorpion", "1F982");
153 | addAnimal("shrimp", "1F364");
154 | addAnimal("prawn", "1F364");
155 | addAnimal("leopard", "1F406");
156 | addAnimal("jaguar", "1F406");
157 | addAnimal("cheetah", "1F406");
158 | addAnimal("ox", "1F402");
159 | addAnimal("buffalo", "1F402");
160 | addAnimal("cow", "1F404");
161 | addAnimal("canary", "1F424");
162 | addAnimal("cockatoo", "1F426");
163 | }
164 |
165 |
166 | //--------------------------------------------------------------------------------------------------//
167 | //--------------------------------------------------------------------------------------------------//
168 | // Useful Public Routines
169 | //--------------------------------------------------------------------------------------------------//
170 | //--------------------------------------------------------------------------------------------------//
171 |
172 | public String emojify(String tweet)
173 | {
174 | if (!hasNumberingSystem(tweet, 1, 3)) return tweet;
175 |
176 | String[] schema = (String[])numberingSchemes.elementAt(RND.nextInt(numberingSchemes.size()));
177 |
178 | if (tweet.indexOf("3. Marry") > 0)
179 | schema = TweetEmojifier.MARRIAGE;
180 | else
181 | if (tweet.indexOf(": \n1.") > 0 || tweet.indexOf(":\n1.") > 0)
182 | schema = TweetEmojifier.FACES;
183 |
184 | return insertNumberEmoji(tweet, schema, 1, 9);
185 | }
186 |
187 |
188 |
189 | //--------------------------------------------------------------------------------------------------//
190 | //--------------------------------------------------------------------------------------------------//
191 | // Private Helper Routines
192 | //--------------------------------------------------------------------------------------------------//
193 | //--------------------------------------------------------------------------------------------------//
194 |
195 |
196 | private boolean hasNumberingSystem(String tweet, int min, int max)
197 | {
198 | for (int i = min; i <= max; i++)
199 | if (tweet.indexOf("" + i + ".") < 0) return false;
200 |
201 | return true;
202 | }
203 |
204 |
205 |
206 | private String insertNumberEmoji(String tweet, String[] emojis, int min, int max)
207 | {
208 | for (int i = min; i <= max; i++)
209 | {
210 | int pos = tweet.indexOf("" + i + ".");
211 |
212 | if (pos < 0) continue;
213 |
214 | String code = emojis[i];
215 |
216 | if (tweet.indexOf("" + i + ". Marry") >= 0)
217 | code = TweetEmojifier.WEDDING;
218 | else
219 | if (tweet.indexOf("" + i + ". Get dumped") >= 0)
220 | code = TweetEmojifier.POO;
221 |
222 | tweet = tweet.substring(0, pos) + getEmojiForCode(code) + tweet.substring(pos+1);
223 | }
224 |
225 | return tweet;
226 | }
227 |
228 |
229 |
230 | public static String getEmojiForCode(String code)
231 | {
232 | if (code == null) return "";
233 |
234 | int space = code.indexOf((int)' ');
235 |
236 | if (space > 0)
237 | return getEmojiForCode(code.substring(0, space)) + getEmojiForCode(code.substring(space+1).trim());
238 | else
239 | {
240 | try {
241 | return new String(Character.toChars(Integer.parseInt(code, 16)));
242 | }
243 | catch (Exception e)
244 | {
245 | System.out.println("Improper code: <" + code + ">");
246 |
247 | System.exit(0);
248 |
249 | return null;
250 | }
251 | }
252 | }
253 |
254 |
255 | //--------------------------------------------------------------------------------------------------//
256 | //--------------------------------------------------------------------------------------------------//
257 | // Maintain a symbol table with emoji symbol mapping to unicodes
258 | //--------------------------------------------------------------------------------------------------//
259 | //--------------------------------------------------------------------------------------------------//
260 |
261 | public void addSymbol(String symbol, String unicode)
262 | {
263 | Vector codes = (Vector)symbols.get(symbol);
264 |
265 | if (codes == null)
266 | {
267 | codes = new Vector();
268 | symbols.put(symbol, codes);
269 |
270 | allSymbols.add(symbol);
271 | }
272 |
273 | unicode = unicode.intern();
274 |
275 | if (codes.indexOf(unicode) < 0)
276 | codes.add(unicode);
277 | }
278 |
279 |
280 | public void addAnimal(String symbol, String unicode)
281 | {
282 | addSymbol(symbol, unicode);
283 |
284 | if (allAnimals.indexOf(symbol) < 0)
285 | allAnimals.add(symbol);
286 | }
287 |
288 |
289 | public Vector getUnicodesFor(String symbol)
290 | {
291 | return (Vector)symbols.get(symbol);
292 | }
293 |
294 |
295 | public String getRandomSymbol()
296 | {
297 | return (String)allSymbols.elementAt(RND.nextInt(allSymbols.size()));
298 | }
299 |
300 |
301 | public String getRandomAnimal()
302 | {
303 | return (String)allAnimals.elementAt(RND.nextInt(allAnimals.size()));
304 | }
305 |
306 |
307 |
308 | public String getRandomUnicodeFor(String symbol)
309 | {
310 | Vector codes = (Vector)symbols.get(symbol);
311 |
312 | if (codes == null || codes.size() == 0) return null;
313 |
314 | if (codes.size() == 1)
315 | return (String)codes.elementAt(0);
316 |
317 | return (String)codes.elementAt(RND.nextInt(codes.size()));
318 | }
319 |
320 |
321 |
322 | public String getRandomEmojiFor(String symbol)
323 | {
324 | String code = getRandomUnicodeFor(symbol);
325 |
326 | if (code == null)
327 | {
328 | int dash = symbol.lastIndexOf((int)'_');
329 |
330 | if (dash < 0) dash = symbol.lastIndexOf((int)' ');
331 |
332 | if (dash < 0) return null;
333 |
334 | String headEmoji = getRandomEmojiFor(symbol.substring(dash+1));
335 |
336 | if (headEmoji != null)
337 | return symbol.substring(0, dash+1) + headEmoji;
338 | else
339 | return null;
340 | }
341 |
342 | return getEmojiForCode(code);
343 | }
344 |
345 |
346 |
347 |
348 | }
349 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/TweetLaunchpadWithEmoji.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | import java.util.StringTokenizer;
4 | import java.util.Vector;
5 |
6 | import tabular.BucketTable;
7 |
8 | public class TweetLaunchpadWithEmoji extends TweetLaunchpad
9 | {
10 | private BucketTable wordsToEmojis = new BucketTable("Unicodes for words");
11 |
12 |
13 | //--------------------------------------------------------------------------------------------------//
14 | //--------------------------------------------------------------------------------------------------//
15 | // Constructors
16 | //--------------------------------------------------------------------------------------------------//
17 | //--------------------------------------------------------------------------------------------------//
18 |
19 | public TweetLaunchpadWithEmoji(String resDir, String cKey, String cSecret, String aKey, String aSecret)
20 | {
21 | super(cKey, cSecret, aKey, aSecret);
22 |
23 | KnowledgeBaseModule unicodeConnotations = new KnowledgeBaseModule(resDir + "Unicode Connotations.idx");
24 |
25 | unicodeConnotations.invertFieldInto("Connotations", wordsToEmojis);
26 | }
27 |
28 |
29 | public TweetLaunchpadWithEmoji()
30 | {
31 | super();
32 | }
33 |
34 |
35 | public Long postTweetWithRGB(String tweet, Long inResponseTo, String inResponseToHandle)
36 | {
37 | return super.postTweetWithRGB(tweet, inResponseTo, inResponseToHandle, getAptEmojiCodes(tweet));
38 | }
39 |
40 |
41 | //--------------------------------------------------------------------------------------------------//
42 | //--------------------------------------------------------------------------------------------------//
43 | // Return a list of Emoji unicodes that may be apt for a given tweet
44 | //--------------------------------------------------------------------------------------------------//
45 | //--------------------------------------------------------------------------------------------------//
46 |
47 | public Vector getAptEmojiCodes(String tweet)
48 | {
49 | return getAptEmojiCodes(tweet, wordsToEmojis);
50 | }
51 |
52 |
53 | public Vector getAptEmojiCodes(String tweet, BucketTable emojiIndex)
54 | {
55 | Vector codes = new Vector();
56 |
57 | getAptEmojiCodes(new StringTokenizer(tweet, " \t.,-;\"'()"), codes, emojiIndex);
58 | getAptEmojiCodes(new StringTokenizer(tweet.toLowerCase(), " \t.,-;\"'()"), codes, emojiIndex);
59 |
60 | return codes;
61 | }
62 |
63 |
64 | private void getAptEmojiCodes(StringTokenizer tokens, Vector codes, BucketTable emojiIndex)
65 | {
66 | String current = null, previous = null;
67 |
68 | while (tokens.hasMoreTokens())
69 | {
70 | previous = current;
71 | current = tokens.nextToken();
72 |
73 | if (emojiIndex.get(current) != null)
74 | addToList(emojiIndex.get(current), codes);
75 |
76 | if (previous != null && emojiIndex.get(previous + " " + current ) != null)
77 | addToList(emojiIndex.get(previous + " " + current), codes);
78 |
79 | if (previous != null && emojiIndex.get(previous + "-" + current) != null)
80 | addToList(emojiIndex.get(previous + "-" + current), codes);
81 |
82 | }
83 | }
84 |
85 |
86 | private void addToList(Vector src, Vector tgt)
87 | {
88 | for (int i = 0; i < src.size(); i++)
89 | if (tgt.indexOf(src.elementAt(i)) < 0)
90 | tgt.add(src.elementAt(i));
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/TweetSearcher.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | import twitter4j.*;
4 | import twitter4j.auth.AccessToken;
5 | import twitter4j.conf.ConfigurationBuilder;
6 |
7 | import java.io.FileOutputStream;
8 | import java.io.IOException;
9 | import java.io.OutputStreamWriter;
10 | import java.net.URLEncoder;
11 | import java.util.List;
12 |
13 |
14 | public class TweetSearcher extends Dribbler
15 | {
16 | private static String CONSUMER_KEY = "dGESUpwS6sbOXb6I3vmTH53Qx";
17 | private static String CONSUMER_SECRET = "Never store a secret token openly in your code";
18 |
19 | private static String ACCESS_TOKEN = "752908753721237504-knMgQhhj3vxz9t9zjsEgVUtf8zT3jpf";
20 | private static String ACCESS_SECRET = "Never store a secret token openly in your code";
21 |
22 | //--------------------------------------------------------------------------------------------------//
23 | //--------------------------------------------------------------------------------------------------//
24 | // Return an instance of a Twitter connection object
25 | //--------------------------------------------------------------------------------------------------//
26 | //--------------------------------------------------------------------------------------------------//
27 |
28 |
29 | public Twitter getTwitter() throws TwitterException, IOException
30 | {
31 | ConfigurationBuilder cb = new ConfigurationBuilder();
32 |
33 | cb.setDebugEnabled(true)
34 | .setOAuthConsumerKey(CONSUMER_KEY)
35 | .setOAuthConsumerSecret(CONSUMER_SECRET)
36 | .setOAuthAccessToken(ACCESS_TOKEN)
37 | .setOAuthAccessTokenSecret(ACCESS_SECRET);
38 |
39 | TwitterFactory tf = new TwitterFactory(cb.build());
40 | Twitter twitter = tf.getInstance();
41 |
42 | twitter.setOAuthAccessToken(new AccessToken(ACCESS_TOKEN, ACCESS_SECRET));
43 |
44 | return twitter;
45 | }
46 |
47 |
48 | //--------------------------------------------------------------------------------------------------//
49 | //--------------------------------------------------------------------------------------------------//
50 | // Main application stub
51 | //--------------------------------------------------------------------------------------------------//
52 | //--------------------------------------------------------------------------------------------------//
53 |
54 | public static void main(String[] args)
55 | {
56 | String queryString = "Obama";
57 |
58 | String dir = "/Users/tonyveale/Desktop/SemEval 2015/";
59 |
60 | try {
61 | TweetSearcher searcher = new TweetSearcher();
62 |
63 | Twitter twitter = searcher.getTwitter();
64 |
65 | Query query = new Query().query(queryString).resultType(Query.RECENT);
66 |
67 | query.count(10);
68 |
69 | QueryResult result;
70 |
71 | searcher.openDribbleFile(dir + "metaphorical tweets.idx");
72 |
73 |
74 |
75 | do {
76 | result = twitter.search(query);
77 |
78 | System.out.println(query + "\n");
79 |
80 | List tweets = result.getTweets();
81 |
82 |
83 | for (Status tweet : tweets)
84 | {
85 | long id = tweet.getId();
86 | StringBuffer text = new StringBuffer(tweet.getText());
87 |
88 | for (int i = 0; i < text.length(); i++)
89 | if (text.charAt(i) == '\n')
90 | text.setCharAt(i, ' ');
91 |
92 | searcher.printlnDribbleFile(id + "\t" + text + "\t" + tweet.getRetweetCount());
93 | }
94 | }
95 | while ((query = result.nextQuery()) != null);
96 |
97 |
98 |
99 | System.exit(0);
100 | }
101 | catch (Exception te)
102 | {
103 | te.printStackTrace();
104 | System.out.println("Failed to search tweets: " + te.getMessage());
105 | System.exit(-1);
106 | }
107 |
108 |
109 | }
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/TwitterbotTrigger.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | // Contains information about a triggering tweet for a Twitterbot
4 |
5 | public class TwitterbotTrigger
6 | {
7 | private String handle = null;
8 | private String tweet = null;
9 |
10 | private Long tweetId = null;
11 |
12 |
13 | //--------------------------------------------------------------------------//
14 | //--------------------------------------------------------------------------//
15 | // Constructors
16 | //--------------------------------------------------------------------------//
17 | //--------------------------------------------------------------------------//
18 |
19 |
20 | public TwitterbotTrigger() {}
21 |
22 | public TwitterbotTrigger(String handle, String tweet, Long id)
23 | {
24 | this.handle = handle;
25 | this.tweet = tweet;
26 | this.tweetId = id;
27 | }
28 |
29 |
30 | //--------------------------------------------------------------------------//
31 | //--------------------------------------------------------------------------//
32 | // Accessors
33 | //--------------------------------------------------------------------------//
34 | //--------------------------------------------------------------------------//
35 |
36 | public String getHandle()
37 | {
38 | return handle;
39 | }
40 |
41 |
42 | public String getTweet()
43 | {
44 | return tweet;
45 | }
46 |
47 | public Long getTweetId()
48 | {
49 | return tweetId;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/NOC/CODE/twitterbotics/VennDiagram.java:
--------------------------------------------------------------------------------
1 | package twitterbotics;
2 |
3 | import javax.imageio.ImageIO;
4 | import java.awt.*;
5 | import java.awt.geom.*;
6 | import java.awt.image.BufferedImage;
7 | import java.io.ByteArrayInputStream;
8 | import java.io.ByteArrayOutputStream;
9 | import java.io.File;
10 | import java.io.InputStream;
11 | import java.util.ArrayList;
12 | import java.util.Vector;
13 |
14 |
15 | public class VennDiagram extends Frame {
16 |
17 | private String metaphor1, metaphor2, intersection1, intersection2;
18 | private Color colorLeft,colorRight,colorMixed;
19 |
20 |
21 | private static int WIDTH=1000, HEIGHT=700, HEIGHT_DIFF = 100;
22 | private static final int RADIUS=200;
23 | private static final int INTERSECTION_LENGTH=120;
24 |
25 | private static final int X1= WIDTH/2 - (6*RADIUS)/6 - INTERSECTION_LENGTH;
26 | private static int Y1= HEIGHT/2 - (4*RADIUS)/4;
27 | private static final int X2 = WIDTH/2 - (6*RADIUS)/6 + INTERSECTION_LENGTH;
28 | private static int Y2 = HEIGHT/2 - (4*RADIUS)/4;
29 |
30 | private static final int XM = WIDTH/2;
31 | private static final int Xd = 0;
32 |
33 | private static final int LINE_START=40;
34 | private static final int LINE_END=200;
35 | private static final int POINTS_R=5;
36 |
37 | private static final int LONG_STRING = 20;
38 | private static final int FONT_SIZE = 30;
39 |
40 | private static final Font FONT = new Font("Lucida", Font.BOLD, FONT_SIZE);
41 | private static Color LINE_COLOR = Color.black;
42 |
43 | private static int STROKE_THICKNESS = 6;
44 | private static int BALL_DIAMETER = 5;
45 |
46 | //--------------------------------------------------------------------------//
47 | //--------------------------------------------------------------------------//
48 | // Constructors
49 | //--------------------------------------------------------------------------//
50 | //--------------------------------------------------------------------------//
51 |
52 | public VennDiagram(String meta1, String meta2, String inter) {
53 | metaphor1 = meta1;
54 | metaphor2 = meta2;
55 | intersection1 = inter;
56 | prepareFrame();
57 | setRandomColor();
58 | }
59 |
60 | public VennDiagram(String meta1, String meta2, String inter1, String inter2) {
61 | metaphor1 = meta1;
62 | metaphor2 = meta2;
63 | intersection1 = inter1;
64 | intersection2 = inter2;
65 | prepareFrame();
66 | setRandomColor();
67 | }
68 |
69 |
70 | public void setRandomColor() {
71 | int r = (int)(Math.random() * 8);
72 | switch (r) {
73 | case 0:
74 | setColor(Color.yellow,Color.lightGray);
75 | break;
76 | case 1:
77 | setColor(Color.orange,Color.red);
78 | break;
79 | case 2:
80 | setColor(Color.orange,Color.magenta);
81 | break;
82 | case 3:
83 | setColor(Color.cyan,Color.orange);
84 | break;
85 | case 4:
86 | setColor(Color.lightGray,Color.pink);
87 | break;
88 | case 5:
89 | setColor(Color.white,Color.lightGray);
90 | break;
91 | case 6:
92 | setColor(Color.yellow,Color.cyan);
93 | break;
94 | default:
95 | setColor(Color.cyan,Color.yellow);
96 | }
97 | }
98 |
99 |
100 | private void prepareFrame() {
101 | if (intersection2 == null)
102 | HEIGHT = HEIGHT-HEIGHT_DIFF;
103 | else
104 | if (breakStrings(intersection1, LONG_STRING).size() > 3)
105 | {
106 | HEIGHT = HEIGHT+HEIGHT_DIFF;
107 | Y1 = Y1 + HEIGHT_DIFF/2;
108 | Y2 = Y2 + HEIGHT_DIFF/2;
109 | }
110 |
111 | if (intersection2 != null && breakStrings(intersection2, LONG_STRING).size() > 3)
112 | {
113 | HEIGHT = HEIGHT+HEIGHT_DIFF/2;
114 | Y1 = Y1 + HEIGHT_DIFF/4;
115 | Y2 = Y2 + HEIGHT_DIFF/4;
116 | }
117 |
118 | setSize(WIDTH, HEIGHT);
119 | }
120 |
121 |
122 | public void paint(Graphics g) {
123 |
124 | // Setting white background
125 |
126 | g.setColor(Color.WHITE);
127 | g.fillRect(0,0, WIDTH, HEIGHT);
128 |
129 | g.setColor(colorLeft);
130 | g.fillOval(X1, Y1, RADIUS*2, RADIUS*2);
131 |
132 | // Right circle
133 | g.setColor(colorRight);
134 | g.fillOval(X2, Y2, RADIUS*2, RADIUS*2);
135 |
136 | // Intersection
137 | g.setColor(colorMixed);
138 | // Looping over all pixels, finding those which lie in both circles and coloring them
139 | for (int x=0; x meta1Strings = breakStrings(metaphor1, LONG_STRING/2);
189 |
190 | int xPlace = (FONT_SIZE/2 * meta1Strings.get(meta1Strings.size()-1).length()) + FONT_SIZE;
191 |
192 | for (int i=0; i meta2Strings = breakStrings(metaphor2, LONG_STRING/2);
198 |
199 |
200 | for (int i=0; i inter1Strings = breakStrings(intersection1, LONG_STRING);
208 |
209 | xPlace = (FONT_SIZE/2 * LONG_STRING) / 2;
210 | for (int i=0; i inter2Strings = breakStrings(intersection2, LONG_STRING);
225 |
226 | xPlace = (FONT_SIZE/2 * inter2Strings.get(inter2Strings.size()-1).length()) / 2;
227 | for (int i=0; i< inter2Strings.size(); i++)
228 | {
229 | int labelSize = g.getFontMetrics().stringWidth(inter2Strings.get(i));
230 |
231 | g.drawString(inter2Strings.get(i), XM - Xd - labelSize/2, Y1 + RADIUS*2 + (i * FONT_SIZE) + 65);
232 | }
233 | }
234 | }
235 |
236 |
237 |
238 | static ArrayList breakStrings(String string, int maxLen) {
239 |
240 | ArrayList brokenStrings = new ArrayList();
241 |
242 | String[] spaceSplit = string.split(" ");
243 | int len = 0;
244 | StringBuffer sb = new StringBuffer();
245 |
246 | for(String str:spaceSplit) {
247 | if (sb.length()+str.length() < maxLen) {
248 | if(sb.length() > 0)
249 | sb.append(" ");
250 | sb.append(str);
251 | }
252 | else if(str.length() > maxLen) { //sb + str > LS
253 | brokenStrings.add(sb.toString());
254 | brokenStrings.add(str);
255 | sb = new StringBuffer();
256 | }
257 | else {
258 | brokenStrings.add(sb.toString());
259 | sb = new StringBuffer(str);
260 | }
261 | }
262 |
263 | if(sb.length() > 0)
264 | brokenStrings.add(sb.toString());
265 |
266 | return brokenStrings;
267 | }
268 |
269 |
270 |
271 | public void setColor(Color color1, Color color2) {
272 | double totalAlpha = color1.getAlpha() + color2.getAlpha();
273 | double w1 = color1.getAlpha() / totalAlpha;
274 | double w2 = color2.getAlpha() / totalAlpha;
275 |
276 | double r = w1 * color1.getRed() + w2 * color2.getRed();
277 | double g = w1 * color1.getGreen() + w2 * color2.getGreen();
278 | double b = w1 * color1.getBlue() + w2 * color2.getBlue();
279 | double a = Math.max(color2.getAlpha(), color2.getAlpha());
280 |
281 | colorMixed = new Color((int) r, (int) g, (int) b, (int) a);
282 | this.colorLeft = color1;
283 | this.colorRight = color2;
284 | }
285 |
286 |
287 | public File saveImage(String filename) {
288 |
289 | BufferedImage bi = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
290 | Graphics g = bi.createGraphics();
291 | this.paint(g); //this == JComponent
292 | g.dispose();
293 |
294 | try {
295 | File file = new File(filename);
296 |
297 | ImageIO.write(bi, "jpg", file);
298 |
299 | return file;
300 | } catch (Exception e) {
301 | }
302 |
303 | return null;
304 | }
305 |
306 |
307 | public InputStream toInputStream() {
308 | BufferedImage bi = new BufferedImage(this.getSize().width, this.getSize().height, BufferedImage.TYPE_INT_RGB);
309 | Graphics g = bi.createGraphics();
310 | this.paint(g); //this == JComponent
311 | g.dispose();
312 | ByteArrayOutputStream os = new ByteArrayOutputStream();
313 | try {
314 | ImageIO.write(bi, "jpg", os);
315 | } catch (Exception e) {
316 | }
317 | InputStream fis = new ByteArrayInputStream(os.toByteArray());
318 | return fis;
319 | }
320 |
321 |
322 | //--------------------------------------------------------------------------//
323 | //--------------------------------------------------------------------------//
324 | // Main Stub
325 | //--------------------------------------------------------------------------//
326 | //--------------------------------------------------------------------------//
327 |
328 | public static void main(String[] args){
329 | VennDiagram m = new VennDiagram("atrocious strategists", "underachievers",
330 | "Thugs who develop sympathetic muscles",
331 | "Sympathetic \"best friends\" who are roused by a rabble rouser");
332 | m.setRandomColor();
333 | m.saveImage("test.jpg");
334 |
335 |
336 | }
337 |
338 |
339 | }
340 |
--------------------------------------------------------------------------------
/NOC/DATA/TSV Lists/List of desserts.txt:
--------------------------------------------------------------------------------
1 | Dessert Ingredients
Almond tart almonds, eggs, milk, sugar, flour
Angel food cake egg whites, sponge, sugar
Apple brown betty apples, crumbs, butter, brown sugar
Apple Charlotte apples, sugar, butter, bread slices
Apple crumble apples, flour, sugar, butter
Banana muffins bananas, flour, eggs, milk, sugar
Banoffee pie bananas, cream, toffee, biscuit crumbs
Battenberg cake sponge, jam, marzipan
Belgian waffles eggs, milk, flour, sugar, vanilla essence
Biscotti Regina sesame seeds, orange zest, flour, eggs, milk
Biscuit Tortoni heavy cream, almonds, chocolate chips, rum
Black Forest gateau cherries, cocoa powder, eggs, flour, whipped cream, kirsch, chocolate curls
Blueberry pie blueberries, butter, milk, sugar, flour
Boston cream pie heavy cream, buttermilk, flour, button, sugar
Bread and butter pudding bread slices, sugar, butter, milk, eggs, cinnamon
Bundt cake eggs, milk, flour, sugar, lemon zest
Butterkuchen eggs, butter, flour, sugar
Butterscotch pie brown sugar, egg yolks, cornstarch, milk
Cake pops eggs, butter, flour, sugar
Capuccino chocolate muffins coffee powder, eggs, butter, flour, sugar
Caraway seed cake caraway seeds, eggs, butter, flour, sugar
Carrot cake shredded carrots, sultanas, orange zest, cinnamon, nutmeg, flour, eggs
Cassata cake ricotta cheese, cornstarch, butter, flour, citrus oil, vanilla essence
Castella cake sugar, flour, eggs, starch syrup
Chantilly cake heavy cream, flour, butter, eggs
Chelsea buns sugar, flour, eggs, starch syrup, sultanas, raisins
Cherries Jubilee cherries, cherry liqueur, vanilla ice cream
Cherry pie cherries, butter, sugar, flour
Chiffon cake vegetable oil, eggs, sugar, flour, icing sugar
Chocolate bombe ground almonds, cocoa powder, flour, vanilla essence, heavy cream, chocolate
Chocolate brownies chocolate chips, cocoa powder, flour, eggs, sugar, milk
Chocolate chip cookies chocolate chips, cocoa powder, flour, eggs, sugar, milk
Chocolate chip scones chocolate chips, cocoa powder, flour, eggs, sugar, milk, baking powder
Chocolate eclairs choux pastry, chocolate fondant, heavy cream
Chocolate fudge cake golden syrup, cocoa powder, flour, eggs, milk
Chocolate ganache cake brown sugar, cocoa powder, flour, eggs, chocolate ganache
Chocolate lava cake butter, chocolate, cocoa powder, egg yolks, vanilla essence
Chocolate mousse chocolate, cocoa powder, orange zest, egg yolks, egg whites, sugar
Chocolate pralines hazelnuts, almonds, chocolate, sugar, pecans, cream
Chocolate truffles chocolate ganache, cocoa powder, toasted nuts, heavy cream
Christmas fruitcake dried cherries, raisins, sultanas, dried cranberries, brandy, flour, eggs, milk, sugar, nutmeg
Cinnamon rolls flour, cinnamon, sugar, butter
Coconut cake shredded coconut, flour, milk, eggs, sugar
Coconut Macaroons shredded coconut, condensed milk, egg whites, sugar
Coffee cake coffee powder, flour, milk, sugar, eggs
Cracker cake saltines, blueberries, cool whip, sugar
Crème brûlée vanilla essence, eggs, milk, sugar
Crepes Suzette flour, eggs, sugar, milk, orange juice, orange zest, Grand Marnier
Crumb cake crumbs, brown sugar, butter, flour, cinnamon
Custard tarts custard, butter, flour, sugar, egg yolks, milk
Devil's food cake cocoa powder, coffee powder, sugar, milk, flour, chocolate, eggs, vanilla essence
Double chocolate muffins cocoa powder, chocolate chips, eggs, flour, butter, milk, sugar
Dundee cake sultanas, orange zest, eggs, sugar, flour, butter, currants, almonds
Eccles cakes currants, brown sugar, butter, flour, cinnamon, ground ginger, orange zest
Flourless chocolate cake no flour, chocolate, cocoa powder, egg whites, egg yolks, sugar
Foam cake butter, sugar, egg whites, baking powder
Fruit flan flour, butter, sugar, heavy cream, blueberries, apples, bananas
Fruit salad blueberries, apples, bananas
Funnel cakes eggs, flour, sugar, vegetable oil, baking powder, cinnamon
Gelato milk, sugar, egg yolks, cream, vanilla essence
German chocolate cake butter, sugar, chocolate, egg yolks, egg whites, shredded coconut, chopped pecans, buttermilk
Gingerbread house golden syrup, ground ginger, flour, butter
Gingerbread men golden syrup, ground ginger, flour, butter, chocolate buttons
Gooey butter cake flour, butter, sugar, eggs, vanilla essence, cream cheese
Gugelhupf cake egg yolks, egg whites, butter, cocoa powder, flour, milk, icing sugar
Hot cakes with syrup eggs, flour, sugar, baking powder, golden syrup
Hot milk cake eggs, butter, flour, sugar, hot milk, vanilla essence
Hummingbird cake crushed pineapple, bananas, pecans, eggs, vanilla essence, cinnamon, flour
Ice cream cake ice cream, flour, eggs, sugar, butter
Ice cream sundaes ice cream, chocolate sauce, pecans
Jaffa cakes chocolate, flour, eggs, flour, sugar, orange zest, gelatin
Jam rolly polly jam, flour, eggs, sugar, butter
Jam tart jam, flour, eggs, sugar, butter
Jamaican rum cake rum, ground ginger, flour, eggs, butter
Jewish apple cake apples, orange juice, vanilla essence, cinnamon, eggs, flour, sugar
Kentucky jam cake buttermilk, pecans, jam, raisins, eggs, butter, cinnamon, ground cloves
Ladyfinger biscuits egg whites, egg yolks, sugar, flour
Lamington cake chocolate, heavy cream, shredded coconut, flour, vanilla essence
Lardy cake lard, sugar, flour, milk, ground ginger, ground cloves
Layer cake ground almonds, buttercream, flour, sugar, eggs, butter
Lemon citrus tart lemon zest, egg yolks, butter, flour, sugar, lemon juice
Lemon drizzle cake lemon zest, eggs, butter, flour, sugar, lemon juice
Lemon meringue pie egg yolks, egg whites, meringue, lemon juice, lemon zest, sugar, flour, butter
Madeira cake butter, milk, sugar, eggs
Madeleines eggs, sugar, flour, lemon zest, sugar, baking powder
Chocolate marble cake sugar, flour, cocoa powder, eggs, vanilla essence
Marzipan cake marzipan, almond paste, ground almonds, sugar, eggs
Meringue cake cornstarch, sugar, meringue, heavy cream, egg whites
Millionaire's shortbread squares flour, butter, golden syrup, dark chocolate, condensed milk
Molasses cake molasses, brown sugar, ground ginger, cinnamon, flour, coffee powder
Molten chocolate cake dark chocolate, flour, eggs, butter, vanilla essence
Napoleon cream slice heavy cream, sugar, butter, flour
Neapolitan ice cream ice cream, wafers
New York cheesecake cream cheese, biscuit crumbs, heavy cream, golden syrup, lemon zest
Nutella pancakes Nutella, eggs, flour, milk
Pain d'Epices rye flour, ground ginger, cinnamon, eggs
Pan Forte hazelnuts, almonds, ground ginger, cinnamon, orange zest, honey, flour
Pandan cake egg yolks, coconut milk, sugar, egg whites, pandan leaves
Panna cotta vanilla essence, eggs, heavy cream, sugar, fresh mint, liqueur
Pannetone bread slices, sugar, butter, milk, eggs, cinnamon
Pavlova cornflour, vanilla essence, egg whites, sugar
Peach Melba peaches, vanilla essence, sugar, lemon juice
Peanut butter cups peanut butter, chocolate, sugar
Pear flan pears, milk, sugar, flour, eggs
Pecan pie pecans, golden syrup, flour, eggs
Petit fours sugar, butter, flour, eggs
Poire belle Helene pears, sugar, lemon juice, vanilla essence, chocolate, heavy cream
Pound cake butter, sugar, eggs, flour, vanilla essence
Prinzregententorte chocolate, buttercream, apricot jam, flour, eggs, sugar
Profiteroles and chocolate sauce flour, eggs, butter, heavy cream, chocolate
Pumpkin pie pumpkin, cinnamon, eggs, milk, flour
Punschkrapfen orange zest, rum, apricot jam, chocolate, butter, flour
Red velvet cake chocolate, cocoa powder, beetroot juice, eggs, vanilla essence, sugar
Rice Krispie cakes Rice Krispies, chocolate
Rice pudding white rice, milk, sugar, cinnamon
Rock cakes butter, milk, sugar, eggs, raisins
Rocky road chocolate, golden syrup, cocoa powder, mini marshmallows, biscuit crumbs
Rum baba eggs, butter, rum, heavy cream, vanilla essence
Rum cake rum, eggs, flour, butter, chopped walnuts
Sachertorte apricot jam, chocolate, ground almonds, flour, vanilla essence
Sesame seed cake sesame seeds, sugar, eggs, flour
Shoofly pie brown sugar, molasses, lard, flour, vanilla essence, butter
Simnel cake cherries, butter, brown sugar, sultanas, orange zest, marzipan, apricot jam
Snickers cake peanuts, marshmallow fluff, peanut butter, condensed milk, heavy cream
Spice cake ground ginger, ground cloves, cinnamon, flour, eggs, milk, butter
Sponge cake milk, eggs, flour, sugar, vanilla essence
Stollen cake ground nutmeg, ground cloves, marzipan, raisins, flour, butter
Strawberry cheesecake strawberries, cream cheese, biscuit crumbs, heavy cream
Strawberry shortcake strawberries, sugar, flour, butter
Streuselkuchen chopped walnuts, cinnamon, ground cloves, butter, cornstarch
Swiss roll flour, eggs, butter, heavy cream, chocolate
Tarta de Santiago almonds, eggs, milk, sugar, flour, lemon zest, orange zest
Tarte Tatin apples, butter, egg yolks, flour
Tartufo heavy cream, chocolate cookie crumbs, cherries, chocolate
Chocolate marshmallow tea cakes dark chocolate, egg whites, biscuit crumbs, golden syrup
Tea loaf sultanas, brown sugar, orange juice, hot tea, flour, butter
Tin roof pie corn flakes, golden syrup, peanuts, ice cream
Tipsy cake cornstarch, egg yolks, heavy cream, brandy, flour
Tiramisu Marsala wine, mascarpone cheese, dark chocolate, cocoa powder, coffee powder, sponge fingers
Torta caprese dark chocolate, almond essence, ground hazelnuts, ground almonds, liquore strega
Torta de nata hot milk, sugar, eggs
Treacle tart golden syrup, lemon zest, butter, flour
Tres leches cake whipped cream, condensed milk, milk, vanilla essence, flour
Pineapple upside-down cake pineapple rings, brown sugar, vanilla essence, eggs, flour
Vanilla cupcakes butter, icing sugar, vanilla essence, buttercream, flour, eggs
Apple Strudel puff pastry, apples, cinnamon, orange zest, nutmeg, sultanas, breadcrumbs
Vinegar pie egg yolks, egg whites, lemon juice, vinegar, flour, butter
Vanilla wafer cake shredded coconut, flour, milk, eggs, sugar, chopped pecans, vanilla essence
Walnut cake walnut halves, eggs, butter, flour, sugar, chopped walnuts, vanilla essence, icing sugar
White sugar sponge cake rice flour, white sugar, baker's yeast
Yule log egg yolks, egg whites, cocoa powder, vanilla essence, chocolate
Zabaione egg yolks, Marsala wine, white sugar
Mille feuille vanilla cake puff pastry, egg yolks, vanilla essence, cream, icing sugar
Raspberry mille-feuille raspberries, puff pastry, egg yolks, cream, icing sugar
2 |
--------------------------------------------------------------------------------
/NOC/DATA/TSV Lists/List of ingredients.txt:
--------------------------------------------------------------------------------
1 | Ingredient Count Substitutions
flour 96 gypsum, cement, road grit, powdered bones, baby powder, uncut heroin, papier maché, chalk dust, powdered bat guano, talcum powder, powdered soap, ashes of a cremated loved one, radioactive desert sand, granite dust, flea powder, Shake-n-Vac, coffin dust
sugar 82 broken glass, powdered glass, pebble dash, rock salt, road grit, powdered crystal meth, frog spawn, anthrax spores
eggs 73 snake embryos, burst eyeballs, pickled goat's eyes, rotten eggs
butter 61 yellow paint, rancid butter, liposuctioned fat, cow's ear wax, hamburger helper, whale blubber, pond scum, melted plastic
milk 35 white paint, white-out fluid, milk of Magnesia, wood glue, shampoo, baby vomit, camel drool, rat milk, sheep dip, industrial effluent
vanilla essence 29 arsenic, cyanide powder, cheap aftershave, crushed laxatives, ant eggs, flop sweat, mildew, Polonium-210, Febreze, armpit sweat
chocolate 21 roofing tar, melted tarmac, hot tar, elephant dung, lumps of clay, swamp mud, diaper filling, used coffee grounds, shoe polish
heavy cream 20 plaster of Paris, tiling grout, yellow snow, wallpaper paste, year-old crusty mayonnaise, hemorrhoid cream, drain cleaner, whale blubber, liposuction fat, lumpy white paint
cocoa powder 19 dirt, fistfuls of earth, toxic sludge, India ink, soot, Shake-and-Vac
egg yolks 19 melted pingpong balls, yellow golfballs, zit pus
cinnamon 18 brick dust, rat droppings, fire ants, cobwebs
egg whites 15 chicken drool, cow's saliva, eyeball jelly, frog spawn, liquid detergent, denture glue, pond scum, liposuction fat
orange zest 12 tennis-ball fluff, sunburnt skin flakes, sunburnt cellulite, congealed fake tan, fake tan and cellulite, bellybutton lint
golden syrup 11 dog phlegm, cat vomit, wood varnish, floor polish
brown sugar 10 used kitty litter, crushed gravel
ground ginger 9 skunk musk, toenail clippings, fingernail clippings, eye crud, clown dandruff, foot fungus, concentrated wasabi, pet kibble
apples 8 wax apples, green tennis balls, apple cores, snooker balls, worm-filled apples
lemon zest 8 canary droppings, ear wax, yellow paint scrapings, lemon-scented air freshener
sultanas 7 cod-liver oil capsules, moth balls, used suppositories, pus-filled zits, sour grapes, bubblewrap
almonds 6 false fingernails, broken teeth, snake fangs, pistachio shells, snake scales, small-caliber bullets, date pits, olive pits
icing sugar 6 powdered glass, dandruff, hobo dandruff, anthrax
lemon juice 6 battery acid, acetone, cat pee, napalm, mouthwash
chocolate chips 5 dead flies, rat droppings
rum 5 gasoline, kerosene, paint stripper, pickled pirate blood, lighter fluid, bug spray, paint thinner, diesel
cherries 5 cherry bombs, red ball-bearings
cornstarch 5 washing powder, laundry starch
coffee powder 5 black bile, brown shoe polish, rust flakes, weasel skat, mahogany dust, baked-in oven grease
raisins 5 dead flies, fish eyes, cancerous polyps, witch's warts, spit balls
bananas 5 wax bananas,banana skins, pickled parsnips, used banana-hammock thongs, yellow umbrella handles
ground almonds 5 sawdust, minced garlic, ground tree bark
baking powder 5 gunpowder, talcum powder, borax powder, rat poison, anthrax
cream 5 toothpaste, rabid dog froth, shampoo, oven cleaner
pecans 5 dried cockroaches, crusty scabs, broken teeth
shredded coconut 5 dandruff, eczema flakes, asbestos
biscuit crumbs 5 chewed dog biscuits, polystyrene flakes, cement dust, pot pouri
dark chocolate 5 black shoe polish, shredded tyres
blueberries 4 thumb tacks, balls of blue tack, poison ivy berries, juicy melanomas
marzipan 4 wet urinal cakes, C4 plastique, play dough, foot cheese
condensed milk 4 sun tan lotion, wood glue, hair cream, car polish, rubber cement, acne cream
ice cream 4 muddy slush, frozen mud, frozen dog turds
ground cloves 4 bloody boogers, plastic shavings, iron shavings, burnt toenail clippings
jam 4 congealed blood, arterial blood, bloody stools, boiled lip gloss, red-hot Tabasco, nail polish
apricot jam 4 cat vomit, road pizza, axle grease, snail slime
bread slices 3 ceiling tiles, sanitory pads, attic insulation, burnt toast, wet toilet paper, roof shingles, paving slabs, dirty socks
orange juice 3 battery acid, golden retriever pee, orangutan pee, horse linament, sun tan oil, swamp water, agent orange, orangutan sweat
cream cheese 3 foot cheese, ear wax, liposuctioned fat, sweaty cheese, volcanic lava, window putty
nutmeg 3 mouse droppings, wood shavings
buttercream 3 acne cream, drain cleaner
chopped walnuts 3 broken walnut shells, candied rabbit brain
puff pastry 3 fried diapers, deep-fried duvet, odour-eater insoles, wet corrugated cardboard
chocolate ganache 2 diaper filling, sewer sludge, melted tyre rubber, creosote
hazelnuts 2 gallstones, kidney stones, brown pebbles, gizzard stones
brandy 2 window cleaner, weed killer, hobo sweat, distilled wino blood, nail polish remover
sesame seeds 2 spider eggs, pine needles, wasp stingers, red-hot chili seeds
currants 2 Bubonic pustules, blackheads, red-hot chillies
crumbs 2 floor sweepings, garden mulch, cigarette ash
chopped pecans 2 brass screws, seashells
buttermilk 2 albino saliva
hot milk 2 wet guano, baby vomit
vegetable oil 2 hair oil, hog sweat
lard 2 liposuctioned fat, rendered human fat
whipped cream 2 shaving foam, whale blubber
molasses 2 creosote, motor oil
peanut butter 2 wet parrot droppings, wet sawdust
pears 2 avocado husks
starch syrup 2 superglue
peanuts 2 cherry pits
strawberries 2 chicken hearts
Marsala wine 2 Italian rubbing alcohol, cheap cough medicine
sponge 2 mattress filling, odour-eater insoles, sanitary towels
white sugar 2 bath salts
meringue 2 used Kleenex , diaper padding, sanitary pads, mattress stuffing, used Kleenex from a teenager's bedroom
toasted nuts 1 metal nuts and bolts, rusty staples, red-hot chili seeds
chocolate buttons 1 brown metal buttons
vanilla ice cream 1 scoops of yellow snow
dried cherries 1 cherry pits, date pits
crushed pineapple 1 crushed urinal cakes
dried cranberries 1 bloody warts
chocolate sauce 1 wet soot, motor oil
gelatin 1 human bone marrow, superglue, silicone breast implants, man-o-war jellyfish, ectoplasm
chocolate fondant 1 volcanic lava
ricotta cheese 1 whale blubber, drywall lining
chocolate curls 1 mahogany shavings, rusty staples
citrus oil 1 bug spray, air freshener spray, Prussic acid
almond paste 1 crushed peach pits
toffee 1 wood glue, congealed wood varnish
kirsch 1 WD40
saltines 1 sardines
wafers 1 corrugated cardboard, index cards
Nutella 1 used hair-removal wax, melted vinyl, window putty
rye flour 1 tree moss
honey 1 bear drool
coconut milk 1 SPF-50 suntan lotion
pandan leaves 1 oily rags
fresh mint 1 nettles, poison ivy
liqueur 1 expensive lighter fluid
cornflour 1 anthrax spores
peaches 1 peach pits, tennis balls
cool whip 1 Silicone Mastic
cherry liqueur 1 German lighter fluid, boiled lipgloss
Grand Marnier 1 flop sweat of a French hobo, agent orange, orangutan sweat
pumpkin 1 old leather football, football helmet
beetroot juice 1 the blood of a loved one, boiled lipgloss
Rice Krispies 1 fried ant eggs, bubblewrap, gravel
white rice 1 ricin, ant eggs
mini marshmallows 1 cotton balls, the tops of Q-tips, coughed-up hairballs, dust bunnies, bubblewrap
caraway seeds 1 cherry pits, iron filings
custard 1 melted plastic, volcanic lava, melted traffic cones
marshmallow fluff 1 cotton wool, shredded plastic, dust bunnies, coughed-up hairballs
ground nutmeg 1 rust flakes, iron filings
chocolate cookie crumbs 1 dead ants, dead termites, dirt
hot tea 1 warm horse urine
corn flakes 1 soda-can ring pulls
choux pastry 1 shoe leather, scrotal sac skin
mascarpone cheese 1 polyfilla plaster, spackle, mattress foam, liposuction fat
sponge fingers 1 the fingers of real ladies, dead man's fingers, puppy's tails
almond essence 1 Prussic acid, floor polish
ground hazelnuts 1 sawdust, ground tree bark
liquore strega 1 Italian rubbing alcohol, Italian lighter fluid
pineapple rings 1 curtain rings, napkin rings
no flour 1 strong flour
breadcrumbs 1 sawdust, ground tree bark
vinegar 1 battery acid, molecular acid, cat pee, sulphuric acid
walnut halves 1 candied rabbit brains
rice flour 1 powdered ricin, anthrax spores
shredded carrots 1 rabbit droppings
baker's yeast 1 gunpowder, flesh-eating bacteria
raspberries 1 poison ivy berries, cherry bombs, moth balls
2 |
--------------------------------------------------------------------------------
/NOC/DATA/TSV Lists/Veale's affordances.txt:
--------------------------------------------------------------------------------
1 | Affordance Past Tense
shooting with shot with
pistol-whipping with pistol-whipped with
attacking with attacked with
overwhelming with overwhelmed with
stabbing with stabbed with
puncturing with punctured with
blasting with blasted with
peppering with peppered with
knocking out with knocked out with
irritating with irritated with
dominating with dominated with
scarring with scarred with
burning with burnt with
withering with withered with
tongue-lashing with tongue-lashed with
squirting with squirted with
walloping with walloped with
hitting with hit with
bombing with bombed with
blowing up with blew up with
blowing away with blew away with
slashing with slashed with
cutting with cut with
gutting with gutted with
ripping apart with ripped apart with
flattening with flattened with
crushing with crushed with
impaling with impaled with
deafening with deafened with
poisoning with poisoned with
dumbing down with dumbed down with
stinging with stung with
blistering with blistered with
misdirecting with misdirected with
confusing with confused with
distracting with distracted with
neutralizing with neutralized with
enchanting with enchanted with
hacking with hacked with
smiting with smote with
choking with choked with
inducing suicidal thoughts with depressed to the point of suicide with
atom-smashing with atom-smashed with
shaming with shamed with
humiliating with humiliated with
entrancing with entranced with
manipulating with manipulated with
slicing with sliced with
horrifying with horrified with
frightening away with frightened away with
repelling with repelled with
sickening with sickened with
bombarding with bombarded with
pummelling with pummelled with
hammering with hammered with
battering with battered with
beating black-and-blue with beat black-and-blue with
shredding with shredded with
beating senseless with beat senseless with
pancaking with pancaked with
knocking senseless with knocked senseless with
ass-kicking with ass-kicked with, kicked in the ass with
blinding with blinded with
immobilizing with immobilized with
piercing with pierced with
petrifying with turned to stone with
penetrating with penetrated with
knocking over with knocked over with
damning with damned with
running through with ran through with
disorienting with disoriented with
whipping with whipped with
pricking with pricked with
dismembering with dismembered with
smashing with smashed with
slamming with slammed with
pepper-spraying with pepper-sprayed with
nauseating with nauseated with
exploding with exploded with
drowning with drowned with
targeting with targeted with
liquidating with liquidated with
suffocating with suffocated with
shocking with shocked with
producing suicidal thoughts with pushed to the verge of suicide with
degrading with degraded with
undermining with undermined with
brutalizing with brutalized with
running over with ran over with
herniating with herniated with
intimidating with intimidated with
driving to suicide with drove to suicide with
producing suicidal thoughts in with pushed to the edge of suicide with
obliterating with obliterated with
reducing to ash with reduced to ash with
entangling with ensnared with
electrocuting with electrocuted with
devastating with devastated with
head-butting with head-butted with
scatter-shooting with scatter-shot with
vaporizing with vaporized with
melting with melted with
electrifying with electrified with
scratching with scratched with
wrong-footing with wrong-footed with
snake-charming with snake-charmed with, charmed like a snake with
clubbing with clubbed with
French-kissing with French-kissed with
perforating with perforated with
traducing with traduced with
slandering with slandered with
bullying into submission with bullied into submission with
hypnotizing with hypnotized with
controlling with controlled with
hardening arteries with filled with cholesterol with
s-s-s-shooting with s-s-s-hot with
frying with fried with
gouging with gouged with
disorientating with disoriented with
enthralling with enthralled with
ramming with rammed with
charming with charmed with
biting with bit with
poking with poked with
kicking senseless with kicked senseless with
kicking with kicked with
clawing with clawed with
weakening with weakened with
under-cutting with under-cut with
swatting with swatted with
torturing with tortured with
shivving with shivved with
shanking with shanked with
chopping with chopped with
destroying with destroyed with
bitch-slapping with bitch-slapped with
bear-hugging with bear-hugged with
savaging with savaged with
mauling with mauled with
groin-kicking with kicked in the groin with
snapping with snapped with
betraying with betrayed with
whacking with whacked with
coshing with coshed with
spraying with sprayed with
zapping with zapped with
infiltrating with infiltrated with
out-thinking with out-thought with
assassinating with assassinated with
crowding out with crowded out with
swatting away with swatted away with
freezing with froze with
nipping with nipped with
terminating with terminated with
infecting with infected with
pistol-whipping pistol-whipped with
terrifying with terrified with
shafting with shafted with
restraining with restrained with
slapping with slapped with
tiring out with tired out with
numbing with numbed with
mowing down with mowed down with
shattering with shattered with
shrinking with shrunk with
splatting with splatted with
crunching with crunched with
stapling with stapled with
kicking black-and-blue with kicked black-and-blue with, kicked senseless with
cutting cut with
burning burned with
slicing sliced with
zapping zapped with
bullying with bullied with
stunning with stunned with
karmic zapping with karmic-zapped with
inflitrating with infiltrated with
2 |
--------------------------------------------------------------------------------
/NOC/DATA/TSV Lists/category list.txt:
--------------------------------------------------------------------------------
1 | Actor
Writer
Singer
Hero
Campaigner
Musician
Politician
Comedian
Composer
Political_Leader
Businessman
Director
Villain
Novelist
Actress
Scientist
Detective
Philosopher
Adventurer
TV_Host
Rock_Singer
Athlete
Criminal
Artist
CEO
Policeman
President
Painter
Father
Crimeboss
Religious_Leader
Humorist
Billionaire
Tyrant
Pioneer
Sportsman
Poet
Spy
Inventor
Killer
Heroine
Teacher
Child
General
Guitarist
Pop_Singer
Astronaut
Advisor
Magician
Pundit
Friend
Recluse
Schoolkid
Fool
Reporter
Pilot
Journalist
Pianist
Chef
Playwright
Sidekick
Soldier
Terrorist
Nerd
Explorer
Emperor
Lawyer
Professor
Fashion_Model
Serial_Killer
Wizard
Military_Leader
Jedi_Knight
Secret_Agent
Wanderer
Boxer
Interviewer
Fugitive
Thief
Software_Engineer
Prime_Minister
Wife
Captain
Publisher
Lothario
Restauranteur
King
Hunter
Traitor
Mastermind
Rapper
Diarist
Princess
Student
Aviator
Strongman
Sculptor
FBI_Agent
Bureaucrat
Political_Advocate
Dictator
Has-Been
Warrior
Robot
Bully
Aristocrat
Womanizer
Loner
Hacker
Royal
Technologist
Queen
Snob
Economist
Outdoorsman
Assassin
Guru
Narcissist
Vice_President
Doctor
Dancer
Son
Dissident
Radio_Host
Psychiatrist
Private_Detective
Playboy
Intellectual
Engineer
Geek
Lover
Teenager
Media_Tycoon
Cop
Rebel
Footballer
Action_Star
Superhero
Country_Singer
Monk
Mentor
Mathematician
Crime_Fighter
Neighbour
Investor
Feminist
Bounty_Hunter
Philanthropist
Psychopath
Pornographer
Genius
Preacher
Transvestite
Tennis_player
Drummer
Communist
Lady
Malcontent
Daughter
Gentleman
Evolutionary_Biologist
Biblical_Hero
Physicist
Crooner
Mayor
Clown
Punk
Invalid
Husband
Martial_Artist
Conqueror
Sailor
Conservative
Revolutionary
Saxophonist
Activist
Promoter
Programmer
Baseball_Player
Smuggler
Historian
Henchman
Foreigner
Duck
First_Lady
Orphan
Radio_Personality
Archeologist
Chess_Player
Olympian
Presenter
Lawman
Cyclist
Propagandist
Judge
Lecher
Fashion_Designer
Basketball_Player
Scholar
Female_Impersonator
Sister
Motorcyclist
Soccer_player
Trader
Mother
Vigilante
Brother
Paleontologist
Fascist
Linguist
Showman
Pope
Skeptic
Newspaper_Magnate
Architect
Therapist
Producer
Grump
Exile
Thug
Old_Man
Shyster
News_Reader
Anchorman
AI_Program
Software_Agent
Opera_Singer
French_Buffoon
Executive
Pretender
Cartoonist
Android
Vampire
English_Buffoon
Bodybuilder
Colonel
Caveman
Adulteress
Cowboy
Roman_Gladiator
Gladiator
Hotelier
Songwriter
Con_Man
Capitalist
Orator
Racer
Autocrat
Tycoon
Informant
Prisoner
Entertainer
Messiah
Norse_God
God
Convict
Demonologist
Vampire_Slayer
Demon
Miser
Clerk
Atheist
Astronomer
Shopper
Madman
Host
Lexicographer
Police_Commissioner
Frontiersman
Cannibal
Escapologist
Sponge
Apostle
Octopus
Scrounger
Boss
Crab
Visionary
Veteran
Golf_Player
Vagabond
Developer
Prosecutor
Complainer
Curmudgeon
Heretic
Reggae_Singer
Ice_Hockey_Player
Confectioner
Folk_Singer
Sheriff
Divorcee
Puppet
Humanist
Damsel
Cross_Dresser
Shooting_Guard
Savant
Cyborg
Computer
Cheat
Wrestler
Dreamer
Stuntman
Patsy
Widow
Film_Maker
Assistant
Adman
Obsessive
Dwarf
Copilot
Symbologist
Performer
District_Attorney
Racist
DJ
Necromancer
Farm_boy
Prince
Counsellor
Maiden
Nazi_Bureaucrat
Daredevil
Predator
Helper
Barman
Barfly
Drunk
Ascetic
Pickup_Artist
Porn_Star
Telepath
Raccoon
Tree
Rabbit
Ogre
Pig
Coyote
Pirate
Girlfriend
TV_Presenter
Skunk
Circus_Performer
Freak
Roman_General
Seductress
Scandalmonger
Slave
Roman_Slave
Role_Model
Alien
Stepmother
Industrialist
Canary
Cat
Mascot
Zealot
Despot
Millionaire
Swimmer
Mouse
Southern_Belle
Prophet
Trumpeter
Designer
Business_Leader
Paranormal_Investigator
Driver
Nurse
Runner
Fund_Manager
Investment_Manager
Broker
Charlatan
Embezzler
Swindler
Nanny
Child_Minder
Nun
Survivalist
Chancellor
Cult_Leader
Monster
Aviatrix
Poetess
Speculator
Political_Activist
Seamstress
Maniac
Bore
Discoverer
Whistleblower
Mogul
Lackey
Toady
Executive_Assistant
Police_Chief
Ambulance_Chaser
Religious_Person
Spinster
Principal
Disciplinarian
Juvenile_Delinquent
Groundskeeper
Janitor
Software_Developer
Statistician
Hedonist
Voyeur
Pervert
Mentalist
Slacker
Hippie
Bowler
Deadbeat
Replicant
Fighter
Blade_Runner
Bank_Robber
Crank
Frost_Giant
Forecaster
Code_Breaker
Barbarian
Mercenary
She-Devil
Proprietor
Outcast
Nihilist
Dog
Bigot
Devil
Hyperchondriac
Debtor
Bankrupt
Fence
Pickpocket
Administrator
Moneylender
Mistress
Intern
Radical
Suitor
Bachelor
Drifter
Everyman
Petty_Criminal
Mutineer
2 |
--------------------------------------------------------------------------------
/NOC/DATA/TSV Lists/past perfects.txt:
--------------------------------------------------------------------------------
1 | Action Past Perfect
shooting shot
pistol-whipping pistol-whipped
attacking attacked
overwhelming overwhelmed
stabbing stabbed
puncturing punctured
blasting blasted
peppering peppered
knocking knocked
irritating irritated
dominating dominated
scarring scarred
burning burnt
withering withered
tongue-lashing tongue-lashed
squirting squirted
walloping walloped
hitting hit
bombing bombed
blowing blown
slashing slashed
cutting cut
gutting gutted
ripping ripped
flattening flattened
crushing crushed
impaling impaled
deafening deafened
poisoning poisoned
dumbing dumbed
stinging stung
blistering blistered
misdirecting misdirected
confusing confused
distracting distracted
neutralizing neutralized
enchanting enchanted
hacking hacked
smiting smitten
choking choked
inducing induced
atom-smashing atom-smashed
shaming shamed
humiliating humiiated
entrancing entranced
manipulating manipulated
slicing sliced
horrifying horrified
frightening frightened
repelling repelled
sickening sickened
bombarding bombarded
pummelling pummeled
hammering hammered
battering battered
beating beaten
shredding shredded
pancaking pancaked
ass-kicking ass-kicked
blinding blinded
immobilizing immobilized
piercing pierced
petrifying petrified
penetrating penetrated
damning damned
running run
disorienting disoriented
whipping whipped
pricking pricked
dismembering dismembered
smashing smashed
slamming slammed
pepper-spraying pepper-sprayed
nauseating nauseated
exploding exploded
drowning drowned
targeting targeted
liquidating liquidated
suffocating suffocated
shocking shocked
degrading degraded
undermining undermined
brutalizing brutalized
herniating herniated
intimidating intimidated
driving driven
obliterating obliterated
reducing reduced
entangling entangled
electrocuting electrocuted
devastating devastated
head-butting head-butted
scatter-shooting scatter-shot
vaporizing vaporized
melting melted
electrifying electrified
scratching scratched
wrong-footing wrong-footed
snake-charming snake-charmed
clubbing clubbed
French-kissing French-kissed
perforating perforated
traducing traduced
slandering slandered
bullying bullied
hypnotizing hypnotized
controlling controlled
hardening hardened
s-s-s-shooting s-s-s-shot
frying fried
gouging gouged
disorientating disorientated
enthralling enthralled
ramming rammed
charming charmed
biting bitten
poking poked
kicking kicked
clawing clawed
weakening weakened
under-cutting under-cut
swatting swatted
torturing tortured
shivving shivved
shanking shanked
chopping chopped
destroying destroyed
bitch-slapping bitch-slapped
bear-hugging bear-hugged
savaging savaged
mauling mauled
groin-kicking groin-kicked
snapping snapped
betraying betrayed
whacking whacked
coshing coshed
spraying sprayed
zapping zapped
infiltrating infiltrated
out-thinking out-thought
assassinating assassinated
crowding crowded
freezing frozen
nipping nipped
terminating terminated
infecting infected
terrifying terrified
shafting shafted
restraining restrained
slapping slapped
tiring tired
numbing numbed
mowing mown
shattering shattered
shrinking shrunk
splatting splatted
crunching crunched
stapling stapled
stunning stunned
2 |
--------------------------------------------------------------------------------
/NOC/DATA/TSV Lists/verb list.txt:
--------------------------------------------------------------------------------
1 | are_trusted_by
are_disrespected_by
condescend_to
are_deceived_by
disappoint
fall_in_love_with
are_feared_by
are_impressed_by
are_pushed_too_far_by
steal_from
are_bored_by
are_worshipped_by
fail_to_deliver_for
are_exploited_by
kill
are_ignored_by
spread_lies_about
beg_forgiveness_from
underestimate
cede_power_to
are_underpaid_by
are_disgusted_by
are_betrayed_by
are_lectured_by
seek_forgiveness_from
are_humiliated_by
are_respected_by
are_cheated_by
are_sued_by
turn_against
manipulate
are_bought_off_by
are_upstaged_by
testify_against
are_unimpressed_by
are_moved_by
are_denounced_by
lead_astray
are_seduced_by
are_insulted_by
are_blackmailed_by
indoctrinate
are_beaten_by
are_corrupted_by
are_underappreciated_by
stand_up_to
lie_to
show_loyalty_to
impress
are_attacked_by
disagree_with
sleep_with
attack
are_rebuffed_by
identify_with
are_pursued_by
are_obeyed_by
are_inspired_by
are_threatened_by
inspire
are_manipulated_by
campaign_against
are_shocked_by
insult
spy_on
are_disillusioned_by
are_mocked_by
trust
are_rewarded_by
are_abandoned_by
lick_up_to
sue
are_flattered_by
blackmail
deceive
kiss_up_to
lay_a_trap_for
profit_from
are_dumped_by
are_resisted_by
humiliate
are_arrested_for_killing
are_despised_by
learn_from
marry
are_bitten_by
are_favored_by
settle_with
are_misrepresented_by
argue_with
criticize
dump
are_haunted_by
surrender_to
are_spurned_by
run_away_from
are_arrested_for_hurting
alienate
threaten
fail_to_impress
are_fired_by
listen_to
disgust
take_advantage_of
bow_down_to
misrepresent
lose_faith_in
curry_favor_with
work_for
resent
are_underestimated_by
look_up_to
are_dismissed_by
pay_off
worship
are_tricked_by
escape_from
are_stalked_by
are_taunted_by
betray
are_promoted_by
are_killed_by
rise_against
pander_to
silence
promote
are_pitied_by
undermine
hate
abuse
pine_for
eject
sympathize_with
are_concerned_about
cheat
are_brainwashed_by
exploit
are_entertained_by
flirt_with
disrespect
are_indoctrinated_by
praise
are_distrusted_by
are_toppled_by
stalk
are_refused_payment_by
refuse_to_pay
are_abused_by
break_with
are_attracted_by
release
are_disappointed_by
fear
obey
are_defeated_by
bribe
hide_from
are_cursed_by
subjugate
fight_against
lose_control_over
are_embarrassed_by
believe_in
suck_up_to
chastise
are_chastised_by
are_forgotten_by
obtain_sympathy_from
punish
break_free_of
disfigure
are_disfigured_by
take_up_with
confide_in
are_driven_mad_by
flatter
let_in
interview
are_hardened_by
are_incarcerated_by
upstage
appeal_to
support
serve
repay
are_copied_by
negotiate_with
are_banished_by
are_intrigued_by
are_heckled_by
fire
are_recalled_by
seek_advice_from
overwork
hire
are_ruled_by
buy_off
observe
labor_for
are_deflowered_by
are_forgiven_by
are_eluded_by
denounce
appoint
imitate
track_down
are_interviewed_by
welcome
are_molded_by
mock
work_with
are_enslaved_by
heckle
confer_with
grow_suspicious_of
sacrifice_to
take_aim_at
elude
are_unimpressed_with
kill_for
cheat_on
are_divorced_by
divorce
summon
die_for
coach
enslave
feel_sorry_for
starve
abandon
are_supplanted_by
testify_for
are_challenged_by
are_uncovered_by
disobey
pray_to
favor
conspire_with
tune_out
are_found_by
sacrifice
are_criticized_by
are_imitated_by
pursue
overthrow
are_abducted_by
are_snatched_by
save
are_scolded_by
date
are_silenced_by
are_mistaken_for
commit_to
condemn
entertain
are_appointed_by
rule_over
are_censured_by
destroy
dismiss
enchant
interrogate
lie_for
admire
travel_with
trick
are_coached_by
are_deposed_by
are_handled_by
enlist
are_investigated_by
are_shielded_by
are_ejected_by
talk_to
are_evaluated_by
are_hired_by
fail_to_reward
are_recruited_by
are_cut_off_by
taunt
are_imprisoned_by
are_escorted_by
are_welcomed_by
are_released_by
complain_to
compete_with
rescue
follow
campaign_for
advise
are_mistreated_by
vote_for
catch
search_for
mimic
compete_against
are_begged_by
control
diagnose
torture
are_sought_by
rule
sign_up
respect
are_disobeyed_by
let_go_of
lose_favor_with
are_saved_by
watch_over
capture
are_chosen_by
are_excommunicated_by
are_expelled_by
look_after
share_stories_with
love
are_punished_by
read_the_works_of
are_booed_by
are_protected_by
are_kissed_by
are_freed_by
are_detained_by
resist
withhold_payment_from
are_photographed_by
drink_with
play_with
struggle_against
pray_with
are_intimidated_by
dominate
ignore
are_captured_by
break_up_with
evict
oppress
imprison
lose_to
are_advised_by
attract
rebel_against
visit
tend
counsel
defeat
study
prey_on
are_funded_by
seduce
play_for
cry_for
report_to
are_charmed_by
guard
brief_against
reward
teach
sing_with
are_kidnapped_by
are_hindered_by
are_paid_by
are_taught_by
are_defrocked_by
are_followed_by
entice
are_enticed_by
are_loved_by
are_helped_by
are_painted_by
are_savaged_by
are_supervised_by
are_overthrown_by
are_caught_by
are_healed_by
are_tortured_by
delegate_to
are_supported_by
are_persecuted_by
appease
struggle_with
are_dispatched_by
are_mentored_by
mentor
are_suppressed_by
copy
excommunicate
are_reported_by
cast_off
are_interrogated_by
sweat_for
are_contradicted_by
disillusion
are_wooed_by
are_enchanted_by
care_for
supply
coerce
recruit
compliment
command
harden_toward
are_thanked_by
are_disqualified_by
speak_to
consult
assist
haunt
are_debated_by
debate
suppress
defraud
are_informed_by
deploy
evaluate
lead
are_conquered_by
are_assisted_by
dispatch
are_subdued_by
receive
encourage
are_represented_by
seek
are_persuaded_by
wait_on
kidnap
rank
persecute
forgive
are_served_by
manage
pamper
torment
supplant
offend
are_tracked_by
send
lose_interest_in
charm
take_as_prisoner
sign_with
resemble
are_tormented_by
are_oppressed_by
are_ruined_by
are_read_by
are_financed_by
intimidate
are_offended_by
are_counseled_by
debate_with
arrest
perform_with
avoid
attend
are_rebuked_by
execute
are_tutored_by
defend
protect
are_failed_by
cheat_with
propose_to
satirize
are_treated_by
are_accompanied_by
agree_with
educate
snatch
speak_through
are_baptized_by
are_marketed_by
are_undermined_by
are_repaid_by
fight_for
chat_with
help
lecture_to
are_blessed_by
are_complimented_by
reach_out_to
supervise
sell_to
are_tipped_by
tip
whip
laugh_at
woo
are_supplied_by
are_drilled_by
are_trained_by
instruct
review
operate_on
cure
curse
are_converted_by
fight
are_defrauded_by
are_accommodated_by
are_fielded_by
are_evicted_by
are_exorcized_by
devour
govern_for
treat
terrorize
are_visited_by
disqualify
nominate
rebuff
invest_in
murder
train
cater_to
host
are_encouraged_by
are_diagnosed_by
are_overworked_by
are_questioned_by
represent
are_nominated_by
detain
massage
reject
are_studied_by
cast_out
fight_with
find
are_spoiled_by
pity
free
dislike
incarcerate
deliver_for
hunt
apprehend
pick_on
are_led_by
experiment_on
look_for
preach_to
translate_for
give_birth_to
are_radicalized_by
are_commanded_by
tower_over
are_published_by
write_about
cross_examine
overcome
propagandize_for
select
sell_through
snitch_to
tip_off
prosecute
are_remembered_by
recall
are_energized_by
run_against
accompany
govern
hurt
are_rejected_by
are_resented_by
monitor
embarrass
buy_from
impersonate
consult_with
snitch_on
vote_against
are_used_by
brainwash
are_hunted_by
are_admired_by
debrief
examine
answer_questions_from
are_monitored_by
build_for
are_mystified_by
are_educated_by
are_accused_by
are_championed_by
are_driven_around_by
design_for
confess_to
are_assaulted_by
inherit_from
nurture
are_answered_by
beautify
enhance
style_for
are_attended_by
are_venerated_by
are_selected_by
leak_to
are_introduced_by
are_named_by
perform_for
live_with
provide_for
renounce
consort_with
drive_for
are_bored_with
finance
are_waited_upon_by
pick
are_rewarded_with
supply_to
ordain
are_ordained_by
transport
are_appreciated_by
are_sickened_by
are_victimized_by
navigate_for
become_dependent_upon
are_driven_by
are_prosecuted_by
are_tended_by
are_raised_by
accommodate
are_frustrated_by
lease_to
rent_to
baptise
govern_via
are_motivated_by
model_for
are_whipped_by
negotiate_for
despise
are_guaranteed_by
train_with
are_signed_by
are_chronicled_by
are_defended_by
are_graded_by
bully
are_overrun_by
paint
are_popularized_by
are_scripted_by
are_picked_by
decapitate
are_rescued_by
baptize
are_discovered_by
play_against
are_insured_by
are_deployed_by
act_via
communicate_through
communicate_via
are_usurped_by
talk_through
countersue
are_enlisted_by
leave_behind
accuse
communicate_with
dress
are_judged_by
seek_sympathy_from
are_retained_by
are_traumatized_by
photograph
pitch_at
sire
are_ennobled_by
are_hurt_by
argue_before
are_controlled_by
remember
are_instructed_by
unleash
charge
discipline
heal
minister_to
persuade
raise
question
are_facilitated_by
round_up
abet
deal_with
worship_with
intimidate_with
mate_with
pick_up
are_robbed_by
target
chase
chase_after
are_cared_for_by
flee_from
are_nurtured_by
commission
are_roused_by
rouse
conquer
create_for
write_for
compose_with
are_examined_by
are_fought_by
take_messages_for
testify_before
are_charged_by
are_chased_by
indulge
are_guarded_by
spoil
advocate_for
are_owed_by
are_missed_by
are_profiled_by
write_to
convert
speak_with
evaluate_with
guide
mystify
act_for
ask_questions_for
interpret_for
speak_for
are_counselled_by
are_guided_by
are_summoned_by
hit
are_probed_by
anger
sell_via
are_influenced_by
are_subjugated_by
are_reviewed_by
abduct
are_impersonated_by
rent_from
borrow_from
are_elected_by
owe
owe_to
rob
respond_to
influence
are_received_by
cause_trouble_for
corrupt
are_overwhelmed_by
molest
handle
assassinate
blow_up
assault
beat_up
mourn_for
joke_about
pray_for
identify
interact_with
are_targeted_by
distrust
descend_from
learn_with
are_wanted_by
rely_on
are_bullied_by
breastfeed
attend_to
facilitate
cook_for
cook_for
farm_for
fool
answer
lease_from
pay
are_transported_by
export_to
fund
guarantee
order_from
are_dominated_by
are_lured_by
inform
exorcise
popularize
deliver_to
topple
censure
threaten_with
lend_to
answer_to
carry_for
champion
elect
please
work_under
challenge
collude_with
harass
shill_for
are_overshadowed_by
overshadow
repress
subdue
pose_for
are_managed_by
are_greeted_by
study_under
are_overlooked_by
read_about
2 |
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Past Perfects.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Past Perfects.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veale's Fictional Worlds.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veale's Fictional Worlds.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veale's The NOC List.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veale's The NOC List.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veale's Typical Activities.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veale's Typical Activities.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veale's affordances.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veale's affordances.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veale's category hierarchy.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veale's category hierarchy.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veale's clothing line.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veale's clothing line.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veale's creations.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veale's creations.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veale's domains.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veale's domains.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veale's location listing.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veale's location listing.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veale's vehicle fleet.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veale's vehicle fleet.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veale's weapon arsenal.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veale's weapon arsenal.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/Veales place elements.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/Veales place elements.xlsx
--------------------------------------------------------------------------------
/NOC/DATA/Veale's NOC List/superlatives.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/DATA/Veale's NOC List/superlatives.xlsx
--------------------------------------------------------------------------------
/NOC/README/Postcards from the Edge.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prosecconetwork/The-NOC-List/4d6b9b169399b1d6cc3bb86c8ddd9333b1093c84/NOC/README/Postcards from the Edge.pdf
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # The-NOC-List
2 |
3 | Created by Tony Veale for use by the CC community. No warranty is offered or implied. When publishing work based in whole or in part on these resources, please cite the following paper as a reference for the NOC approach and knowledge resource:
4 |
5 | Veale, T. (2016). Round Up The Usual Suspects: Knowledge-Based Metaphor Generation. In Proceedings of the Meta4NLP Workshop on Metaphor at NAACL-2016, the annual meeting of the North American Association for Computational Linguistics. San Diego, California.
6 |
7 | The NOC List
8 |
9 | The Non-Official Characterization (NOC) List is a knowledge-base containing semantic triples about famous people, living and dead, fictional and real, for use in story generation, joke generation, metaphor generation and other computational creativity generation systems.
10 |
11 | The NOC List is a large knowledge-base (approx. 30k triples) of pop-culture knowledge about famous individuals, whether living or dead and fictional or real. It was designed to act as a rich source of knowledge for automated metaphor generation and story-telling in Computational Creativity systems such as Twitterbots. This README describes the current state of the knowledge-base (which I call the NOC List, for Non-Official Characterizations List, in a nod to the McGuffin in the first Mission Impossible movie).
12 |
13 | Also included are some easy-to-use Java classes for accessing and working with this knowledge in Java. With this data and these tools, even novice (Java) programmers will be able to do interesting idea generation in the pop-culture realm.
14 |
15 | The CODE directory contains Java code for accessing the knowledge-base(s) and for using the knowledge-bases to generate tweets for @MetaphorMagnet. More of this below.
16 |
17 | The DATA directory has two sub-directories that contain files which encode the knowledge in two-different formats. The TSV Lists directory stores each knowledge-base as a text file (.txt) that is tab delimited. The first line contains the field names for the file, also tab delimited. The directory called "Veale’s The NOC List" contains the corresponding data files in an easier-to-edit/browse spreadsheet (.xlsx) format. Notice that in lieu of a copyright message or author-attribution message each file contains the name of its creator and knowledge-engineer. Please keep this informal attribution in the file names if you share the data with others.
18 |
19 | The slides in the README directory offer the best overall introduction to the knowledge-bases. A more detailed perspective is offered by the code itself. So let’s look more closely at that.
20 |
21 | The class KnowledgeBaseModule.java is designed so that a single instance contains all the information in a single spreadsheet/TSV file. So a different instance is created for each of the data files in the knowledge-base. This is an extract from the class PersonOfInterest.java, which uses the data to generate interesting things:
22 |
23 | NOC = new KnowledgeBaseModule(kDir + “Veale’s The NOC List.txt”, 0);
24 |
25 | CATS = new KnowledgeBaseModule(kDir + “Veale’s Category Hierarchy.txt”, 0);
26 |
27 | CLOTHES = new KnowledgeBaseModule(kDir + “Veale’s clothing line.txt”, 1);
28 |
29 | CREATIONS = new KnowledgeBaseModule(kDir + “Veale’s creations.txt”, 0);
30 |
31 | DOMAINS = new KnowledgeBaseModule(kDir + “Veale’s domains.txt”, 0);
32 |
33 | WORLDS = new KnowledgeBaseModule(kDir + “Veale’s fictional worlds.txt”, 0);
34 |
35 | VEHICLES = new KnowledgeBaseModule(kDir + “Veale’s vehicle fleet.txt”, 1);
36 |
37 | WEAPONS = new KnowledgeBaseModule(kDir + “Veale’s weapon arsenal.txt”, 1);
38 |
39 | PLACES = new KnowledgeBaseModule(kDir + “Veale’s place elements.txt”, 0);
40 |
41 | SUPERLATIVES = new KnowledgeBaseModule(kDir + “superlatives.txt”, 0);
42 |
43 | COMPARATIVES = new KnowledgeBaseModule(kDir + “comparatives.txt”, 0);
44 |
45 | ANTONYMS = new KnowledgeBaseModule(kDir + “antonyms.txt”, 0);
46 |
47 | PAST_PERFECTS = new KnowledgeBaseModule(kDir + “past perfects.txt”, 0);
48 |
49 | Choose kDir to point to the TSV Lists subdirectory of the DATA directory and the above modules should load cleanly.
50 |
51 | The last two data modules are a useful source of glue data for putting everything together in an NLP output.ANTONYMS maps properties (such as strong) onto their opposites (such as weak), while PAST_PERFECTS maps the present continuous form of action verbs (such as shooting) onto their past perfect forms (e,g. shot).
52 |
53 | Have a look inside PersonOfInterest.java to see how these knowledge modules are used to generate a variety of different tweets, often anchored in an opposition of properties (provided by ANTONYMS).
54 |
55 | For instance, the method generateDreamConflicts(…) generates tweets about dreams in which pop-culture figures appear. Here is an example of a two-parter:
56 |
57 | Last night I dreamt I was cleaning floors with #GroundskeeperWillieMacDougal when we were run over with ruthless ambition by #HillaryClinton
58 |
59 | I guess #HillaryClinton and #GroundskeeperWillieMacDougal represent warring parts of my personality: the capable vs. incompetent sides.
60 |
61 |
62 | [The ANTONYMS module provides the crux of the dream here, the contrast between capable and incompetent]
63 |
64 | The method generateNietzscheanTweets(…) generates what-if tweets that riff on Nietzsche’s famous line “What doesn’t kill you makes you stronger“, as in:
65 |
66 |
67 | If what doesn’t kill you makes you stronger, shouldn’t being overwhelmed with ruthless ambition by #HillaryClinton make you more driven?
68 |
69 | If what doesn’t kill you makes you stronger, shouldn’t being knocked out with an Oscar statuette by #DanielDayLewis make you more talented?
70 |
71 |
72 | The method makeOthersLookGood(…) generates a relativistic comparison, where the speaker believes he/she resembles X but others say they resemble Y, where X and Y differ in some antonymous respect. Here’s an example:
73 |
74 |
75 | I see myself as capable, but my boss says that I make even someone as incompetent as #EdWood look like #HillaryClinton.
76 |
77 |
78 | The method generateShakespeareanTweets(…) generates what-if tweets that riff on the Shakespearean idea that “Clothes maketh the man”. Here is an example:
79 |
80 |
81 | If clothes maketh the woman, would wearing #HillaryClinton’s pant suit make you more ambitious? Or more grasping?
82 |
83 |
84 | The method walkMileInShoes(…) generates what-if tweets that riff on the old phrase “you shouldn’t judge someone until you’ve walked a mile in their shoes”. Here’s an example or three:
85 |
86 |
87 | Nobody’s perfect! My grandma says to never judge a grasping first lady like #HillaryClinton until you have walked a mile in her pant suit.
88 |
89 | Nobody’s perfect! My grandpa says to never judge a shallow diarist like #CarrieBradshaw until you have walked a mile in her Manolo Blahniks.
90 |
91 | Nobody’s perfect! My mom says to never judge a neurotic actor like #JackNicholson until you have driven a mile in his Jokermobile.
92 |
93 |
94 | The class PersonOfInterest also contains methods to generate different kinds of XYZ metaphor (i.e. of the form X is the Y of Z). Here are some examples:
95 |
96 |
97 | What if #TheEmpireStrikesBack were real? #HillaryClinton could be its #PrincessLeiaOrgana: driven yet bossy, and controversial too
98 |
99 | What if #TheNewTestament were about #AmericanPolitics? #MonicaLewinsky could be its #Lucifer: seductive yet power-hungry, and ruined too.
100 |
101 | If #MonicaLewinsky is #Lucifer in a stained blue dress, who in #TheNewTestament is #HillaryClinton most like?
102 |
103 | When it comes to #TheDemocrats, is #HillaryClinton just #UriahHeap in a pant suit? She is ambitious yet grasping, and controversial too
104 |
105 |
106 | All of the knowledge in the NOC and its various modules is stored as a collection of semantic triples.
107 | Now, one can use XML, RDF, RDFS or OWL to store a collection of semantic triples, but the core of the triple stays the same regardless of the formalism we use to encode it. So why bother with a complex syntactic sugar for the sake of formalistic appearances? When it comes to maintaining and editing and sharing a large body of semantic triples the most flexible format is a spreadsheet.
108 | As mundane as it may sound, a spreadsheet is perfect for this kind of representation work.
109 |
110 | Every cell, representing as it does a value-containing intersection of a named column and a named row, represents a single triple. We can share spreadsheets easily (and post them on the Web as Google docs for communal editing) and cut-and-paste relevant parts with abandon.
111 | So every piece of information in Scéalextricis to be found in a spreadsheet. Each sheet can be saved as a tab-separated-values text file for easy processing by Java and Python programs, and we encourage you to add new columns and rows to each one, and to create new spreadsheets of your own with complementary forms of knowledge.
112 |
113 | Consider a semantic relationdhip P(X, Y) where P is a predicate that holds between X and Y. We can represent a collection of triples of the form P(X, Y) in a spreadsheet with a column labelled P, a row whose first (and key) value is X, and a cell at the intersection of this row and the column labelled P that contains the value Y. This cell may contain multiple values Y1, Y2 ... Yn, each separated by commas, so this cell would represent a group of predications P(X, Y1), P(X, Y2) ... P(X, Yn)
114 |
115 | The NOC distribution contains a variety of spreadsheets, each one a triple store that stores its semantic triples in this fashion. The following are the main spreadsheets in the distribution (the TSV Lists directory contains text file equivalents in which the spreadsheets have been saved in tab-separated-values [TSV] format):
116 |
117 | Veale's The NOC List.xlsx
118 |
119 | This spreadsheet encodes the central triple-store in which characters are defined. Other triple-stores/spreadsheets in the NOC distribution provide further detail on the concepts used in this central triple-store. The first and key column provides the names of the characters, one row per character. Other columns then contain attributes of each character and related ideas, such as Gender, Political leaning, Address, Spouse, Opponent, Weapon, Vehicle, Typical Activities, Typical Clothing, Group Affiliation, Domain, Fictive status (real or fictional?), Creator (if fictional), Taxonomic Category, Positive Talking Points and Negative Talking Points
120 |
121 | Veale's vehicle fleet.xlsx
122 |
123 | This triple-store provides useful detail on the vehicles associated with characters in the central NOC triple-store above.
124 |
125 | Veale's weapon arsenal.xlsx
126 |
127 | This triple-store provides useful detail on the weapons associated with characters in the central NOC triple-store above.
128 |
129 | Veale's Typical Activities.xlsx
130 |
131 | This triple-store provides useful detail on the activities associated with characters in the central NOC triple-store above.
132 |
133 | Veale's clothing line.xlsx
134 |
135 | This triple-store provides useful detail on the clothing items associated with characters in the central NOC triple-store above.
136 |
137 | Veale's creations.xlsx
138 |
139 | This triple-store provides useful detail on the creations associated with characters in the central NOC triple-store above. For instance, Seth McFarlane is the creator of Family Guy and this triple-store indicates that Family Guy is a TV show
140 |
141 | Veale's Fictional Worlds.xlsx
142 |
143 | Family Guy is also a fictional world in which a variety of characters live and interact. This triple-store characterizes the fictional worlds associated with the characters of the main NOC triple-store.
144 |
145 | Veale's domains.xlsx
146 |
147 | This triple-store provides useful detail on the genres and domains associated with characters in the central NOC triple-store above.
148 |
149 | Veale's category hierarchy.xlsx
150 |
151 | This triple-store provides useful detail on the taxonomic categories associated with characters in the central NOC triple-store above. In effect, it clusters these categories into broader categories to form a semantic hierarchy or IS-A hierarchy in the old-fashioned AI sense.
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------