Render the words via TSNE

@param tsne           the tsne to use
@param numWords
@param connectionInfo
328420
@Override
    public void plotVocab(BarnesHutTsne tsne, int numWords, UiConnectionInfo connectionInfo) {
        try {
            final List<String> labels = fitTnseAndGetLabels(tsne, numWords);
            final INDArray reducedData = tsne.getData();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < reducedData.rows() && i < numWords; i++) {
                String word = labels.get(i);
                INDArray wordVector = reducedData.getRow(i);
                for (int j = 0; j < wordVector.length(); j++) {
                    sb.append(String.valueOf(wordVector.getDouble(j))).append(",");
                }
                sb.append(word);
            }

            String address = connectionInfo.getFirstPart() + "/tsne/post/" + connectionInfo.getSessionId();
            //            System.out.println("ADDRESS: " + address);
            URI uri = new URI(address);

            HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("User-Agent", "Mozilla/5.0");
            //            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=-----TSNE-POST-DATA-----");
            connection.setDoOutput(true);

            final OutputStream outputStream = connection.getOutputStream();
            final PrintWriter writer = new PrintWriter(outputStream);
            writer.println("-------TSNE-POST-DATA-----");
            writer.println("Content-Disposition: form-data; name=\"fileupload\"; filename=\"tsne.csv\"");
            writer.println("Content-Type: text/plain; charset=UTF-16");
            writer.println("Content-Transfer-Encoding: binary");
            writer.println();
            writer.flush();

            DataOutputStream dos = new DataOutputStream(outputStream);
            dos.writeBytes(sb.toString());
            dos.flush();
            writer.println();
            writer.flush();
            dos.close();
            outputStream.close();

            try {
                int responseCode = connection.getResponseCode();
                System.out.println("RESPONSE CODE: " + responseCode);

                if (responseCode != 200) {
                    BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                    String inputLine;
                    StringBuilder response = new StringBuilder();

                    while ((inputLine = in.readLine()) != null) {
                        response.append(inputLine);
                    }
                    in.close();

                    log.warn("Error posting to remote UI - received response code {}\tContent: {}", response,
                                    response.toString());
                }
            } catch (IOException e) {
                log.warn("Error posting to remote UI at {}", uri, e);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
739350
public void setConnectionNameList(java.util.Collection<String> connectionNameList) {
        if (connectionNameList == null) {
            this.connectionNameList = null;
            return;
        }

        this.connectionNameList = new java.util.ArrayList<String>(connectionNameList);
    }
652334
public void useNamespace(SerializerContext serializerContext, String namespace)
	{
		if (namespace != null && namespace.length() > 0)
		{
			if (serializerContext.knownNamespaces == null)
			{
				serializerContext.knownNamespaces = new HashSet<String>(8);
			}
			serializerContext.knownNamespaces.add(namespace);
		}
	}
382023
public ResponseWrapper addSensitiveWords(Set<String> words) throws APIConnectionException, APIRequestException {
        return _sensitiveWordClient.addSensitiveWords(words);
    }
976960
public static void writeTsneFormat(Glove vec, INDArray tsne, File csv) throws Exception {
        try (BufferedWriter write = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csv), StandardCharsets.UTF_8))) {
            int words = 0;
            InMemoryLookupCache l = (InMemoryLookupCache) vec.vocab();
            for (String word : vec.vocab().words()) {
                if (word == null) {
                    continue;
                }
                StringBuilder sb = new StringBuilder();
                INDArray wordVector = tsne.getRow(l.wordFor(word).getIndex());
                for (int j = 0; j < wordVector.length(); j++) {
                    sb.append(wordVector.getDouble(j));
                    if (j < wordVector.length() - 1) {
                        sb.append(",");
                    }
                }
                sb.append(",");
                sb.append(word.replaceAll(" ", WHITESPACE_REPLACEMENT));
                sb.append(" ");

                sb.append("\n");
                write.write(sb.toString());

            }

            log.info("Wrote " + words + " with size of " + vec.lookupTable().layerSize());
        }
    }
363624
public static void load(Connection connection) throws SQLException {
        registerH2GISFunctions(connection,"");
        registerGeometryType(connection);
        registerSpatialTables(connection);
    }
1330419
public void emit(ComponentInfo componentInfo, EmitInfo info)
    {
        if (this.sessions.size() == 0)
        {
            return;
        }

        Date nowTime = new Date();
        DateFormat format = new SimpleDateFormat(DATE_PATTERN);
        String nowTimeStr = format.format(nowTime);

        Map<String, Object> objectMap = Maps.newHashMap();
        objectMap.put("time", nowTimeStr);
        objectMap.put("component", componentInfo);
        objectMap.put("emitinfo", info);

        String logInfo;
        try
        {
            logInfo = this.mapper.writeValueAsString(objectMap);
        }
        catch (JsonProcessingException ex)
        {
            String msgFormat = "Event convert failed. Skip log output. : ComponentInfo={0}, EmitInfo={1}";
            String message = MessageFormat.format(msgFormat, componentInfo,
                    ToStringBuilder.reflectionToString(info, ToStringStyle.SHORT_PREFIX_STYLE));
            logger.warn(message, ex);
            return;
        }

        for (Entry<String, Session> entry : this.sessions.entrySet())
        {
            entry.getValue().getAsyncRemote().sendText(logInfo, this.handler);
        }
    }
912540
private void handleStubDefinition(NodeTraversal t, Node n) {
    if (!t.inGlobalHoistScope()) {
      return;
    }
    JSDocInfo info = n.getFirstChild().getJSDocInfo();
    boolean hasStubDefinition = info != null && (n.isFromExterns() || info.hasTypedefType());
    if (hasStubDefinition) {
      if (n.getFirstChild().isQualifiedName()) {
        String name = n.getFirstChild().getQualifiedName();
        ProvidedName pn = providedNames.get(name);
        if (pn != null) {
          n.putBooleanProp(Node.WAS_PREVIOUSLY_PROVIDED, true);
          pn.addDefinition(n, t.getModule());
        } else if (n.getBooleanProp(Node.WAS_PREVIOUSLY_PROVIDED)) {
          // We didn't find it in the providedNames, but it was previously marked as provided.
          // This implies we're in hotswap pass and the current typedef is a provided namespace.
          ProvidedName provided = new ProvidedName(name, n, t.getModule(), true, true);
          providedNames.put(name, provided);
          provided.addDefinition(n, t.getModule());
        }
      }
    }
  }
151154
public static void info(TraceComponent tc, String msgKey) {
    if(isTracing()) SibTr.info(tc, msgKey);

  }
859404
private void initNamespaces(){
		Map<Integer, String> namespaceMap = new HashMap<Integer,String>();
		try{
			int b = read();

			this.keywords.reset();
			StringBuilder buffer = null;

			while (b != -1) {
//				System.out.print((char)b);

				if (buffer != null) {
					buffer.append((char) b);
				}

				if (this.keywords.check((char) b)) {
					switch (this.keywords.getValue()) {

						case KEY_START_NAMESPACES:
							buffer = new StringBuilder(WikipediaXMLKeys.KEY_START_NAMESPACES.getKeyword());
							break;

						case KEY_END_NAMESPACES:
							DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
							factory.setIgnoringElementContentWhitespace(true);
							Document namespaces = factory.newDocumentBuilder().parse(new InputSource(new StringReader(buffer.toString())));


							NodeList nsList = namespaces.getChildNodes().item(0).getChildNodes();

							for (int i = 0; i < nsList.getLength(); i++) {
								Node curNamespace = nsList.item(i);

								//get the prefix for the current namespace
								String prefix = curNamespace.getTextContent().trim();
								if(!prefix.isEmpty()){
									NamedNodeMap nsAttributes = curNamespace.getAttributes();
									String namespace = nsAttributes.getNamedItem("key").getTextContent();
									namespaceMap.put(Integer.parseInt(namespace), prefix);
								}
							}

					    buffer = null;
						articleFilter.initializeNamespaces(namespaceMap);
						return; //init done

					}

					this.keywords.reset();
				}

				b=read();
			}
		}catch(IOException e){
			System.err.println("Error reading namespaces from xml dump.");
		}catch(ParserConfigurationException e){
			System.err.println("Error parsing namespace data.");
		}catch(SAXException e){
			System.err.println("Error parsing namespace data.");
		}
	}
197075
function DynamicDictionaries(trie, token_info_dictionary, connection_costs, unknown_dictionary) {
    if (trie != null) {
        this.trie = trie;
    } else {
        this.trie = doublearray.builder(0).build([
            {k: "", v: 1}
        ]);
    }
    if (token_info_dictionary != null) {
        this.token_info_dictionary = token_info_dictionary;
    } else {
        this.token_info_dictionary = new TokenInfoDictionary();
    }
    if (connection_costs != null) {
        this.connection_costs = connection_costs;
    } else {
        // backward_size * backward_size
        this.connection_costs = new ConnectionCosts(0, 0);
    }
    if (unknown_dictionary != null) {
        this.unknown_dictionary = unknown_dictionary;
    } else {
        this.unknown_dictionary = new UnknownDictionary();
    }
}
157856
public static void renderDOTExternal(File dotFile, String format) throws IOException {
        renderDOTExternal(IOUtil.asBufferedUTF8Reader(dotFile), format);
    }
210781
def outputConnections(self, cls=None):
        
        scene = self.scene()
        if not scene:
            return []
        
        if not cls:
            cls = XNodeConnection
        
        output = []
        for item in scene.items():
            if not isinstance(item, cls):
                continue
            
            if item.outputNode() == self:
                output.append(item)
        
        return output
587276
public void PrintCollocationStrings(PrintWriter pw){
    //ArrayList<String> strs = new ArrayList<String>();
    for(Collocation c: collocationCollector){
      String cs = c.collocationString;
      pw.println(cs+" ("+(c.span.first()+1)+","+(c.span.second()+1)+")");
    }
  }
185852
def _writeConnections(self, connections, fileObject):
        
        for connection in connections:
            fileObject.write('CONNECT  %s  %s  %s\n' % (
                connection.slinkNumber,
                connection.upSjuncNumber,
                connection.downSjuncNumber))
635847
public static int word_count(EvaluationContext ctx, Object text, @BooleanDefault(false) Object bySpaces) {
        String _text = Conversions.toString(text, ctx);
        boolean _bySpaces = Conversions.toBoolean(bySpaces, ctx);
        return getWords(_text, _bySpaces).size();
    }
223691
public void setOutboundConnectionInfoInternal(Map<String, Object> connectionInfo) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "setOutboundConnectionInfoInternal :" + connectionInfo);
        this.outboundConnectionInfoInternal = connectionInfo;
    }