Comments (5)
Hi @mamift. With your file, I was able to recreate the problem.
This is an issue of the OpenXml library itself (see dotnet/Open-XML-SDK#715). It seems to be resolved in version 3.x, but unfortunately ClosedXML (that is used to read Excel files), is still on version 2.x. A fix for this has been merged (ClosedXML/ClosedXML#2248), but it has not been published yet. According to the milestone page (https://github.com/ClosedXML/ClosedXML/milestone/26?closed=1), it will be available in the next 0.104 version.
from kernel-memory.
I have just tried and I get no exception with a DOCX file that contains an URI like http:\\google.com
. I'm using Kernel Memory v0.35.240318.1.
If you still experience the issue, could you please attach a file that showcases the problem?
from kernel-memory.
OK did a bit of more digging. Recent versions of Word (don't know the earliest version exactly,) are autocorrecting the wrong slash with https:\\ and http:\\ protocol prefixes before saving the file. If you use a non-standard protocol prefix, such as quic:\\ or test:\\, Word won't auto correct and persist the \ in the file without allowing you to re-create the exception.
It seems the DOCX files I'm working with go back up to 20 years, and have been made using a range of different Word versions, such as Word 2007, 2010 (2011 for Mac), 2013, 2016, 2019, and 365 versions etc.
And the exact pattern that triggers the error has to have at least 3 wrong slashes with non-whitespace characters after the 3rd slash. So these will trigger the error,
quic:\\1234\456
wss:\\blah\12
Strangely the following don't trigger the error; there needs to be trailing non-whitespace chars after a 3rd \
:
quic:\\1234\
wss:\\blah\
http:\\intranet\
Edit: OK actually here's an example of a docx file that triggers it on my end. The files I'm working with have links to a specific custom document management system protocol:
from kernel-memory.
The latest ClosedXML 0.102.2 added a warning in case one uses a non-supported version of OpenXML, see ClosedXML/ClosedXML#2246
Closing this issue since there's nothing we can do until ClosedXML/ClosedXML#2220 is addressed and a new nuget is released. I would suggest following up with ClosedXML project, e.g. supporting with PRs and tests where possible.
from kernel-memory.
OK well for anyone else who comes across this same issue, there's a workaround: just bulk remove all links in the document and keep the text. I wrote an extension method for it:
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
namespace Program.Extensions;
public static class OpenXmlExtensions
{
/// <summary>
/// Assuming the current <paramref name="docStream"/> is a <see cref="WordprocessingDocument"/>, bulk flatten all hyperlinks (remove the link, but keep the text).
/// </summary>
/// <param name="docStream"></param>
public static void BulkRemoveHyperlinks(this Stream docStream)
{
using var doc = WordprocessingDocument.Open(docStream, true, new OpenSettings() {
AutoSave = true
});
doc.BulkRemoveHyperlinks();
}
/// <summary>
/// For the current <see cref="WordprocessingDocument"/>, remove the links on all in-document hyperlinks but keep the text inline.
/// </summary>
/// <param name="doc"></param>
public static void BulkRemoveHyperlinks(this WordprocessingDocument doc)
{
if (doc.MainDocumentPart?.Document.Body == null) return;
foreach (var link in doc.MainDocumentPart.Document.Body.Descendants<Hyperlink>()) {
if (!string.IsNullOrEmpty(link.Id)) {
var hr = doc.MainDocumentPart.HyperlinkRelationships.Single(hr => hr.Id == link.Id);
doc.MainDocumentPart.DeleteReferenceRelationship(hr.Id);
}
var linkText = link.InnerText;
var run = new Run(new Text(linkText));
link.Parent?.ReplaceChild(run, link);
}
if (!doc.AutoSave) {
doc.Save();
}
}
}
from kernel-memory.
Related Issues (20)
- [Feature Request] Support batching upsert in SQL Server Memory DB HOT 1
- IndexNotFound should be renamed to IndexNotFoundException
- [Question] does content.url in filename for websites make sense? (I want attribution per paragraph via separate prompt) HOT 4
- [Question] Regarding Hard-coded Elastic index vector dimension size HOT 1
- [Question] Running Kernel Memory as a service in Asp.Net HOT 1
- [Bug] Can't publish HOT 2
- Kernel Memory on kubernetes HOT 6
- [Question] public to internal HOT 4
- [Bug] MemoryWebClient - Rewind stream before posting to server HOT 1
- [Question] How to optimize the cost of each Ask?
- This model's maximum context length is 8192 tokens - question HOT 2
- [Question] Reading document status HOT 2
- [Question] Export imported Documents HOT 3
- [Bug] SQL failing to save when too many tags with the same key are present (list/content too big for the key) HOT 2
- GraphRAG Support HOT 1
- Support Managed Identity Authentication for AI Search HOT 2
- [Bug] - Postgres - 3D000: database <username> does not exist HOT 5
- Unable to configure AzureUSGovernmentCloud audience for AI Search HOT 1
- [Bug] 22021: invalid byte sequence for encoding "UTF8": 0x00 HOT 3
- [Bug] Wrong wording on the Cosine Similarity doc page HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kernel-memory.