-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
296 lines (264 loc) · 12.1 KB
/
Copy pathindex.html
File metadata and controls
296 lines (264 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Commons Text</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/white.css">
<link rel="shortcut icon" href="#" />
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match(/print-pdf/gi) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName('head')[0].appendChild(link);
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>Commons Text</h1>
<h4>A library focused on algorithms working on strings.</h4>
<br>
<small>Created by
<a href="https://github.com/chtompki">
Rob Tompkins (chtompki)</a></small><br/>
<small>Presentation Address: <a href="http://bit.ly/2rj9M29">
http://bit.ly/2rj9M29</a></small>
</p>
</section>
<section>
<h3>Who I am.</h3>
<ul>
<li class="fragment"><a href="mailto:chtompki@apache.org">chtompki@apache.org</a>
</li>
<li class="fragment">Apache Commons Committer</li>
<li class="fragment">Apache Commons Text Release Manager</li>
<li class="fragment">Software Developer (Java, DevOps)</li>
<li class="fragment">Mathematician/Logician (?, sure why not).</li>
</ul>
</section>
<section>
<h3>Introducing <code style="text-transform: none;">commons-text</code>.</h3>
<ul>
<li class="fragment">
<em>Goal</em>. Text processing algorithms out of standard java library scope and promote
reuse across all of Apache's projects.</li>
<li class="fragment">
<em>Secondary goal.</em>
<ul>
<li class="fragment">Remove heavier text processing mechanics from <code>commons-lang</code>.</li>
<li class="fragment">Ensure <code>lang</code> minimally remains all that every Java developer needs.</li>
</ul>
</li>
</ul>
</section>
<section>
<h3>History</h3>
<ul>
<li class="fragment">
Traction on appetite for a
<a href="https://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein Distance</a> began to form
in October 2014 in <a href="https://issues.apache.org/jira/browse/LANG-591">LANG-591</a>.
</li>
<li class="fragment">
<a href="http://kinoshita.eti.br/">Bruno Kinoshita</a> and <a href="http://www.benediktritter.de/">Benedikt Ritter</a>
put together a proposal to create <code>text</code> in the sandbox.
</li>
<li class="fragment">
Last November, I picked up <code>text</code> where they left off, and by March 11, 2017
we had our 1.0.
</li>
</ul>
</section>
<section>
<h3>Current Layout.</h3>
<ul>
<li class="fragment">Textier utilities than <code>lang</code>'s <code>StringUtils</code>:</li>
<ul class="fragment">
<li><code>StrBuilder</code>, <code>FormattableUtils</code>, <code>StrSubstitutor</code>, and
<code>StrTokenizer</code></li>
</ul>
<li class="fragment">Diff utilities</li>
<li class="fragment">String similarity and edit distance.</li>
<li class="fragment">String translation and escaping (e.g. XML, CSV, JSON, ect.)</li>
</ul>
</section>
<section>
<h2>From <code style="text-transform: none;">lang</code></h2>
</section>
<section>
<h3><code style="text-transform: none;">StrBuilder</code></h3>
<ul>
<li class="fragment">An alternative to <code>java.lang.StringBuilder</code></li>
<li class="fragment">Better instance methods</li>
<li class="fragment">Not thread safe, not final</li>
</ul>
<pre class="fragment"><code class="java">StrBuilder sb = new StrBuilder("Test");
sb.readFrom(CharBuffer.wrap(" 123")); // "Test 123"
sb = new StrBuilder("bb");
sb.replaceAll("b", "xbx"); // "xbxxbx"
sb = new StrBuilder("abc");
sb.replace(0, 1, "aaa"); // "aaabc"
</code></pre>
</section>
<section>
<h3><code style="text-transform: none;">FormattableUtils</code></h3>
<ul>
<li class="fragment">Provides basic control over formatting when using a
<code>java.util.Formatter</code></li>
<li class="fragment">Primarily concerned with numeric precision and padding</li>
<li class="fragment">No generalized alternative forms</li>
</ul>
<pre class="fragment"><code class="java">FormattableUtils.append("foo",
new Formatter(),
FormattableFlags.LEFT_JUSTIFY,
6, -1, '*').toString(); // "foo***"
FormattableUtils.append("foo",
new Formatter(),
FormattableFlags.LEFT_JUSTIFY,
6, -1).toString(); // "foo "</code></pre>
</section>
<section>
<h3><code style="text-transform: none;">StrSubstitutor</code></h3>
<ul>
<li class="fragment">Provides a convenient way to do string substitutions</li>
<li class="fragment">Think of it as a template engine in one class</li>
</ul>
<pre class="fragment"><code class="java">Map valuesMap = HashMap();
valuesMap.put("animal", "quick brown fox");
valuesMap.put("target", "lazy dog");
String templateString = "The ${animal} jumped " +
"over the ${target}.";
StrSubstitutor sub = new StrSubstitutor(valuesMap);
String resolvedString = sub.replace(templateString);
// "The quick brown fox jumped over the lazy dog."
</code></pre>
</section>
<section>
<h3><code style="text-transform: none;">StrTokenizer</code></h3>
<ul>
<li class="fragment">Tokenizes a string based based on delimiters (separators) and supporting quoting
and ignored character concepts
</li>
<li class="fragment">Aims to do a similar job to <code>java.util.StringTokenizer</code></li>
<li class="fragment">Offers much more control and flexibility including implementing the
<code>java.util.ListIterator</code> interface
</li>
</ul>
</section>
<section>
<h3><code style="text-transform: none;">StrTokenizer</code></h3>
<pre><code class="java">final String input = "a;b;c;\"d;e\";f; ; ; ";
final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
//Matches the String trim() whitespace characters.
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
final String tokens[] = tok.getTokenArray();
// String[]{"a", "b", "c", "d;e", "f", "", "", ""};</code></pre>
</section>
<section>
<h3><code style="text-transform: none;">StringEscapeUtils</code></h3>
<ul>
<li class="fragment">Provides a convenient way to do escaping</li>
</ul>
<pre class="fragment"><code class="java">StringEscapeUtils.escapeJson("He didn't say, \"stop!\"");
// "He didn\\'t say, \\\"stop!\\\""
StringEscapeUtils.escapeJava("\\\b\t\r");
// "\\\\\\b\\t\\r" </code></pre>
</section>
<section>
<h2>New functionality, unique to <code style="text-transform: none;">text</code></h2>
</section>
<section>
<h3><code style="text-transform: none;">LongestCommonSubsequence</code></h3>
<p>The Longest commons subsequence is a classical String similarity algorithm.</p>
<pre><code class="java">LongestCommonSubsequence siml =
new LongestCommonsSubsequence();
siml.apply("abba","abab"); // 3
siml.apply("frog", "fog"); // 3
siml.apply("PENNSYLVANIA", "PENNCISYLVNIA"); // 11
smil.apply("elephant", "hippo"); // 1</code></pre>
</section>
<section>
<h3><code style="text-transform: none; font-size:90%;">LongestCommonSubsequenceDistance</code></h3>
<pre><code class="java">LongestCommonSubsequenceDistance dist =
new LongestCommonSubsequenceDistance();
dist.apply("abba","abab"); // 2
dist.apply("frog", "fog"); // 1
dist.apply("PENNSYLVANIA", "PENNCISYLVNIA"); // 3
dist.apply("elephant", "hippo"); // 11</code></pre>
</section>
<section>
<h3><code style="text-transform: none;">LevenshteinDistance</code></h3>
<p>Different algorithm with almost the same results.</p>
<pre><code class="java">LevenshteinDistance dist = new LevenshteinDistance();
dist.apply("abba","abab"); // 2
dist.apply("frog", "fog"); // 1
dist.apply("PENNSYLVANIA", "PENNCISYLVNIA"); // 3
dist.apply("elephant", "hippo"); // 7</code></pre>
</section>
<section>
<h3>What else is there?</h3>
<ul>
<li class="fragment"><code>org.apache.commons.text.diff</code> contains the a variety of diff tools.</li>
<li class="fragment"><code>org.apache.commons.text.similarity</code> contains various other similarity/distance tools</li>
<ul class="fragment">
<li>Cosine similarity and distance, Hamming distance, Jaccard distance, and Jaro-winkler.</li>
</ul>
<li class="fragment"><code>org.apache.commons.text.translate</code> mainly supports <code>StringEscapeUtils</code>, but has more...</li>
</ul>
</section>
<section>
<h3>What's next?</h3>
<ul>
<li class="fragment">Release 1.1 in the next month or so? Assuming no 1.0.1......</li>
<li class="fragment"><code>WordUtils</code> from <code>lang</code>, with some updates.</li>
<li class="fragment"><code>RandomStringGenerator</code> thanks to the <code>rng</code> crew.</li>
<li class="fragment"><code>@Deprecated</code> on code taken from <code>lang</code></li>
</ul>
</section>
<section>
<h2>Questions?</h2>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
history: true,
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [
{src: 'plugin/markdown/marked.js'},
{src: 'plugin/markdown/markdown.js'},
{src: 'plugin/math/math.js', async: true},
{src: 'plugin/notes/notes.js', async: true},
{
src: 'plugin/highlight/highlight.js',
async: true,
callback: function () {
hljs.initHighlightingOnLoad();
}
}
],
math: {
mathjax: 'https://cdn.mathjax.org/mathjax/latest/MathJax.js',
config: 'TeX-AMS_HTML-full' // See http://docs.mathjax.org/en/latest/config-files.html
}
});
</script>
</body>
</html>