Skip to content

Commit

Permalink
extracting contacts from text using ingo
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Oct 5, 2024
1 parent 3db4b2d commit c345c03
Show file tree
Hide file tree
Showing 7 changed files with 402 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -677,11 +677,15 @@ You should also get your employer (if you work as a programmer) or school,
import com.jdimension.jlawyer.persistence.ArchiveFileBean;
import com.jdimension.jlawyer.persistence.AssistantPrompt;
import java.awt.event.ActionEvent;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
Expand Down Expand Up @@ -773,6 +777,21 @@ public Map<AssistantConfig, List<AiCapability>> getCapabilities() throws Excepti
* @throws Exception
*/
public Map<AssistantConfig, List<AiCapability>> filterCapabilities(String requestType, String inputType) throws Exception {
return this.filterCapabilities(requestType, inputType, AiCapability.USAGETYPE_INTERACTIVE);
}

/**
* Filters available capabilities of the backends to match what the client
* requests, e.g. it might only have a STRING instead of a FILE and only
* wants to transcribe instead of summarize
*
* @param requestType
* @param inputType
* @param usageType the usage type, either automated or interactive
* @return
* @throws Exception
*/
public Map<AssistantConfig, List<AiCapability>> filterCapabilities(String requestType, String inputType, String usageType) throws Exception {

Map<String, List<AssistantPrompt>> prompts=this.getCustomPrompts();

Expand All @@ -783,6 +802,9 @@ public Map<AssistantConfig, List<AiCapability>> filterCapabilities(String reques
if (requestType != null && !c.getRequestType().equals(requestType)) {
continue;
}
if (usageType != null && !c.getUsageTypes().toLowerCase().contains(usageType.toLowerCase())) {
continue;
}

boolean inputSupported = false;
if (inputType != null) {
Expand Down Expand Up @@ -912,5 +934,23 @@ public void populateMenu(JMenu menu, Map<AssistantConfig, List<AiCapability>> ca
}

}

public static Map<String, String> jsonStringToMap(String jsonString) throws Exception {
Map<String, String> resultMap = new HashMap<>();

// Create a JsonReader from the JSON string
try (JsonReader jsonReader = Json.createReader(new StringReader(jsonString))) {
// Parse the JSON string into a JsonObject
JsonObject jsonObject = jsonReader.readObject();

// Iterate through the key-value pairs in the JSON object
for (String key : jsonObject.keySet()) {
// Assuming all values are of type String, otherwise handle differently
resultMap.put(key, jsonObject.getString(key));
}
}

return resultMap;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSplitPane1" alignment="0" pref="857" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="cmdExtract" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="cmdConfirm" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cmdClose" min="-2" max="-2" attributes="0"/>
Expand All @@ -47,6 +48,7 @@
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cmdClose" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cmdConfirm" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cmdExtract" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
Expand All @@ -73,8 +75,10 @@
<Component class="javax.swing.JTextArea" name="taBody">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="lineWrap" type="boolean" value="true"/>
<Property name="rows" type="int" value="5"/>
<Property name="toolTipText" type="java.lang.String" value="&lt;html&gt;&lt;p&gt;Erstellung einer Adresse aus Text in der Zwischenablage&lt;br/&gt;Die relevante Textpassage - bspw. eine Signatur oder ein Impressum - hier einf&#xfc;gen und so angepassen, dass jedes Attribut auf einer eigenen Zeile steht.&lt;br/&gt;Anschlie&amp;szlig;end die relevanten Zeilen markieren und im rechten Teil des Dialogs eine Zuordnung vornehmen.&lt;/html&gt;"/>
<Property name="wrapStyleWord" type="boolean" value="true"/>
</Properties>
</Component>
</SubComponents>
Expand Down Expand Up @@ -127,5 +131,15 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdConfirmActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cmdExtract">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons16/material/j-lawyer-ai.png"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdExtractActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>
Loading

0 comments on commit c345c03

Please sign in to comment.