This method restores ParagraphVectors model previously saved with writeParagraphVectors()

@return
193039
public static ParagraphVectors readParagraphVectors(File file) throws IOException {
        Word2Vec w2v = readWord2Vec(file);

        // and "convert" it to ParaVec model + optionally trying to restore labels information
        ParagraphVectors vectors = new ParagraphVectors.Builder(w2v.getConfiguration())
                .vocabCache(w2v.getVocab())
                .lookupTable(w2v.getLookupTable())
                .resetModel(false)
                .build();

        try (ZipFile zipFile = new ZipFile(file)) {
            // now we try to restore labels information
            ZipEntry labels = zipFile.getEntry("labels.txt");
            if (labels != null) {
                InputStream stream = zipFile.getInputStream(labels);
                try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
                    String line;
                    while ((line = reader.readLine()) != null) {
                        VocabWord word = vectors.getVocab().tokenFor(decodeB64(line.trim()));
                        if (word != null) {
                            word.markAsLabel(true);
                        }
                    }
                }
            }
        }

        vectors.extractLabels();

        return vectors;
    }
11393
function createParagraph(nodes) {
    const firstNode = nodes[0];
    const lastNode = nodes[nodes.length - 1];
    return {
        type: Syntax.Paragraph,
        raw: nodes
            .map(function(node) {
                return node.raw;
            })
            .join(""),
        range: [firstNode.range[0], lastNode.range[1]],
        loc: {
            start: {
                line: firstNode.loc.start.line,
                column: firstNode.loc.start.column
            },
            end: {
                line: lastNode.loc.end.line,
                column: lastNode.loc.end.column
            }
        },
        children: nodes
    };
}
102372
@Nonnull
    public List<OutputWriter> getEffectiveOutputWriters() {
        // Google Guava predicates would be nicer but we don't include guava to ease embeddability
        List<OutputWriter> result = new ArrayList<OutputWriter>(embeddedJmxTrans.getOutputWriters().size() + outputWriters.size());
        for (OutputWriter outputWriter : embeddedJmxTrans.getOutputWriters()) {
            if (outputWriter.isEnabled()) {
                result.add(outputWriter);
            }
        }
        for (OutputWriter outputWriter : outputWriters) {
            if (outputWriter.isEnabled()) {
                result.add(outputWriter);
            }
        }
        return result;
    }
775606
public function getParagraphModel()
    {
        if ( null === $this->_paragraphModel )
        {
            $this->_paragraphModel = $this->getServiceLocator()
                                          ->get( 'Grid\Paragraph\Model\Paragraph\Model' );
        }

        return $this->_paragraphModel;
    }
1227047
public static <T> Reducer<PersistentList<T>,T> toPersistentVector() {
        return Reducer.fromMonoid(Monoids.concatPersistentCollection(Vector.empty()), a -> Vector.of(a));
    }
880336
@Override
    public INDArray getWordVectors(Collection<String> labels) {
        List<INDArray> words = new ArrayList<>();
        for (String label : labels) {
            if (hasWord(label) || getUNK() != null)
                words.add(getWordVectorMatrix(label));
        }

        return Nd4j.vstack(words);
    }
215464
public Part[] toPartsArray()
  {
    Vector parts = getPartsAsRepeatedOnceVector();
    Part[] partsArray = new Part[parts.size()];
    for (int i=0; i<parts.size(); i++)
      partsArray[i] = (Part)parts.elementAt(i);
    return partsArray;
  }
1149558
SaveRestoreState saveRestoreState() {
    List<Statement> saves = new ArrayList<>();
    List<Statement> restores = new ArrayList<>();
    // Iterate backwards so that we restore variables in order of definition which will ensure that
    // derived fields work correctly.
    for (Iterator<Map<VarKey, Variable>> iterator = frames.descendingIterator();
        iterator.hasNext();
        ) {
      Map<VarKey, Variable> frame = iterator.next();
      for (Variable var : frame.values()) {
        saves.add(var.save());
        restores.add(var.restore());
      }
    }
    return new AutoValue_TemplateVariableManager_SaveRestoreState(
        Statement.concat(saves), Statement.concat(restores));
  }
544513
public List<BatchArtifactRef<BatchXMLDescriptor>> getAllRef()
   {
      List<BatchArtifactRef<BatchXMLDescriptor>> list = new ArrayList<BatchArtifactRef<BatchXMLDescriptor>>();
      List<Node> nodeList = model.get("ref");
      for(Node node: nodeList)
      {
         BatchArtifactRef<BatchXMLDescriptor>  type = new BatchArtifactRefImpl<BatchXMLDescriptor>(this, "ref", model, node);
         list.add(type);
      }
      return list;
   }
620704
public static <T extends SequenceElement> void writeSequenceVectors(@NonNull SequenceVectors<T> vectors,
                                                                        @NonNull SequenceElementFactory<T> factory, @NonNull OutputStream stream) throws IOException {
        WeightLookupTable<T> lookupTable = vectors.getLookupTable();
        VocabCache<T> vocabCache = vectors.getVocab();

        try (PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream, StandardCharsets.UTF_8)))) {

            // at first line we save VectorsConfiguration
            writer.write(vectors.getConfiguration().toEncodedJson());

            // now we have elements one by one
            for (int x = 0; x < vocabCache.numWords(); x++) {
                T element = vocabCache.elementAtIndex(x);
                String json = factory.serialize(element);
                INDArray d = Nd4j.create(1);
                double[] vector = lookupTable.vector(element.getLabel()).dup().data().asDouble();
                ElementPair pair = new ElementPair(json, vector);
                writer.println(pair.toEncodedJson());
                writer.flush();
            }
        }
    }
397249
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(List<StyledSegment<SEG, S>> styledSegments) {
        return addParagraph(styledSegments, null);
    }
857421
def cleanParagraph(self):
        

        runs = self.block.content

        if not runs:
            self.block = None
            return

        if not self.clean_paragraphs:
            return

        joinedRuns = []
        hasContent = False

        for run in runs:

            if run.content[0]:
                hasContent = True
            else:
                continue

            # For whitespace-only groups, remove any property stuff,
            # to avoid extra markup in output
            if not run.content[0].strip():
                run.properties = {}

            # Join runs only if their properties match
            if joinedRuns and (run.properties == joinedRuns[-1].properties):
                joinedRuns[-1].content[0] += run.content[0]
            else:
                joinedRuns.append(run)

        if hasContent:
            # Strip beginning of paragraph
            joinedRuns[0].content[0] = joinedRuns[0].content[0].lstrip()
            # And then strip the end
            joinedRuns[-1].content[0] = joinedRuns[-1].content[0].rstrip()
            self.block.content = joinedRuns
        else:
            self.block = None
1164892
public boolean nextBatch() throws IOException {
    for (WritableColumnVector vector : columnVectors) {
      vector.reset();
    }
    columnarBatch.setNumRows(0);
    if (rowsReturned >= totalRowCount) return false;
    checkEndOfRowGroup();

    int num = (int) Math.min((long) capacity, totalCountLoadedSoFar - rowsReturned);
    for (int i = 0; i < columnReaders.length; ++i) {
      if (columnReaders[i] == null) continue;
      columnReaders[i].readBatch(num, columnVectors[i]);
    }
    rowsReturned += num;
    columnarBatch.setNumRows(num);
    numBatched = num;
    batchIdx = 0;
    return true;
  }
972452
public DataSet getDataSet()
    {
        if(!noMoreAdding)
        {
            initialLoad();
            finishAdding();
        }
        
        List<DataPoint> dataPoints= new ArrayList<DataPoint>(vectors.size());
        
        for(SparseVector vec : vectors)
            dataPoints.add(new DataPoint(vec, new int[0], new CategoricalData[0]));
        
        return new SimpleDataSet(dataPoints);
    }
    
    /**
     * To be called after all original texts have been loaded. 
     * 
     * @param text the text of the document to create a document vector from
     * @return the sparce vector representing this document 
     */
    @Override
    public Vec newText(String text)
    {
        if(!noMoreAdding)
            throw new RuntimeException("Initial documents have not yet loaded");
        return getTextVectorCreator().newText(text);
    }

    @Override
    public Vec newText(String input, StringBuilder workSpace, List<String> storageSpace)
    {
        if(!noMoreAdding)
            throw new RuntimeException("Initial documents have not yet loaded");
        return getTextVectorCreator().newText(input, workSpace, storageSpace);
    }
    
    /**
     * Returns the {@link TextVectorCreator} used by this data loader to convert
     * documents into vectors. 
     * 
     * @return the text vector creator used by this class
     */
    public TextVectorCreator getTextVectorCreator()
    {
        if(!noMoreAdding)
            throw new RuntimeException("Initial documents have not yet loaded");
        else if(tvc == null)
            tvc = new BasicTextVectorCreator(tokenizer, wordIndex, weighting);
        return tvc;
    }
    
    /**
     * Returns the original token for the given index in the data set
     * @param index the numeric feature index
     * @return the word token associated with the index
     */
    public String getWordForIndex(int index)
    {
        //lazy population of allWords array
        if(allWords.size() != wordIndex.size())//we added since this was done
        {
            while(allWords.size() < wordIndex.size())
                allWords.add("");
            for(Map.Entry<String, Integer> entry : wordIndex.entrySet())
                allWords.set(entry.getValue(), entry.getKey());
        }
        if(index >= 0 && index < allWords.size())
            return allWords.get(index);
        else
            return null;
    }
    
    /**
     * Return the number of times a token has been seen in the document
     * @param index the numeric feature index 
     * @return the total occurrence count for the feature
     */
    public int getTermFrequency(int index)
    {
        return termDocumentFrequencys.get(index).get();
    }
    
    /**
     * Creates a new transform factory to remove all features for tokens that 
     * did not occur a certain number of times
     * @param minCount the minimum number of occurrences to be kept as a feature
     * @return a transform factory for removing features that did not occur 
     * often enough
     */
    @SuppressWarnings("unchecked")
    public RemoveAttributeTransform getMinimumOccurrenceDTF(int minCount)
    {
        
        final Set<Integer> numericToRemove = new IntSet();
        for(int i = 0; i < termDocumentFrequencys.size(); i++)
            if(termDocumentFrequencys.get(i).get() < minCount)
                numericToRemove.add(i);
        
        return new RemoveAttributeTransform(Collections.EMPTY_SET, numericToRemove);
    }
}
907753
function convertFakeListsToProperLists(node) {
          var currentListNode, prevListNode, lastLevel = 1;

          function getText(node) {
            var txt = '';

            if (node.type === 3) {
              return node.value;
            }

            if ((node = node.firstChild)) {
              do {
                txt += getText(node);
              } while ((node = node.next));
            }

            return txt;
          }

          function trimListStart(node, regExp) {
            if (node.type === 3) {
              if (regExp.test(node.value)) {
                node.value = node.value.replace(regExp, '');
                return false;
              }
            }

            if ((node = node.firstChild)) {
              do {
                if (!trimListStart(node, regExp)) {
                  return false;
                }
              } while ((node = node.next));
            }

            return true;
          }

          function removeIgnoredNodes(node) {
            if (node._listIgnore) {
              node.remove();
              return;
            }

            if ((node = node.firstChild)) {
              do {
                removeIgnoredNodes(node);
              } while ((node = node.next));
            }
          }

          function convertParagraphToLi(paragraphNode, listName, start) {
            var level = paragraphNode._listLevel || lastLevel;

            // Handle list nesting
            if (level != lastLevel) {
              if (level < lastLevel) {
                // Move to parent list
                if (currentListNode) {
                  currentListNode = currentListNode.parent.parent;
                }
              } else {
                // Create new list
                prevListNode = currentListNode;
                currentListNode = null;
              }
            }

            if (!currentListNode || currentListNode.name != listName) {
              prevListNode = prevListNode || currentListNode;
              currentListNode = new Node(listName, 1);

              if (start > 1) {
                currentListNode.attr('start', '' + start);
              }

              paragraphNode.wrap(currentListNode);
            } else {
              currentListNode.append(paragraphNode);
            }

            paragraphNode.name = 'li';

            // Append list to previous list if it exists
            if (level > lastLevel && prevListNode) {
              prevListNode.lastChild.append(currentListNode);
            }

            lastLevel = level;

            // Remove start of list item "1. " or "&middot; " etc
            removeIgnoredNodes(paragraphNode);
            trimListStart(paragraphNode, /^\u00a0+/);
            trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/);
            trimListStart(paragraphNode, /^\u00a0+/);
          }

          // Build a list of all root level elements before we start
          // altering them in the loop below.
          var elements = [], child = node.firstChild;
          while (typeof child !== 'undefined' && child !== null) {
            elements.push(child);

            child = child.walk();
            if (child !== null) {
              while (typeof child !== 'undefined' && child.parent !== node) {
                child = child.walk();
              }
            }
          }

          for (var i = 0; i < elements.length; i++) {
            node = elements[i];

            if (node.name == 'p' && node.firstChild) {
              // Find first text node in paragraph
              var nodeText = getText(node);

              // Detect unordered lists look for bullets
              if (isBulletList(nodeText)) {
                convertParagraphToLi(node, 'ul');
                continue;
              }

              // Detect ordered lists 1., a. or ixv.
              if (isNumericList(nodeText)) {
                // Parse OL start number
                var matches = /([0-9]+)\./.exec(nodeText);
                var start = 1;
                if (matches) {
                  start = parseInt(matches[1], 10);
                }

                convertParagraphToLi(node, 'ol', start);
                continue;
              }

              // Convert paragraphs marked as lists but doesn't look like anything
              if (node._listLevel) {
                convertParagraphToLi(node, 'ul', 1);
                continue;
              }

              currentListNode = null;
            } else {
              // If the root level element isn't a p tag which can be
              // processed by convertParagraphToLi, it interrupts the
              // lists, causing a new list to start instead of having
              // elements from the next list inserted above this tag.
              prevListNode = currentListNode;
              currentListNode = null;
            }
          }
        }
501734
@Override
	public String getParagraphs(int min, int max) {
		int count = getCount(min, max);
		StringBuilder sb = new StringBuilder();
		for (int j = 0; j < count; j++) {
			int sentences = random.nextInt(5) + 2; // 2 to 6
			for (int i = 0; i < sentences; i++) {
				String first = getWords(1, 1, false);
				first = first.substring(0, 1).toUpperCase()
						+ first.substring(1);
				sb.append(first);

				sb.append(getWords(2, 20, false));
				sb.append(".  ");
			}
			sb.append("\n");
		}
		return sb.toString().trim();
	}
1143516
protected Set<?> getPrevExpandedRows() {
		Set<?> keys = getComponentModel().prevExpandedRows;
		if (keys == null) {
			return Collections.emptySet();
		} else {
			return Collections.unmodifiableSet(keys);
		}
	}