# \<PrimaryInterface> Class Doc.

{% hint style="info" %}
You can use the help function (`?/help`) at any time to view a list of available commands or to get detailed information about a specific command by adding a `<command>` .
{% endhint %}

```
| Tip: type 'help' to learn about any command. 
| Tip: type '?' to learn about allowed actions.
-----------------------------------------------
03:31:21 ~ [es][b]@[Sin pudor(NA)]/[y1]: r
03:31:24 ~ [es][v]@[Caer en la cuenta(NA)]/[y1]: ls
(SYS: Started edit-session at 03:31:27)
Showing 2/2 results.
| 1. Darse cuenta  | 2. Darse perfecta cuenta
>> mv 1 y2
>> y2
Showing 1/1 results.
| 1. Darse cuenta                                                                                          a
>> y1
Showing 1/1 results.
| 1. Darse perfecta cuenta
>> cd 1
03:31:56 ~ [es][v]@[Darse perfecta cuenta(NA)]/[y1]: edit lang en
Change applied successfully.
03:32:06 ~ [en][v]@[Darse perfecta cuenta(NA)]/[y1]: sug
(SYS: Started sug-session at 03:32:13)
| [es][v]@[Sobrentender(NA)] [Y/N] >>
| [es][v]@[Finiquitar(NA)] [Y/N] >> e2
| Succesfully binded node to 'e2' field.
| [es][v]@[Analizar(NA)] [Y/N] >> q
(SYS: Ended sug-session at 03:32:26)
03:32:06 ~ [en][v]@[Darse perfecta cuenta(NA)]/[y1]: e2
03:32:32 ~ [en][v]@[Darse perfecta cuenta(NA)]/[e2]: ls
(SYS: Started edit-session at 03:32:36)
Showing 1/1 results.
| 1. Finiquitar
>>
(SYS: Ended edit-session at 03:32:48)
03:32:32 ~ [en][v]@[Darse perfecta cuenta(NA)]/[e2]: Perro
| Successfully binded 'Perro'.
03:32:32 ~ [en][v]@[Darse perfecta cuenta(NA)]/[e2]: vg
| There are no examples.
>>
(SYS: Ended vg-session at 03:33:27)
03:32:32 ~ [en][v]@[Darse perfecta cuenta(NA)]/[e2]: pin
03:33:29 ~ [en][v]@[Darse perfecta cuenta(NA)*]/[e2]: details
| Synset sizes (y0 = 0, y1 = 2, y2 = 0)
| Semset sizes (e0 = 0, e1 = 0, e2 = 2)
03:33:29 ~ [en][v]@[Darse perfecta cuenta(NA)*]/[e2]: r -t v
03:33:42 ~ [es][v]@[Brasear(NA)]/[e2]:
```

## **0. Overview**

`SK_Interface` is a comprehensive command-line interface (CLI) designed to interact with a knowledge graph. It provides a wide range of functionalities including node navigation (`cd`), modification (`grab`, `new`), information display (`ls`, `run`), and settings management (`set`, `unset`), among others. This documentation details the usage and features of each command available in the SK\_Interface.

## 1. Basic Commands

{% tabs %}
{% tab title="cd" %}
The `cd` command in the CLI facilitates navigation to different nodes within the graph.

When a user inputs `cd` followed by a node name, the system either (_1st case_) directly navigates to the node if there's an exact match, or (_2nd case_) presents a selection interface to choose from among multiple matching nodes. In cases where no exact match exists (due to misspelling), the CLI provides guessed options based on the input for user selection (_3rd case_).

***

```
20:21:50 ~ [es][n]@[Esfinge(NA)]/[y1]: cd Zorro
20:23:10 ~ [es][n]@[Zorro(NA)]/[y1]:
```

```
20:21:07 ~ [es][j]@[Por defecto(NA)]/[y1]: cd Planta
| Do you mean ...
|   1) [es][n]@[Planta(NA)]
|   2) [es][j]@[Planta(vegetal)]
| (Press Enter without any input to exit)
>> 2
20:21:17 ~ [es][j]@[Planta(vegetal)]/[y1]:
```

```
20:21:17 ~ [es][j]@[Planta(vegetal)]/[y1]: cd Esfingie
| Do you mean ...
|   1) [es][n]@[Esfinge(NA)]
|   2) [es][n]@[Efigie(NA)]
|   3) [es][v]@[Fingir(NA)]
|   4) [es][v]@[Definirse(NA)]
| (Press Enter without any input to exit)
>> 1
20:21:50 ~ [es][n]@[Esfinge(NA)]/[y1]:
```

***

To go back, we can write `cd ..` .

```
00:32:12 ~ [es][n]@[Spaghetti(NA)]/[y1]: cd Capacidad
00:36:08 ~ [es][n]@[Capacidad(NA)]/[y1]: cd Veto
00:36:10 ~ [es][n]@[Veto(NA)]/[y1]: cd ..
00:36:11 ~ [es][n]@[Capacidad(NA)]/[y1]: cd ..
00:36:15 ~ [es][n]@[Spaghetti(NA)]/[y1]: cd ..
Reached base state.
00:36:15 ~ [es][n]@[Spaghetti(NA)]/[y1]:
```
{% endtab %}

{% tab title="r" %}
The `r` command is designed to select a random node from the graph, with the option to apply specific constraints.

Users can refine their search by specifying the language (using the `-l` option), the type of node (with `-t`), or toggle the selection to favorited nodes (using `-f`). This command allows for a more targeted random selection within the graph based on these specified parameters.

One added functionality in one of the latest revisions is the `-s` (`--sos`) command, which allows setting a bias to limit the number of connections of the nodes, so that a node filling session with few connections can be focused on."

```
20:24:33 ~ [es][n]@[Presuntuosidad(NA)]/[y1]: r
20:24:34 ~ [es][n]@[Rayo solar(NA)]/[y1]: r -l fr
20:24:37 ~ [fr][w]@[Géneral De Gaulle(NA)]/[y1]: r -t j
20:24:42 ~ [es][j]@[Desopilante(NA)]/[y1]: r -t v -l es
20:24:55 ~ [es][v]@[Darse de hostias con(NA)]/[y1]: r -f
20:24:58 ~ [es][n]@[Tabla optométrica(NA)*]/[y1]: r -s 0
20:24:58 ~ [es][n]@[Civilizaciones pretéritas(NA)]/[y1]: r -s 0
```

Note that this commands are **persistent**.

For users who want to continuously travel to a specific type of nodes throughout their session, the `-t` and `-l` commands are designed to persistently set filters for node types and languages, respectively. This means filters remain active across commands until explicitly altered or cleared.

To adjust or clear these filters, users can issue `r -t` or `r -l` without accompanying arguments, effectively resetting the respective filter to its default state.

Here's an example of this behavior:

<pre><code><strong>18:17:39 ~ [es][n]@[Radio de onda corta(NA)]/[y1]: r -t n
</strong>([!] Global filter set for `r` at 'n'; 'r -t' to unset)
18:19:58 ~ [es][n]@[Nota luctuosa(NA)]/[y1]:
18:20:00 ~ [en][n]@[Poor-mental-health-hour(NA)]/[y1]:
<strong>18:20:00 ~ [es][n]@[Estibador(NA)]/[y1]: r -l es
</strong>([!] Global filter set for `r` at 'es'; 'r -l' to unset)
18:20:09 ~ [es][n]@[Percepción(NA)]/[y1]:
18:20:11 ~ [es][n]@[Microbio(NA)]/[y1]:
<strong>18:20:11 ~ [es][n]@[Cambio climático(NA)]/[y1]: r -t
</strong>([!] Succesfully unset `r` global filter 'n')
<strong>18:20:23 ~ [es][v]@[Tirarse del pelo(NA)]/[y1]: r -l
</strong>([!] Succesfully unset `r` global filter 'es')
18:20:35 ~ [es][v]@[Cosificar(NA)]/[y1]:
</code></pre>
{% endtab %}

{% tab title="____" %}
**Instead of `set <field>`...**

If a field is set rawly (`y0`), it will be set.

```
01:43:34 ~ [es][j]@[Salvador(NA)]/[y1]: e0
01:45:11 ~ [es][j]@[Salvador(NA)]/[e0]:
```

**Instead of `ls ; <name>`...**

If a name existing in the Graph is rawly set (`Gallo`), it will be added to the current field (it has to be only one selected).

```
01:46:20 ~ [es][j]@[Salvador(NA)]/[e1]: Héroe
| Successfully binded 'Héroe'.
01:46:20 ~ [es][j]@[Salvador(NA)]/[e1]: ls
(SYS: Started edit-session at 01:47:46)
Showing 4/4 results.
| 1. Héroe  | 2. Ocultar de  | 3. Proteger  | 4. Proteger de
>>
```
{% endtab %}

{% tab title="set/unset" %}
The `set` and `unset` commands in the CLI are designed for configuring and clearing settings, respectively. The `set` command allows users to specify various settings, including field selections (like `y0`, `y1`, `e2`) and node characteristics (`language` and `type`, indicated by 2-character and 1-character codes, respectively).

If no specific settings are provided, it defaults to enabling all 'y' and 'e' prefixed fields. However, `set` will always clear the fielding for the current operation, no matter the parameters.

Conversely, the `unset` command is used to remove specific settings, functioning analogously to the `set` command but for clearing instead of setting parameters. If executed without any arguments, it removes all 'y' and 'e' prefixed fields, effectively resetting the field settings.

***

```
20:14:48 ~ [es][n]@[Interrogatorio(NA)]/[y1]: set e
20:15:10 ~ [es][n]@[Interrogatorio(NA)]/[e2/e1/e0]: unset e1
20:15:15 ~ [es][n]@[Interrogatorio(NA)]/[e2/e0]: set y0 y1 y2
20:15:20 ~ [es][n]@[Interrogatorio(NA)]/[y2/y1/y0]: unset
20:15:28 ~ [es][n]@[Interrogatorio(NA)]/[]:
```

```
20:17:16 ~ [es][n]@[Vulgarización(NA)]/[y1]: set j
20:17:24 ~ [es][j]@[Selecto(NA)]/[y1]: set fr
20:17:26 ~ [fr][w]@[Géneral De Gaulle(NA)]/[y1]: set jp
Invalid 'lang'.
20:17:26 ~ [fr][w]@[Géneral De Gaulle(NA)]/[y1]: set x
Invalid 'type'.
```
{% endtab %}

{% tab title="ls" %}
The `ls` command is used for listing information about the current node in the CLI, and it triggers the `LS_Interface` for an enhanced display. Bear in mind that if a single field is selected at placeholder, the `ls` command will trigger the `LS_Interface`, which allows for plenty of operations within a Node (mostly related about editing connections).&#x20;

_For more information, review the LS\_Interface information at \<AUX>\_Interface Class Doc._

***

```
20:31:09 ~ [es][n]@[Héroe de La Odisea(NA)]/[y2/y1/y0/e2/e1/e0]: ls
Showing 28/28 results.
| 1. Abnegado        | 11. Hazaña      | 21. Noble
| 2. Admirable       | 12. Hércules    | 22. Poderes ext...
| 3. Audacia         | 13. Héroe       | 23. Poderoso
| 4. Audaz           | 14. Implacable  | 24. Robar el fu...
| 5. Capacidad       | 15. Impávido    | 25. Sobrehumano
| 6. Centauro        | 16. Intrepidez  | 26. Triunfante
| 7. Extraordinario  | 17. Legendario  | 27. Valentía
| 8. Fuerte          | 18. Leyenda     | 28. Valiente
| 9. Ganador         | 19. Minotauro
| 10. Guerrero       | 20. Mágico
```

***

### **1. Functional Parameters**

* `-l` (`--lang`) and `-t` (`--type`)

We can instantly select the field we want to inspect by inputing it as an argument to the command.

<pre><code><strong>17:56:03 ~ [es][v]@[Portarse bien(NA)]/[y1]: ls y0
</strong>| The set field for the target node is empty.
>>
(SYS: Ended edit-session at 17:56:06)
17:56:05 ~ [es][v]@[Portarse bien(NA)]/[y0]:
</code></pre>

We can decide wether to display results of a specific `lang` or `type` by using the adequate flags `-l` (`--lang`) or `-t` (--`type`) .

<pre><code><strong>17:07:26 ~ [es][v]@[Estar como una regadera(NA)]/[y1]: ls -t n
</strong>| The set field for the target node is empty.
>>
(SYS: Ended edit-session at 17:10:41)
<strong>17:07:26 ~ [es][v]@[Estar como una regadera(NA)]/[y1]: ls -t v
</strong>(SYS: Started edit-session at 17:10:47)
Showing 6/6 results.
| 1. Estar como u...  | 3. Estar de la ...  | 5. Estar mal de...
| 2. Estar como u...  | 4. Estar loco       | 6. Estar turuleta
>>
</code></pre>

Note that this commands are **persistent**.

For users who want to continuously inspect a specific type of nodes throughout their session, the `-t` and `-l` commands are designed to persistently set filters for node types and languages, respectively. This means filters remain active across commands until explicitly altered or cleared.

To adjust or clear these filters, users can issue `ls -t` or `ls -l` without accompanying arguments, effectively resetting the respective filter to its default state.

Here's an example of this behavior:

```
14:42:56 ~ [en][n]@[Fucktard(NA)]/[e1]: ls
(SYS: Started edit-session at 14:47:43)
Showing 2/2 results.
| 1. Estupidez  | 2. Stupidity
>>
(SYS: Ended edit-session at 14:47:45)
14:42:56 ~ [en][n]@[Fucktard(NA)]/[e1]: ls -l es
([!] Global filter set at 'es'; 'ls -l' to unset)
(SYS: Started edit-session at 14:47:49)
Showing 1/2 results.
| 1. Estupidez
>>
(SYS: Ended edit-session at 14:47:51)
14:42:56 ~ [en][n]@[Fucktard(NA)]/[e1]: ls
([!] Global filter set at 'es'; 'ls -l' to unset)
(SYS: Started edit-session at 14:47:54)
Showing 1/2 results.
| 1. Estupidez
>>
(SYS: Ended edit-session at 14:47:55)
14:42:56 ~ [en][n]@[Fucktard(NA)]/[e1]: ls -l
(SYS: Started edit-session at 14:47:57)
Showing 2/2 results.
| 1. Estupidez  | 2. Stupidity
>>
```

### **2. Aesthetic Parameters**

* `-d` (`--details`)

For a detailed view of node information, utilize the `-d` or `--details` option. This flag is most effective when used alone, as it provides a comprehensive display of each node's details. The use of `--width`, `--abbr`, or `--ncol` in conjunction with this flag is not necessary, as `--details` already optimizes the display format for detailed information, overriding the need for specifying column width (`--width`), abbreviation length (`--abbr`), or the number of columns (`--ncol`).

```
20:31:09 ~ [es][n]@[Héroe de La Odisea(NA)]/[y2/y1/y0/e2/e1/e0]: ls -d
01) [es][j][Abnegado][NA]....(0/25/0 - 0/110/0)
02) [es][j][Admirable][NA]....(0/35/0 - 0/66/0)
03) [es][n][Audacia][NA]....(0/32/0 - 0/146/0)
...
```

* `-w` (`--width`)

To customize the column width in the display, use the `-w` or `--width` option followed by your preferred width value. This setting allows you to adjust how much information fits across the screen.

Default for the system is set to `width=35`.

```
20:31:09 ~ [es][n]@[Héroe de La Odisea(NA)]/[y2/y1/y0/e2/e1/e0]: ls -w 10
Showing 28/28 results.
| 1. Ab...  | 11. H...  | 21. N...
| 2. Ad...  | 12. H...  | 22. P...
| 3. Au...  | 13. H...  | 23. P...
...

20:31:09 ~ [es][n]@[Héroe de La Odisea(NA)]/[y2/y1/y0/e2/e1/e0]: ls -w 50
Showing 28/28 results.
| 1. Abnegado        | 11. Hazaña      | 21. Noble
| 2. Admirable       | 12. Hércules    | 22. Poderes extraordinarios
| 3. Audacia         | 13. Héroe       | 23. Poderoso
...
```

* `-a` (`--abbr`)

For shortening node names, the `-a` or `--abbr` flag can be applied, followed by the maximum character length. This is useful for simplifying and tidying up the display, especially when dealing with longer node names.

```
20:31:09 ~ [es][n]@[Héroe de La Odisea(NA)]/[y2/y1/y0/e2/e1/e0]: ls -a 7
Showing 28/28 results.
| 1. Abnegad...   | 11. Hazaña      | 21. Noble
| 2. Admirab...   | 12. Hércule...  | 22. Poderes...
| 3. Audacia      | 13. Héroe       | 23. Poderos...
...
```

* `-p` (`--stop`)

To cap the number of nodes shown, the `-p` or `--stop` option can be utilized with a specified maximum count. This is particularly helpful for managing the quantity of data presented at once.

```
20:31:09 ~ [es][n]@[Héroe de La Odisea(NA)]/[y2/y1/y0/e2/e1/e0]: ls -t 8
Showing 8/28 results.
| 1. Abnegado   | 4. Audaz      | 7. Extraordinario
| 2. Admirable  | 5. Capacidad  | 8. Fuerte
| 3. Audacia    | 6. Centauro
20:31:09 ~ [es][n]@[Héroe de La Odisea(NA)]/[y2/y1/y0/e2/e1/e0]:
```

* `-c` (`--ncol`)

For configuring the layout with a specific number of columns, use the `-c` or `--ncol` option, followed by the desired number of columns. This allows for a more structured and organized presentation of nodes.

Default for the system is set to `ncol=4`.

```
20:31:09 ~ [es][n]@[Héroe de La Odisea(NA)]/[y2/y1/y0/e2/e1/e0]: ls -c 4
Showing 28/28 results.
| 1. Abnegado        | 8. Fuerte       | 15. Impávido    | 22. Poderes ext...
| 2. Admirable       | 9. Ganador      | 16. Intrepidez  | 23. Poderoso
| 3. Audacia         | 10. Guerrero    | 17. Legendario  | 24. Robar el fu...
...
```

* `-r` (`--shuffle`)

To randomize the order in which nodes are displayed, the `-r` or `--shuffle` option can be employed. This feature adds an element of variability and can be useful in viewing the nodes from different perspectives.

```
20:31:09 ~ [es][n]@[Héroe de La Odisea(NA)]/[y2/y1/y0/e2/e1/e0]: ls -r
Showing 28/28 results.
| 1. Capacidad       | 11. Hércules        | 21. Sobrehumano
| 2. Hazaña          | 12. Admirable       | 22. Audacia
| 3. Guerrero        | 13. Abnegado        | 23. Minotauro
...
```
{% endtab %}

{% tab title="vg" %}
_Shows the examples for the current placeholder node, if any, and enters the VG (from verbi gracia) pseudo-interface._

_For more information, review the VG\_Interface information at \<AUX>\_Interface Class Doc._
{% endtab %}

{% tab title="details" %}
Shows the size of the fields for the current node.

***

```
01:07:03 ~ [es][v]@[Desprestigiar(NA)]/[y1]: details
| Synset sizes (y0 = 0, y1 = 15, y2 = 0)
| Semset sizes (e0 = 0, e1 = 49, e2 = 0)
01:07:03 ~ [es][v]@[Desprestigiar(NA)]/[y1]:
```
{% endtab %}
{% endtabs %}

## 2. Editing commands

{% tabs %}
{% tab title="new" %}
Creating a node consists on writing `new` and filling some fields. And that's all actually.

***

```
01:20:33 ~ [es][n]@[(NA)]/[y1]: new Mentirosillo
> lang  : es
> type  : n
> lemma :
| Succesfully created.
01:24:17 ~ [es][n]@[Mentirosillo(NA)]/[y1]:
```
{% endtab %}

{% tab title="edit" %}
We can edit the current node hash properties by using `edit <hash_attr> <new_value>` . In case the new hash configuration matched an already existing node, it merges them using the `merge_nodes` function from `Graph` implementation.

***

```
12:27:22 ~ [es][n]@[Recoveco(NA)]/[y1]: cd Banco
| Do you mean ...
|   1) [es][n]@[Banco(Edificio)]
|   2) [es][n]@[Banco(NA)]
|   3) [es][n]@[Banco(Asiento)]
| (Press Enter without any input to exit)
>> 2
12:27:36 ~ [es][n]@[Banco(NA)]/[y1]: edit lemma Asiento
The conformed node matched an existing one, and has been merged.
12:27:46 ~ [es][n]@[Banco(Asiento)]/[y1]: cd Banco
| Do you mean ...
|   1) [es][n]@[Banco(Edificio)]
|   2) [es][n]@[Banco(Asiento)]
| (Press Enter without any input to exit)
>>
```


{% endtab %}

{% tab title="sug" %}
This command is designed to facilitate the suggestion process for connecting nodes within a network. By examining a specific node and its associated field, the command dynamically generates recommendations for potential connections, derived from the node's neighbors and their relationships.

**Subcommands**

Users are prompted to accept or reject suggestions dynamically, with the option to specify a particular field for binding or to exit the session.

* **Accepting Suggestions (`Y` or `y`)**:
  * By responding with `Y` or `y`, the user indicates acceptance of the suggested connection using the current field under consideration. This action binds the current node to the suggested node, reinforcing the network's structure based on the predetermined logic specific to that field.
* **Rejecting Suggestions (`N` or `n`)**:
  * Responding with `N` or `n` signifies rejection of the current suggestion. The session then progresses to the next suggestion without making any changes to the network, allowing the user to skip suggestions that are deemed irrelevant or unhelpful.
* **Specifying a Field for Binding (`y0`, `y1`, ..., `e1`, `e2`)**:
  * The user can specify a particular field for the connection by entering one of the field codes (`y0`, `y1`, ..., `e1`, `e2`). This advanced option allows for greater specificity in how nodes are connected, tailoring the network's evolution to the user's insight into the relational dynamics between nodes.
* **Exiting the Session (`q` or `exit`)**:
  * At any point, the user can choose to exit the suggestion session by entering `q` or `exit`. This command immediately terminates the session, allowing the user to effectively conclude their interaction without proceeding through the entirety of the suggestions queue.

**Algorithm Specific Logic**

* **Field `y0`**:
  * The command targets neighbors linked through the `y1` relationship.
  * It then explores these neighbors to find their connections via `y0`, effectively looking one step beyond direct neighbors to suggest second-degree connections that share a `y0` link.
* **Field `y1`**:
  * An extensive search is performed starting from neighbors connected by `y1`.
  * It identifies direct `y1` neighbors, then explores their `y1` neighbors, and further extends to those second-degree neighbors' own `y1` connections.
  * Additionally, it considers the `y1` connections of `y2` neighbors and the `y` connections of `e` neighbors, prioritizing those with a centrality score above 35%, indicating strong relevance or intersection with the original node.
* **Field `y2`**:
  * Focuses on the `y1` neighbors of the current node, seeking out their `y2` connections to suggest a broader but directly related network circle.
* **Fields `e0`, `e1`, `e2`**:
  * These fields share a similar approach, tailored to the specific `e` variant:
    * The process starts by identifying `y1` neighbors, then selecting their respective `e0`, `e1`, or `e2` connections.
    * Additionally, it looks into the `e` neighbors of the current node and gathers their `e` connections, broadening the scope of potential suggestions.

***

<pre><code><strong>03:25:28 ~ [es][n]@[Luna(NA)]/[y1]: sug
</strong>(SYS: Started sug-session at 03:25:32)
| [es][n]@[Alumbre(NA)] [Y/N] >>
<strong>| [es][n]@[Espejismo(NA)] [Y/N] >> e1
</strong>| Succesfully binded node to 'e1' field.
<strong>| [es][n]@[Ilusión magnífica(NA)] [Y/N] >> y
</strong>| Succesfully binded node to 'y' field.
| [es][n]@[Dechado(NA)] [Y/N] >> q
(SYS: Ended sug-session at 03:26:57)
03:25:28 ~ [es][n]@[Luna(NA)]/[y1]:
</code></pre>
{% endtab %}

{% tab title="pin/unpin" %}
Sets the `favorite` hash attribute of the current node to either True or False by respectively calling the command `pin` or `unpin` . This will be useful when filtering nodes, to find the ones we love the most (for example, via `r -f`).

Favorite nodes are represented with an asterisk at the end of the compact representation.

***

```
14:30:12 ~ [es][n]@[Tabla optométrica(NA)]/[y1]: pin
14:30:17 ~ [es][n]@[Tabla optométrica(NA)*]/[y1]: unpin
14:30:20 ~ [es][n]@[Tabla optométrica(NA)]/[y1]:
```
{% endtab %}

{% tab title="del" %}
Deletes from the graph the current node set at the placeholder.

***

```
00:45:06 ~ [es][n]@[Persona(NA)]/[y1]: del
SYS: Are you sure you want to remove this node (1179 edges)? [Y/N]
>>
Deletion process aborted.
00:45:06 ~ [es][n]@[Persona(NA)]/[y1]:
```
{% endtab %}
{% endtabs %}

## 3. Advanced Commands

{% tabs %}
{% tab title="grab" %}
The `grab` command in the CLI is versatile, offering two modes of operation. When used with an argument (i.e., `grab [node_name]`), it targets and grabs a specific node named in the argument. If the specified node doesn’t match any existing nodes, the command initiates a selection process, suggesting similar nodes for the user to choose from. When used without an argument (`grab`), it simply grabs the current node in the context.

Nodes can also be grabbed within the GB\_Interface and the LS\_Interface.

***

```
21:15:02 ~ [es][n]@[Oveja(NA)]/[y1]: grab
21:15:02 ~ [es][n]@[Oveja(NA)]/[y1]: grab Cordero
```
{% endtab %}

{% tab title="grabbed" %}
The `grabbed` command is designed to display all the nodes that have been grabbed so far and activates the GB\_Interface. This interface is particularly useful for managing the nodes that are marked for use in subsequent operations, like the `run` command.

_For more information, review the GB\_Interface information at \<AUX>\_Interface Class Doc._

***

```
21:15:02 ~ [es][n]@[Oveja(NA)]/[y1]: grabbed
(SYS: Started edit-session at 21:16:17)
| Grabbed 4 nodes:
|   1) es-n:Cordero(NA)  : 1.0000 | ████████████████████
|   2) es-n:Oveja(NA)    : 0.8980 | ██████████████████
|   3) es-n:Cabra(NA)    : 0.7830 | ████████████████
|   4) es-j:Exterior(NA) : 0.0080 |
>>
```
{% endtab %}

{% tab title="run" %}
The `run` command works closely with the list of grabbed nodes. It incorporates all the display formatting options of the `ls` command, such as column width and order shuffling.

Additionally, it introduces the `-f` or `--fielding` flag, a boolean option that, when included, restricts the search to the nodes within the current fielding at the placeholder. Essentially, `run` executes a Density Search algorithm on the grabbed nodes, leveraging these formatting and fielding features for an optimized search experience.

The `k` parameter can be defined as a flag (1st case) or inputed when the function asks for it (2nd case). This is just a matter of ergonomy.

***

<pre><code><strong>21:15:02 ~ [es][n]@[Oveja(NA)]/[y1]: run 2 -w 30 -a 10
</strong>(SYS: Started search-session at 21:19:15)
Showing 47/47 results.
| 1. Pastor         | 17. Multitudin...  | 33. Bucle
| 2. Cancilla       | 18. Pedestre       | 34. Acaracolad...
| 3. Lozano         | 19. Esquilar       | 35. Cabeza hue...
...
(SYS: Ended search-session at 21:19:15)
21:15:02 ~ [es][n]@[Oveja(NA)]/[y1]:
</code></pre>

<pre><code><strong>21:15:02 ~ [es][n]@[Oveja(NA)]/[y1]: run -w 30 -a 10
</strong>(SYS: Started search-session at 21:20:35)
<strong>>> MSL (Minimum Shared Linkage) [int] : 2
</strong>Showing 47/47 results.
| 1. Pastor         | 17. Multitudin...  | 33. Bucle
| 2. Cancilla       | 18. Pedestre       | 34. Acaracolad...
| 3. Lozano         | 19. Esquilar       | 35. Cabeza hue...
...
(SYS: Ended search-session at 21:20:38)
21:15:02 ~ [es][n]@[Oveja(NA)]/[y1]:
</code></pre>
{% endtab %}

{% tab title="save" %}
The `save` command is a straightforward utility for saving the current state of the graph. By default, it saves the file as 'data.txt', but it allows for customization of the filename by providing a different name as an argument (e.g., `save custom_filename.txt`), enabling users to easily manage multiple saved states or versions of their graph.

***

```
21:15:02 ~ [es][n]@[Oveja(NA)]/[y1]: save 
```

```
21:15:02 ~ [es][n]@[Oveja(NA)]/[y1]: save custom_filename.txt
```
{% endtab %}

{% tab title="term" %}
The `do_term` method provides an interactive Python terminal within the SK\_Interface command-line environment. This feature is designed primarily for advanced users or administrators who need direct access to the underlying Python objects and methods for maintenance, debugging, or advanced customization.

**Functionality**

* **Access to SKComponents**: provides direct access to SKComponents objects and methods. This includes immediate access to `Node` and `Graph` (`G`) objects, enabling advanced manipulation and querying capabilities within the system.
  * `Node`
    * **Node Representation:** customize node displays using `Node` class methods like `compress`, `toggle_back_labels`, `expand`, and `toggle`.
  * `Graph (G)`
    * **Node Visualization and Interaction**: find, select, and set nodes as variables with ease, including the use of the `random`, `find` and `select` methods for random node selection.
    * **Graph Filtering:** apply filters for targeted exploration using the `char_count` , `word_count`, `contains_word`, `contains`, `starts_with` and `ends_with` filters.
      * **Editing: e**dit node properties such as name, type, lemma, language, and favorites, offering detailed control over node hash attributes through the `edit` command.
* **Enhanced User Experience**: enjoy improved clarity in viewing longexamples and handling long names, thanks to the terminal's format.
* **Interactive Result Display**: automatically print outputs of commands for an interactive experience, akin to a standard Python shell.
* **Database Operations**: manually save the database to ensure all modifications are effectively captured and stored.
* **Simple Exit Mechanism**:
  * Exit the terminal mode easily by typing `exit`, `quit`, or `q`.

***

<pre><code><strong>01:25:08 ~ [es][n]@[Auxilio(NA)]/[y1]: term
</strong>Python terminal. Access to SKComponents objects and methods.
Type "Node" or "Graph" to inspect objects and "exit" to leave.
>>> G
Graph(size=28752)
>>> G.contains_word('mano')
NodeSet(size=119)
>>> G.contains_word('mano').random()
Node(es-v:Ensuciarse las manos(NA))[synset0=0, semset0=0, synset1=14, semset1=4, synset2=0, semset2=0, examples=1]
>>> Node.compress()
&#x3C;class 'src.skcomponents.sknode.Node'>
>>> G.contains_word('mano').random()
Node(es-j:Inhumano(NA))
>>>
</code></pre>

***

**Warning on Safety**

The `do_term` method, while a powerful tool within SK\_Interface, poses significant risks due to its use of the `exec` function for executing arbitrary Python code. This capability could lead to unintended system alterations or security vulnerabilities if mishandled. Therefore, it is advised for use exclusively by administrators or knowledgeable users who fully grasp its implications. Caution is paramount, and it's recommended to employ this feature only in controlled and secure settings.
{% endtab %}
{% endtabs %}
