├── README.md ├── src ├── run_tests.rb ├── build_word2vec_index.rb ├── _logger.rb └── _stanford_sentiment_treebank.rb └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | treebank 2 | ======== 3 | 4 | - Stanford Sentiment Treebank machine learning & sentiment analysis library 5 | - Tomas Mikolov's word2vec support library 6 | 7 | -------------------------------------------------------------------------------- /src/run_tests.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | <<'EOF_LICENSE' 3 | Copyright 2013 Ben Gimpert (ben@somethingmodern.com) 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | EOF_LICENSE 17 | 18 | require 'test/unit' 19 | 20 | require 'rubygems' 21 | require 'graphviz' 22 | 23 | require '_logger' 24 | require '_stanford_sentiment_treebank' 25 | 26 | class StanfordSentimentTreebankTests = 0) ? 1 : 0) 57 | hash_s += proj_bit.to_s 58 | end 59 | hash = eval(hash_s) 60 | 61 | Logger.debug("Word ##{(i+1).to_comma_s} of #{num_words.to_comma_s} \"#{word}\" at #{word_pos} position in database w/ #{hash} hash.") if Logger.debug? 62 | idx[word] = { 63 | "pos" => word_pos, 64 | "lsh" => hash, 65 | } 66 | end 67 | idx 68 | end 69 | 70 | rng = GSL::Rng.alloc 71 | rng.gaussian 72 | 73 | num_hashes = 10 # about 1,400 vectors per bucket 74 | proj_vs = build_random_projections(rng, num_hashes, 1_000) 75 | 76 | path = File.expand_path(ARGV.first) 77 | File.open(path, "r") do |in_f| 78 | idx = build_binary_word2vec_index(in_f, proj_vs) 79 | File.open(path + ".idx", "w+") { |out_f| out_f.puts(idx.to_json) } 80 | end 81 | 82 | -------------------------------------------------------------------------------- /src/_logger.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | <<'EOF_LICENSE' 3 | Copyright 2013 Ben Gimpert (ben@somethingmodern.com) 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | EOF_LICENSE 17 | 18 | class Numeric 19 | 20 | def frac 21 | self.modulo(1) 22 | end 23 | 24 | def to_comma_s 25 | s = (self.frac.zero? ? self.to_s : self.to_float_s) 26 | s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse 27 | end 28 | 29 | end 30 | 31 | class Time 32 | 33 | def to_timestamp 34 | ms_s = sprintf("%03d", (self.to_f.frac * 1_000).to_i) 35 | self.strftime("%Y-%m-%d %H:%M:%S.#{ms_s} %z") 36 | end 37 | 38 | end 39 | 40 | class Logger 41 | 42 | IS_PROFILING_MEMORY = false 43 | 44 | def self.csv?; true 45 | end 46 | def self.db?; true 47 | end 48 | def self.verbose?; false 49 | end 50 | def self.debug?; true 51 | end 52 | def self.info?; true 53 | end 54 | def self.warn?; true 55 | end 56 | def self.error?; true 57 | end 58 | 59 | def self.to_console(level, msg) 60 | if msg.is_a?(Exception) 61 | to_console(level, "Exception: #{msg.message}") 62 | msg.backtrace.each { |backtrace_line| to_console(level, " #{backtrace_line}") } unless msg.backtrace.nil? 63 | return 64 | end 65 | 66 | prefixed_msg = "[#{Time.now.to_timestamp}] -- PID(#$$) -- #{level}" 67 | if IS_PROFILING_MEMORY 68 | mem_usage = `ps -o rss= -p #{$$}`.to_f / 1_024 69 | prefixed_msg += " -- #{mem_usage.to_float_s(2)}mb" 70 | end 71 | prefixed_msg += " -- #{msg}" 72 | $stderr.puts prefixed_msg 73 | end 74 | 75 | def self.csv(*cols) 76 | $stdout.puts CSV.generate_line(["____CSV____"] + cols) 77 | end 78 | 79 | def self.db(msg) 80 | to_console(" DB", msg) 81 | end 82 | 83 | def self.verbose(msg) 84 | to_console(" VERB", msg) 85 | end 86 | 87 | def self.debug(msg) 88 | to_console("DEBUG", msg) 89 | end 90 | 91 | def self.info(msg) 92 | to_console(" INFO", msg) 93 | end 94 | 95 | def self.warn(msg) 96 | to_console(" WARN", msg) 97 | end 98 | 99 | def self.error(msg) 100 | to_console("ERROR", msg) 101 | end 102 | 103 | end 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/_stanford_sentiment_treebank.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | <<'EOF_LICENSE' 3 | Copyright 2013 Ben Gimpert (ben@somethingmodern.com) 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | EOF_LICENSE 17 | 18 | module StanfordSentimentTreebank 19 | 20 | class StanfordSentimentTreebank 21 | 22 | DATA_DIR = File.expand_path("~/stanfordSentimentTreebank") 23 | IS_GRAPHING = true 24 | IS_GRAPHING_NODES_NUMBERED = true 25 | 26 | def initialize(init_max_num = nil) 27 | @max_num = init_max_num 28 | @sent_map = read_sentiment_map 29 | end 30 | 31 | def build_phrase_node_nums(node_map, phrase_toks, parent_node_num) 32 | return [parent_node_num] if node_map[parent_node_num].nil? || node_map[parent_node_num].empty? 33 | Logger.verbose("Building the leaf node numbers in #{parent_node_num} node phrase.") if Logger.verbose? 34 | phrase_node_nums = [] 35 | node_map[parent_node_num].sort.each do |child_node_num| 36 | if child_node_num <= phrase_toks.length 37 | phrase_node_nums << child_node_num 38 | else 39 | phrase_node_nums += build_phrase_node_nums(node_map, phrase_toks, child_node_num) 40 | end 41 | end 42 | phrase_node_nums 43 | end 44 | 45 | def build_phrase(node_map, phrase_toks, parent_node_num) 46 | phrase_node_nums = build_phrase_node_nums(node_map, phrase_toks, parent_node_num) 47 | raise "Duplicate token nodes in \"#{phrase_toks}\" phrase" unless phrase_node_nums.length == phrase_node_nums.uniq.length 48 | phrase_node_nums.sort.uniq.map { |node_num| phrase_toks[node_num-1] }.join(" ") 49 | end 50 | 51 | def confirm_graph_node(gv, gv_node_map, node_map, phrase_toks, node_num) 52 | return gv_node_map[node_num] if gv_node_map[node_num] 53 | 54 | phrase = build_phrase(node_map, phrase_toks, node_num) 55 | raise "Could not find sentiment for \"#{phrase}\" phrase" unless @sent_map.has_key?(phrase) 56 | sent = @sent_map[phrase] 57 | sent_shade = (sent * 255).to_i 58 | sent_color = sprintf("#%02x%02x%02x", sent_shade, sent_shade, sent_shade) 59 | Logger.debug("Using \"#{sent_color}\" sentiment color for \"#{phrase}\" phrase.") if Logger.debug? 60 | 61 | gv_node = gv.add_node("id#{node_num}") 62 | gv_node_label = if node_num.zero? 63 | "(root)" 64 | elsif (1..phrase_toks.length).member?(node_num) 65 | phrase_toks[node_num-1] 66 | else 67 | "" 68 | end 69 | gv_node_label += " ##{node_num}" if IS_GRAPHING_NODES_NUMBERED 70 | gv_node[:label] = gv_node_label 71 | gv_node[:style] = "filled" 72 | gv_node[:fillcolor] = sent_color 73 | gv_node_map[node_num] = gv_node 74 | 75 | if node_map[node_num] && (! node_map[node_num].empty?) 76 | Logger.verbose("Adding #{node_map[node_num].length.to_comma_s} children under #{node_num} new node.") if Logger.verbose? 77 | gv_node[:group] = "parent" 78 | node_map[node_num].sort.each do |child_node_num| 79 | child_gv_node = confirm_graph_node(gv, gv_node_map, node_map, phrase_toks, child_node_num) 80 | gv.add_edge(gv_node, child_gv_node) 81 | end 82 | elsif (2..phrase_toks.length).member?(node_num) 83 | Logger.debug("Added token leaf #{node_num} new node.") if Logger.debug? 84 | gv_node[:group] = "leaf" 85 | prev_tok_gv_node = confirm_graph_node(gv, gv_node_map, node_map, phrase_toks, node_num-1) 86 | invis_edge = gv.add_edge(prev_tok_gv_node, gv_node) 87 | invis_edge[:style] = "invis" 88 | end 89 | gv_node 90 | end 91 | 92 | def write_graph(node_map, phrase_toks, desc, svg_path) 93 | gv = GraphViz.new(:G, :type => :graph) 94 | gv[:rankdir] = "LR" 95 | gv[:label] = desc 96 | 97 | Logger.debug("Saving #{node_map.inspect} as a graph.") if Logger.debug? 98 | gv_node_map = {} 99 | node_map.keys.sort.each { |node_num| confirm_graph_node(gv, gv_node_map, node_map, phrase_toks, node_num) } 100 | gv.output(:svg => svg_path) 101 | end 102 | 103 | def read_sentiment_map 104 | dict_map = {} 105 | File.open("#{DATA_DIR}/dictionary.txt", "r") do |dict_io| 106 | until dict_io.eof? 107 | dict_line = dict_io.gets.strip 108 | dict_phrase, dict_id = dict_line.split("|") 109 | dict_id = dict_id.to_i 110 | dict_map[dict_id] = dict_phrase 111 | end 112 | end 113 | Logger.debug("Read #{dict_map.length.to_comma_s} entries from the dictionary file.") if Logger.debug? 114 | 115 | sent_map = {} 116 | File.open("#{DATA_DIR}/sentiment_labels.txt", "r") do |sent_io| 117 | until sent_io.eof? 118 | sent_line = sent_io.gets.strip 119 | next if sent_line == "phrase ids|sentiment values" 120 | dict_id, sent = sent_line.split("|") 121 | dict_id = dict_id.to_i 122 | sent = sent.to_f 123 | 124 | raise "No phrase for #{dict_id} dictionary ID" unless dict_map.has_key?(dict_id) 125 | dict_phrase = dict_map[dict_id] 126 | sent_map[dict_phrase] = sent 127 | end 128 | end 129 | Logger.debug("Read #{sent_map.length.to_comma_s} sentiment values from the sentiment file.") if Logger.debug? 130 | sent_map 131 | end 132 | 133 | def each_node_map 134 | result = nil 135 | Logger.debug("Reading the parse trees.") if Logger.debug? 136 | File.open("#{DATA_DIR}/SOStr.txt", "r") do |tok_io| 137 | File.open("#{DATA_DIR}/STree.txt", "r") do |tree_io| 138 | doc_i, phrase_i = 0, 0 139 | until tok_io.eof? 140 | tok_line = tok_io.gets.strip 141 | raise "End of tree file reached early" if tree_io.eof? 142 | tree_line = tree_io.gets.strip 143 | 144 | phrase_toks = tok_line.split("|") 145 | tree_els = tree_line.split("|") 146 | Logger.debug("For ##{(doc_i+1).to_comma_s} document, found #{phrase_toks.length.to_comma_s} tokens & #{tree_els.length.to_comma_s} nodes.") if Logger.debug? 147 | 148 | node_map = {} 149 | tree_els.each_index do |node_i| 150 | child_node_num = node_i+1 151 | node_map[child_node_num] = [] unless node_map.has_key?(child_node_num) 152 | parent_node_num = tree_els[node_i].to_i 153 | node_map[parent_node_num] = [] unless node_map.has_key?(parent_node_num) 154 | node_map[parent_node_num] << child_node_num 155 | Logger.verbose("Child node ##{child_node_num} now has #{parent_node_num} parent & #{node_map[parent_node_num].inspect} siblings.") if Logger.verbose? 156 | end 157 | 158 | if IS_GRAPHING 159 | svg_path_i_s = sprintf("%08i", doc_i+1) 160 | desc = "Stanford Treebank Phrase ##{(doc_i+1).to_comma_s},\n\"#{tok_line}\"" 161 | write_graph(node_map, phrase_toks, desc, Dir.tmpdir + File::SEPARATOR + "/stanford_treebank_phrase#{svg_path_i_s}.svg") 162 | end 163 | 164 | result = yield(node_map, phrase_toks) 165 | doc_i += 1 166 | break if (! @max_num.nil?) && (doc_i >= @max_num) 167 | end 168 | end 169 | end 170 | result 171 | end 172 | 173 | def each_phrase_map 174 | phrase_i = 0 175 | each_node_map do |node_map, phrase_toks| 176 | phrase_map = {} 177 | node_map.keys.sort.each do |parent_node_num| 178 | phrase = build_phrase(node_map, phrase_toks, parent_node_num) 179 | raise "Could not find sentiment for \"#{phrase}\" phrase" unless @sent_map.has_key?(phrase) 180 | sent = @sent_map[phrase] 181 | Logger.verbose("Phrase #{(phrase_i+1).to_comma_s} \"#{phrase}\" has #{sent} sentiment.") if Logger.verbose? 182 | phrase_map[phrase] = sent 183 | phrase_i += 1 184 | end 185 | yield(phrase_map) 186 | end 187 | end 188 | 189 | def each_node_map_split(node_map, phrase_toks, from_node_num = 0, &block) 190 | return nil if node_map[from_node_num].nil? || node_map[from_node_num].empty? 191 | child_node_nums = node_map[from_node_num] 192 | child_node_nums.each { |child_node_num| each_node_map_split(node_map, phrase_toks, child_node_num, &block) } 193 | block.call(from_node_num, child_node_nums) 194 | end 195 | 196 | def each_node_map_leaf_trigram(node_map, phrase_toks, from_node_num = 0) 197 | each_node_map_split(node_map, phrase_toks, from_node_num) do |node_num, child_node_nums| 198 | next unless child_node_nums.length == 2 199 | child1_node_num, child2_node_num = child_node_nums 200 | child1_children = node_map[child1_node_num] 201 | child2_children = node_map[child2_node_num] 202 | next unless (child1_children.nil? || child1_children.empty?) && (child2_children.nil? || child2_children.empty?) 203 | yield(node_num, child1_node_num, child2_node_num) 204 | end 205 | end 206 | 207 | end 208 | 209 | end 210 | 211 | -------------------------------------------------------------------------------- /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, and 10 | distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 13 | owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all other entities 16 | that control, are controlled by, or are under common control with that entity. 17 | For the purposes of this definition, "control" means (i) the power, direct or 18 | indirect, to cause the direction or management of such entity, whether by 19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the 20 | outstanding shares, or (iii) beneficial ownership of such entity. 21 | 22 | "You" (or "Your") shall mean an individual or Legal Entity exercising 23 | permissions granted by this License. 24 | 25 | "Source" form shall mean the preferred form for making modifications, including 26 | but not limited to software source code, documentation source, and configuration 27 | files. 28 | 29 | "Object" form shall mean any form resulting from mechanical transformation or 30 | translation of a Source form, including but not limited to compiled object code, 31 | generated documentation, and conversions to other media types. 32 | 33 | "Work" shall mean the work of authorship, whether in Source or Object form, made 34 | available under the License, as indicated by a copyright notice that is included 35 | in or attached to the work (an example is provided in the Appendix below). 36 | 37 | "Derivative Works" shall mean any work, whether in Source or Object form, that 38 | is based on (or derived from) the Work and for which the editorial revisions, 39 | annotations, elaborations, or other modifications represent, as a whole, an 40 | original work of authorship. For the purposes of this License, Derivative Works 41 | shall not include works that remain separable from, or merely link (or bind by 42 | name) to the interfaces of, the Work and Derivative Works thereof. 43 | 44 | "Contribution" shall mean any work of authorship, including the original version 45 | of the Work and any modifications or additions to that Work or Derivative Works 46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work 47 | by the copyright owner or by an individual or Legal Entity authorized to submit 48 | on behalf of the copyright owner. For the purposes of this definition, 49 | "submitted" means any form of electronic, verbal, or written communication sent 50 | to the Licensor or its representatives, including but not limited to 51 | communication on electronic mailing lists, source code control systems, and 52 | issue tracking systems that are managed by, or on behalf of, the Licensor for 53 | the purpose of discussing and improving the Work, but excluding communication 54 | that is conspicuously marked or otherwise designated in writing by the copyright 55 | owner as "Not a Contribution." 56 | 57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 58 | of whom a Contribution has been received by Licensor and subsequently 59 | incorporated within the Work. 60 | 61 | 2. Grant of Copyright License. 62 | 63 | Subject to the terms and conditions of this License, each Contributor hereby 64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 65 | irrevocable copyright license to reproduce, prepare Derivative Works of, 66 | publicly display, publicly perform, sublicense, and distribute the Work and such 67 | Derivative Works in Source or Object form. 68 | 69 | 3. Grant of Patent License. 70 | 71 | Subject to the terms and conditions of this License, each Contributor hereby 72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 73 | irrevocable (except as stated in this section) patent license to make, have 74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where 75 | such license applies only to those patent claims licensable by such Contributor 76 | that are necessarily infringed by their Contribution(s) alone or by combination 77 | of their Contribution(s) with the Work to which such Contribution(s) was 78 | submitted. If You institute patent litigation against any entity (including a 79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a 80 | Contribution incorporated within the Work constitutes direct or contributory 81 | patent infringement, then any patent licenses granted to You under this License 82 | for that Work shall terminate as of the date such litigation is filed. 83 | 84 | 4. Redistribution. 85 | 86 | You may reproduce and distribute copies of the Work or Derivative Works thereof 87 | in any medium, with or without modifications, and in Source or Object form, 88 | provided that You meet the following conditions: 89 | 90 | You must give any other recipients of the Work or Derivative Works a copy of 91 | this License; and 92 | You must cause any modified files to carry prominent notices stating that You 93 | changed the files; and 94 | You must retain, in the Source form of any Derivative Works that You distribute, 95 | all copyright, patent, trademark, and attribution notices from the Source form 96 | of the Work, excluding those notices that do not pertain to any part of the 97 | Derivative Works; and 98 | If the Work includes a "NOTICE" text file as part of its distribution, then any 99 | Derivative Works that You distribute must include a readable copy of the 100 | attribution notices contained within such NOTICE file, excluding those notices 101 | that do not pertain to any part of the Derivative Works, in at least one of the 102 | following places: within a NOTICE text file distributed as part of the 103 | Derivative Works; within the Source form or documentation, if provided along 104 | with the Derivative Works; or, within a display generated by the Derivative 105 | Works, if and wherever such third-party notices normally appear. The contents of 106 | the NOTICE file are for informational purposes only and do not modify the 107 | License. You may add Your own attribution notices within Derivative Works that 108 | You distribute, alongside or as an addendum to the NOTICE text from the Work, 109 | provided that such additional attribution notices cannot be construed as 110 | modifying the License. 111 | You may add Your own copyright statement to Your modifications and may provide 112 | additional or different license terms and conditions for use, reproduction, or 113 | distribution of Your modifications, or for any such Derivative Works as a whole, 114 | provided Your use, reproduction, and distribution of the Work otherwise complies 115 | with the conditions stated in this License. 116 | 117 | 5. Submission of Contributions. 118 | 119 | Unless You explicitly state otherwise, any Contribution intentionally submitted 120 | for inclusion in the Work by You to the Licensor shall be under the terms and 121 | conditions of this License, without any additional terms or conditions. 122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of 123 | any separate license agreement you may have executed with Licensor regarding 124 | such Contributions. 125 | 126 | 6. Trademarks. 127 | 128 | This License does not grant permission to use the trade names, trademarks, 129 | service marks, or product names of the Licensor, except as required for 130 | reasonable and customary use in describing the origin of the Work and 131 | reproducing the content of the NOTICE file. 132 | 133 | 7. Disclaimer of Warranty. 134 | 135 | Unless required by applicable law or agreed to in writing, Licensor provides the 136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, 137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 138 | including, without limitation, any warranties or conditions of TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are 140 | solely responsible for determining the appropriateness of using or 141 | redistributing the Work and assume any risks associated with Your exercise of 142 | permissions under this License. 143 | 144 | 8. Limitation of Liability. 145 | 146 | In no event and under no legal theory, whether in tort (including negligence), 147 | contract, or otherwise, unless required by applicable law (such as deliberate 148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be 149 | liable to You for damages, including any direct, indirect, special, incidental, 150 | or consequential damages of any character arising as a result of this License or 151 | out of the use or inability to use the Work (including but not limited to 152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or 153 | any and all other commercial damages or losses), even if such Contributor has 154 | been advised of the possibility of such damages. 155 | 156 | 9. Accepting Warranty or Additional Liability. 157 | 158 | While redistributing the Work or Derivative Works thereof, You may choose to 159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or 160 | other liability obligations and/or rights consistent with this License. However, 161 | in accepting such obligations, You may act only on Your own behalf and on Your 162 | sole responsibility, not on behalf of any other Contributor, and only if You 163 | agree to indemnify, defend, and hold each Contributor harmless for any liability 164 | incurred by, or claims asserted against, such Contributor by reason of your 165 | accepting any such warranty or additional liability. 166 | 167 | END OF TERMS AND CONDITIONS 168 | 169 | APPENDIX: How to apply the Apache License to your work 170 | 171 | To apply the Apache License to your work, attach the following boilerplate 172 | notice, with the fields enclosed by brackets "[]" replaced with your own 173 | identifying information. (Don't include the brackets!) The text should be 174 | enclosed in the appropriate comment syntax for the file format. We also 175 | recommend that a file or class name and description of purpose be included on 176 | the same "printed page" as the copyright notice for easier identification within 177 | third-party archives. 178 | 179 | Copyright [yyyy] [name of copyright owner] 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | http://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | --------------------------------------------------------------------------------