GeminiTextExtractor is a C# console application designed to parse and extract specific text segments from JSON files generated by Google AI Studio's Gemini output. The application filters and saves texts where the role is designated as "model" into a separate file.
- Parses JSON files to extract specific text segments.
- Filters text based on the "role" attribute.
- Outputs extracted texts to a new file with a customized filename.
- Supports single-file deployment with trimming to reduce executable size.
- .NET 5.0 or later (Ensure you have the .NET SDK installed)
- Newtonsoft.Json (Included in the project dependencies)
-
Clone the repository:
git clone https://github.com/yourusername/GeminiTextExtractor.git cd GeminiTextExtractor
-
Open the project in your preferred C# IDE (e.g., JetBrains Rider, Visual Studio).
- Open the project in your IDE.
- Ensure you have the necessary NuGet packages installed.
- Build the project using the build configuration (e.g.,
Release
).
- Open a terminal or command prompt.
- Navigate to the directory containing the built executable.
- Run the executable with the input JSON file as an argument:
GeminiTextExtractor.exe "test.txt"
Given a JSON file test.txt
, the application will extract all text segments with the role "model" and save them into a file named test_extract.txt
in the same directory.
To publish the application as a single executable file, use the following command:
dotnet publish -c Release -r win-x64 --self-contained --no-restore -p:PublishSingleFile=true -p:PublishTrimmed=true -p:PublishReadyToRun=true