Updates the semantic vectors based on the words in the document.

@param document {@inheritDoc}

@throws IllegalStateException if the vector values of this instance have
been transform using {@link #processSpace(Transform)}
508357
public void processDocument(BufferedReader document) throws IOException {
        if (wordToTransformedVector != null) {
            throw new IllegalStateException("Cannot add new documents to a " +
                "GenericWordSpace whose vectors have been transformed");
        }

        Queue<String> prevWords = new ArrayDeque<String>(windowSize);
        Queue<String> nextWords = new ArrayDeque<String>(windowSize);

        Iterator<String> documentTokens = 
            IteratorFactory.tokenizeOrdered(document);

        String focusWord = null;

        // prefetch the first windowSize words 
        for (int i = 0; i < windowSize && documentTokens.hasNext(); ++i)
            nextWords.offer(documentTokens.next());
        
        while (!nextWords.isEmpty()) {
            focusWord = nextWords.remove();

            // shift over the window to the next word
            if (documentTokens.hasNext()) {
                String windowEdge = documentTokens.next(); 
                nextWords.offer(windowEdge);
            }    

            // If we are filtering the semantic vectors, check whether this word
            // should have its semantics calculated.  In addition, if there is a
            // filter and it would have excluded the word, do not keep its
            // semantics around
            boolean calculateSemantics =
                (semanticFilter.isEmpty() || semanticFilter.contains(focusWord))
                && !focusWord.equals(IteratorFactory.EMPTY_TOKEN);
            
            if (calculateSemantics) {
                SparseIntegerVector focusSemantics = 
                    getSemanticVector(focusWord);

                // Keep track of the relative position of the focus word in case
                // word ordering is being used.
                int position = -prevWords.size(); // first word is furthest
                for (String word : prevWords) {
                    // Skip the addition of any words that are excluded from the
                    // filter set.  Note that by doing the exclusion here, we
                    // ensure that the token stream maintains its existing
                    // ordering, which is necessary when word order is taken
                    // into account.
                    if (word.equals(IteratorFactory.EMPTY_TOKEN)) {
                        position++;
                        continue;
                    }
                    
                    int dimension = basisMapping.getDimension(
                        new Duple<String,Integer>(word, position));
                    synchronized(focusSemantics) {
                        focusSemantics.add(dimension, 1);
                    }
                    position++;
                }
            
                // Repeat for the words in the forward window.
                position = 1;
                for (String word : nextWords) {
                    // Skip the addition of any words that are excluded from the
                    // filter set.  Note that by doing the exclusion here, we
                    // ensure that the token stream maintains its existing
                    // ordering, which is necessary when word order is taken
                    // into account.
                    if (word.equals(IteratorFactory.EMPTY_TOKEN)) {
                        ++position;
                        continue;
                    }
                
                    int dimension = basisMapping.getDimension(
                        new Duple<String,Integer>(word, position));
                    synchronized(focusSemantics) {
                        focusSemantics.add(dimension, 1);
                    }
                    position++;
                }
            }

            // Last put this focus word in the prev words and shift off the
            // front of the previous word window if it now contains more words
            // than the maximum window size
            prevWords.offer(focusWord);
            if (prevWords.size() > windowSize) {
                prevWords.remove();
            }
        }    

        document.close();
    }
34792
protected void update(DocumentEvent event)
	{
		String text;
		try
		{
			text = event.getDocument().getText(event.getDocument().getStartPosition().getOffset(),
				event.getDocument().getEndPosition().getOffset() - 1);
			model.setObject(text);
		}
		catch (BadLocationException e1)
		{
			log.log(Level.SEVERE,
				"some portion of the given range was not a valid part of the document. "
					+ "The location in the exception is the first bad position encountered.",
				e1);
		}
	}
811042
public void updateNamespaces(Document document) {
	Namespace rootNamespace = Namespace.gatherNamespaces(document);
	document.setNamespace(rootNamespace);
	for (org.openprovenance.prov.model.Bundle bu: utils.getBundle(document)) {
	    Namespace ns=bu.getNamespace();
	    if (ns!=null) {
		ns.setParent(rootNamespace);
	    } else {
		ns=new Namespace();
		ns.setParent(rootNamespace);
		bu.setNamespace(ns);
	    }
	}
    }
642836
public static void setVersion(Document doc, Version version) {
	Element root = doc.getDocumentElement();
	root.setAttribute("version", version.getMajor() + "." + version.getMinor());

    }
877444
protected void addAttributes(final GedDocument<?> document) {
        for (final GedDocument<? extends GedObject> attribute : document
                .getAttributes()) {
            final DocumentToApiModelVisitor v = createVisitor();
            attribute.accept(v);
            baseObject.getAttributes()
                    .add(convertToAttribute(v.getBaseObject()));
        }
    }
782110
public static void addAll(Document document) {
        List<Element> elementList = getElements(document);

        List<String> elementIds = getElementsId(elementList);

        addAll(elementList);
    }
178821
protected void _format(SarlBehavior behavior, IFormattableDocument document) {
		formatAnnotations(behavior, document, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations);
		formatModifiers(behavior, document);

		final ISemanticRegionsFinder regionFor = this.textRegionExtensions.regionFor(behavior);
		document.append(regionFor.keyword(this.keywords.getBehaviorKeyword()), ONE_SPACE);

		document.surround(regionFor.keyword(this.keywords.getExtendsKeyword()), ONE_SPACE);
		document.format(behavior.getExtends());

		formatBody(behavior, document);
	}
259277
@Override
    public String stringify(Document document) {
        try {
            StringWriter sw = new StringWriter();
            TransformerFactory tf = TransformerFactory.newInstance();
            Transformer transformer = tf.newTransformer();
            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");

            transformer.transform(new DOMSource(document), new StreamResult(sw));
            return sw.toString();
        } catch (TransformerException e) {
            throw new RuntimeException(e);
        }
    }
53884
public Vector decodeEvents(final String document) {

      if (document != null) {

          if (document.trim().equals("")) {
              return null;
          }

          String newDoc;
          String newPartialEvent = null;
          //separate the string into the last portion ending with </record>
          // (which will be processed) and the partial event which
          // will be combined and processed in the next section

          //if the document does not contain a record end,
          // append it to the partial event string
          if (document.lastIndexOf(RECORD_END) == -1) {
              partialEvent = partialEvent + document;
              return null;
          }

          if (document.lastIndexOf(RECORD_END) + RECORD_END.length()
                  < document.length()) {
              newDoc = document.substring(0,
                      document.lastIndexOf(RECORD_END) + RECORD_END.length());
              newPartialEvent = document.substring(
                      document.lastIndexOf(RECORD_END) + RECORD_END.length());
          } else {
              newDoc = document;
          }
          if (partialEvent != null) {
              newDoc = partialEvent + newDoc;
          }
          partialEvent = newPartialEvent;

          Document doc = parse(newDoc);
          if (doc == null) {
              return null;
          }
          return decodeEvents(doc);
      }
      return null;
  }
327500
private void updateSingle(
            ReadOnlyStyledDocument<PS, SEG, S> newValue,
            RichTextChange<PS, SEG, S> change,
            MaterializedListModification<Paragraph<PS, SEG, S>> parChange) {
        updateMulti(newValue, Collections.singletonList(change), Collections.singletonList(parChange));
    }
520656
private void setC4Document(C4Document c4doc) {
        synchronized (lock) {
            replaceC4Document(c4doc);
            data = null;
            if (c4doc != null && !c4doc.deleted()) { data = c4doc.getSelectedBody2(); }
            updateDictionary();
        }
    }
891136
public void add(DOCUMENT doc) {
      if (doc != null) {
         documents.add(doc);
         int id = documents.size() - 1;
         for (KEY key : documentMapper.apply(doc)) {
            index.put(key, id);
         }
      }
   }
999608
public void fitLabelledDocuments(JavaRDD<LabelledDocument> documentsRdd) {

        validateConfiguration();

        broadcastEnvironment(new JavaSparkContext(documentsRdd.context()));

        JavaRDD<Sequence<VocabWord>> sequenceRDD =
                        documentsRdd.map(new DocumentSequenceConvertFunction(configurationBroadcast));

        super.fitSequences(sequenceRDD);
    }
1141022
protected void addSplitAttributes(final GedDocument<?> document) {
        for (final GedDocument<? extends GedObject> attribute : document
                .getAttributes()) {
            final DocumentToApiModelVisitor v = createVisitor();
            attribute.accept(v);
            ((ApiHasImages) baseObject)
                    .addAttribute(convertToAttribute(v.getBaseObject()));
        }
    }
380956
def setdocument(self, doc):
        
        assert isinstance(doc, Document)

        if not self.doc:
            self.doc = doc
            if self.id:
                if self.id in doc:
                    raise DuplicateIDError(self.id)
                else:
                    self.doc.index[id] = self

        for e in self: #recursive for all children
            if isinstance(e,AbstractElement): e.setdocument(doc)
1016828
public void updateStyleElement(Document document, Element style) {
    StringBuilder buf = new StringBuilder();
    serialize(buf);
    Text cont = document.createTextNode(buf.toString());
    while (style.hasChildNodes()) {
      style.removeChild(style.getFirstChild());
    }
    style.appendChild(cont);
  }
172340
void add_document(Document doc)
    {
        doc.feature().normalize();
        documents_.add(doc);
        composite_.add_vector(doc.feature());
    }