Returns the {@link DecoratedKey} contained in the specified Lucene {@link Document}.

@param document the {@link Document} containing the partition key to be get.
@return The {@link DecoratedKey} contained in the specified Lucene {@link Document}.
164397
public DecoratedKey partitionKey(Document document) {
        String string = document.get(FIELD_NAME);
        ByteBuffer partitionKey = ByteBufferUtils.fromString(string);
        return partitionKey(partitionKey);
    }
173258
@SuppressWarnings("unchecked")
    public Object convertToEntity(Class entityType, String id, ObjectNode document) {
        try {
            if (ObjectNode.class.equals(entityType)) {
                return document;
            }

            Object defaultValue = InMemoryDocumentSessionOperations.getDefaultValue(entityType);
            Object entity = defaultValue;

            String documentType =_session.getConventions().getJavaClass(id, document);
            if (documentType != null) {
                Class type = Class.forName(documentType);
                if (entityType.isAssignableFrom(type)) {
                    entity = _session.getConventions().getEntityMapper().treeToValue(document, type);
                }
            }

            if (entity == defaultValue) {
                entity = _session.getConventions().getEntityMapper().treeToValue(document, entityType);
            }

            if (id != null) {
                _session.getGenerateEntityIdOnTheClient().trySetIdentity(entity, id);
            }

            return entity;
        } catch (Exception e) {
            throw new IllegalStateException("Could not convert document " + id + " to entity of type " + entityType.getName(), e);
        }
    }
45645
public static List<String> getKeywordList(String document, int size)
    {
        return new TermFrequencyCounter().getKeywords(document, size);
    }
166718
public static <TERM> Map<TERM, Double> tf(Collection<TERM> document, TfType type)
    {
        Map<TERM, Double> tf = new HashMap<TERM, Double>();
        for (TERM term : document)
        {
            Double f = tf.get(term);
            if (f == null) f = 0.0;
            tf.put(term, f + 1);
        }
        if (type != TfType.NATURAL)
        {
            for (TERM term : tf.keySet())
            {
                switch (type)
                {
                    case LOGARITHM:
                        tf.put(term, 1 + Math.log(tf.get(term)));
                        break;
                    case BOOLEAN:
                        tf.put(term, tf.get(term) == 0.0 ? 0.0 : 1.0);
                        break;
                }
            }
        }
        return tf;
    }
1154522
@Pure
	public static Document getDocumentFor(Node node) {
		Node localnode = node;
		while (localnode != null) {
			if (localnode instanceof Document) {
				return (Document) localnode;
			}
			localnode = localnode.getParentNode();
		}
		return null;
	}
1020549
public static List<String> getKeywordList(String document, int size)
    {
        TextRankKeyword textRankKeyword = new TextRankKeyword();

        return textRankKeyword.getKeywords(document, size);
    }
1359674
public static List<String> extractKeyword(String document, int size)
    {
        return TextRankKeyword.getKeywordList(document, size);
    }
1155467
def findBookmark(self, bookmark):
        """"""
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")

        return _fitz.Document_findBookmark(self, bookmark)
725887
public Document cloneDocument(DOMImplementation domImpl, Document document) {
    Element root = document.getDocumentElement();
    // New document
    Document result = domImpl.createDocument(root.getNamespaceURI(), root.getNodeName(), null);
    Element rroot = result.getDocumentElement();
    // Cloning the document element is a bit tricky.
    // This is adopted from DomUtilities#deepCloneDocument
    boolean before = true;
    for(Node n = document.getFirstChild(); n != null; n = n.getNextSibling()) {
      if(n == root) {
        before = false;
        copyAttributes(result, root, rroot);
        for(Node c = root.getFirstChild(); c != null; c = c.getNextSibling()) {
          final Node cl = cloneNode(result, c);
          if(cl != null) {
            rroot.appendChild(cl);
          }
        }
      }
      else {
        if(n.getNodeType() != Node.DOCUMENT_TYPE_NODE) {
          final Node cl = cloneNode(result, n);
          if(cl != null) {
            if(before) {
              result.insertBefore(cl, rroot);
            }
            else {
              result.appendChild(cl);
            }
          }
        }
      }
    }
    return result;
  }
1049673
@Programmatic
    public <T> T paperclipAttaches(final Document document, Class<T> typeAttachedTo) {
        final List<Paperclip> paperclips = findByDocument(document);
        for (Paperclip paperclip : paperclips) {
            final Object attachedTo = paperclip.getAttachedTo();
            if(typeAttachedTo.isAssignableFrom(attachedTo.getClass())) {
                return (T) attachedTo;
            }
        }
        return null;
    }
404819
protected function document(Document $document = null): ?Document {
        if ($document === null) {
            return $this->document;
        }

        $this->document = $document;

        return $this->document;
    }
688823
public void read(final URI filename, final Document doc) {
        currentFile = filename;
        rootScope = null;
        // TODO: use KeyScope implementation that retains order
        KeyScope keyScope = readScopes(doc);
        keyScope = cascadeChildKeys(keyScope);
        // TODO: determine effective key definitions here
        keyScope = inheritParentKeys(keyScope);
        rootScope = resolveIntermediate(keyScope);
    }
503596
public int addDocument(String document) {
    if (root().getNumberOfChildren() >= 0) {
      throw new IllegalStateException("Tree sorting has begun");
    }
    final int index;
    synchronized (this) {
      index = documents.size();
      documents.add(document);
    }
    cursors.addAll(
      IntStream.range(0, document.length() + 1).mapToObj(i -> new CursorData(index, i)).collect(Collectors.toList()));
    nodes.update(0, node -> node.setCursorCount(cursors.length()));
    return index;
  }
1362827
private Map<String, Object> getContentForNav(Map<String, Object> document) {
        Map<String, Object> navDocument = new HashMap<>();
        navDocument.put(Attributes.NO_EXTENSION_URI, document.get(Attributes.NO_EXTENSION_URI));
        navDocument.put(Attributes.URI, document.get(Attributes.URI));
        navDocument.put(Attributes.TITLE, document.get(Attributes.TITLE));
        return navDocument;
    }
1287240
final Document getPayloadDocument() throws ParserConfigurationException,
                                             IOException,
                                             UnsupportedEncodingException {

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getPayloadDocument");

    Document domDoc = null;

    // If we already have a Document cached we don't need to build it again
    if (softRefToDocument != null) {
      domDoc = softRefToDocument.get();
    }

    // Otherwise we'll take the hit of building it, and cache it in a soft reference
    if (domDoc == null) {
      String text = getText();
      if ((text != null) && (text.length() > 0)) {
        DocumentBuilderFactory domFactory =DocumentBuilderFactory.newInstance();
        // We need to tell the factory that we want it to be namespace aware.
        domFactory.setNamespaceAware(true);
        DocumentBuilder builder = domFactory.newDocumentBuilder();
        InputSource is = new InputSource(new StringReader(text));
        try {
          domDoc = builder.parse(is);
          softRefToDocument = new SoftReference<Document>(domDoc);
        }
        catch (SAXException e) {
          // No FFDC code needed
          // This is not really an error - it just means the data is not XML.
          // As the XPath Expression can't evaluate to True we just set the document to null;
          domDoc = null;
        }
      }
      else {
        domDoc = null;
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getPayloadDocument", domDoc);
    return domDoc;
  }
429661
public static DecoratedKey getMinimalKey(DecoratedKey key)
    {
        return key.getKey().position() > 0 || key.getKey().hasRemaining() || !key.getKey().hasArray()
                                       ? new BufferDecoratedKey(key.getToken(), HeapAllocator.instance.clone(key.getKey()))
                                       : key;
    }
98721
public MtasToken getObjectById(String field, int docId, int mtasId)
      throws IOException {
    try {
      Long ref;
      Long objectRefApproxCorrection;
      IndexDoc doc = getDoc(field, docId);
      IndexInput inObjectId = indexInputList.get("indexObjectId");
      IndexInput inObject = indexInputList.get("object");
      IndexInput inTerm = indexInputList.get("term");
      if (doc.storageFlags == MtasCodecPostingsFormat.MTAS_STORAGE_BYTE) {
        inObjectId.seek(doc.fpIndexObjectId + (mtasId * 1L));
        objectRefApproxCorrection = Long.valueOf(inObjectId.readByte());
      } else if (doc.storageFlags == MtasCodecPostingsFormat.MTAS_STORAGE_SHORT) {
        inObjectId.seek(doc.fpIndexObjectId + (mtasId * 2L));
        objectRefApproxCorrection = Long.valueOf(inObjectId.readShort());
      } else if (doc.storageFlags == MtasCodecPostingsFormat.MTAS_STORAGE_INTEGER) {
        inObjectId.seek(doc.fpIndexObjectId + (mtasId * 4L));
        objectRefApproxCorrection = Long.valueOf(inObjectId.readInt());
      } else {
        inObjectId.seek(doc.fpIndexObjectId + (mtasId * 8L));
        objectRefApproxCorrection = Long.valueOf(inObjectId.readLong());
      }
      ref = objectRefApproxCorrection + doc.objectRefApproxOffset
          + (mtasId * (long) doc.objectRefApproxQuotient);
      return MtasCodecPostingsFormat.getToken(inObject, inTerm, ref);
    } catch (Exception e) {
      throw new IOException(e);
    }
  }