{"id":19457654,"url":"https://github.com/liaad/entityrelationsnelson","last_synced_at":"2025-02-25T11:40:54.034Z","repository":{"id":71824960,"uuid":"72737048","full_name":"LIAAD/EntityRelationsNelson","owner":"LIAAD","description":null,"archived":false,"fork":false,"pushed_at":"2017-09-25T11:49:05.000Z","size":75,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-08T01:48:04.263Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LIAAD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-03T11:05:58.000Z","updated_at":"2016-11-23T22:43:53.000Z","dependencies_parsed_at":"2023-09-11T09:15:09.508Z","dependency_job_id":null,"html_url":"https://github.com/LIAAD/EntityRelationsNelson","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIAAD%2FEntityRelationsNelson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIAAD%2FEntityRelationsNelson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIAAD%2FEntityRelationsNelson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIAAD%2FEntityRelationsNelson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LIAAD","download_url":"https://codeload.github.com/LIAAD/EntityRelationsNelson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240662325,"owners_count":19837366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T17:23:17.574Z","updated_at":"2025-02-25T11:40:53.998Z","avatar_url":"https://github.com/LIAAD.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EntityRelationsNelson\r\nFramework to clustering relations between named entities based on the context. Also it can evaluate the clustering results by constraint pairs. It is accepted only non-annotated texts as input.\r\n\r\nPhases:\r\n 1. Initialization\r\n 2. Preprocessing\r\n   1. Named Entity Extraction\r\n   2. Named Entity Pairing\r\n 3. Clustering\r\n 4. Evaluation\r\n\r\n## INITIALIZATION\r\n\r\nFirst, it is essential to set working directory, using `setwd`, where files are.\r\nSecond, load the following R files:\r\n* `entity-processing`\r\n* `logger`\r\n* `debugger`\r\n* `context-processing`\r\n* `relation-detection`\r\n* `analysis`\r\n* `relation-extraction`\r\n* `pair-treatment`\r\n* `evaluation`\r\n\r\nThird, set some parameters in the environment:\r\n* `data.type`\r\n  * `\"folder\"` if input is a folder with texts\r\n  * `\"text\"` if input is a given text\r\n* `textual.content`\r\n  * a string indicating the folder path when `data.type=\"folder\"`\r\n  * a string with the exact content when `data.type=\"text\"`\r\n* `idiom` - defined language to named entity recognition and stemming (`\"pt\"` is the only possible by now)\r\n* `what.context`\r\n  * `\"all\"` if it is the complete context to extract\r\n  * `\"between\"` if it is the intermediate context to extract\r\n* `only.consecutive`\r\n  * `TRUE` allows pairing involving only consecutive named entities on the same sentence\r\n  * `FALSE` allows pairing involving every named entities on the same sentence\r\n* `exceptions` - vector with named entities to ignore on pairing process and to remove on corpus mapping \r\n* `use.stemming` - `TRUE` / `FALSE`\r\n\r\n\r\n\r\n## PREPROCESSING\r\n\r\n### NAMED ENTITY EXTRACTION\r\n\r\nTo know where named entities are on a text, there are two ways:\r\n* `extractEntities` function locates named entities on input text(s), returning a data frame with 5 columns (please install `PAMPO` package and read respective documentation)\r\n * `source` - the path where text files are or the textual content\r\n * `to` - the CSV file name where named entity information is written. If empty no file is outputted\r\n* `fileExtraction` function gets information of named entities directly from a CSV file following the structure generated by `PAMPO`\r\n * `file` - the CSV file title\r\n * `file.header` - boolean value indicating if CSV file has header\r\n * `file.separator` - character(s) used as separator among attributes of each instance\r\n\r\nSome named entity cleaning is done with `cleanEntities` function where `exceptions` are removed too.\r\n* `entities` is the data frame with named entity information\r\n* `special.cases` is a vector with row numbers from specific instances to remove\r\n\r\nThe returned data frame has the same structure but without the retired records.\r\n\r\n\r\nIf it is required only named entities, forming certain numbers on the sentences, it is required to use `countEntities` function firstly:\r\n* `entity.locations` is the data frame with information about named entities and respective positions by `File`, `Paragraph` and `Sentence`\r\n\r\nThe returned data frame has `File`, `Paragraph`, `Sentence` and `occurrences` that counts named entities in the position defined by the previous three attributes.\r\n\r\n\r\nThen `filterSentences` function allows to preserve information of named entities, where this ones form certain numbers on respective sentences:\r\n* `entity.locations` - data frame with information about named entities and respective positions by `File`, `Paragraph` and `Sentence`\r\n* `sentence.entities` - data frame with the named entity occurrences per sentence \r\n* `entity.number` - a vector with the required numbers of named entities on sentences\r\n\r\nThe returned data frame has the same structure but without named entities escaping from filtering.\r\n\r\n### NAMED ENTITY PAIRING\r\n\r\nSuch way that availed named entities are used to pairing, it is required to use `scanIteratively` or `scanEfficiently` where both has the same arguments:\r\n* `entities` - a data frame with the attributes returned on recognition stage\r\n* `relation.file` - a string, when it is not empty (value by default), to name a RDS file with every encountered pairs and respective contexts\r\n* `order.significance`\r\n * `TRUE` - elements of named entity pairs are displayed by appearance order on sentence\r\n * `FALSE` - the elements are displayed by lexicographic order\r\n \r\nThe data frame that results has `entity1.name` and `entity2.name` attributes as left and right elements of pairs. Also it has `context` attribute that is a string for each pair and it is defined according `what.context` parameter. The number of returned pairs can be influenced by `only.consecutive` parameter.\r\n\r\nTo avoid repeated pairs and to join every contexts with pair in common, `aggregateContexts` function is essential:\r\n* `relations` - data frame with the pairs of named entities and the extracted contexts\r\n\r\nThe returned data frame, with the same attributes as the argument, has distinct pairs and a list with every contexts for each pair.\r\n\r\n\r\n\r\n## CLUSTERING\r\n\r\nPicking named entity pairs and respective contexts, pair clustering can be executed with `defineClustering`:\r\n* `pair.contexts` - data frame with named entity pairs and lists of contexts\r\n* `weight.type` - term weighting (`\"TF/IDF\"` by default) (try `help(DocumentTermMatrix)` to know another options)\r\n* `distance.measure` - measure (`\"euclidean\"` by default) to use on `dist` function (try `help(dist)` to know another options)\r\n* `dist.args` - list of arguments (empty by default) to use on `dist` function (try `help(dist)` to know the arguments)\r\n* `algorithm.type` - clustering algorithm to use where the possibilities are `\"hierarchical\"` and `\"k-means\"` (being this one by default)\r\n* `hclust.args` - list of arguments (`list(method=\"ward.D\")` by default) to use on `hclust` function (try `help(hclust)` to know the arguments)\r\n* `kmeans.args` - list of arguments (`list(algorithm=\"Lloyd\")` by default) to use on `kmeans` function (try `help(kmeans)` to know the arguments)\r\n* `cluster.percentage` - number of clusters required based on the proportion of pairs (`0.1` by default)\r\n* `remove.stopwords` - stopwords are removed on corpus mapping (where `use.stemming` and `exceptions` parameters also are used) if it is allowed (`TRUE` by default) \r\n* `words.number` - number of the most frequent words from each cluster that are used as labels (`1` by default)\r\n\r\nThe obtained data frame has `entity1.name`, `entity2.name`, `cluster.key` and `semantic.label`. This attributes correspond to the left and right elements from clustered pairs, the numbers of clusters where pairs are assigned and the labels that distinguish semantic relations between pairs.\r\n\r\n\r\n\r\n## EVALUATION\r\n\r\nAfter pairs be clustered, it is possible to evaluate the result by F1. Using `evaluateClustering`, it is necessary to give values for the arguments:\r\n* `clusters` - data frame with named entity pairs (`entity1.name` and `entity2.name`), identifications of respective clusters (`cluster.key`) and the word sets that characterize semantic relations (`semantic.label`)\r\n* `must.link` - vectors with strings of constraint pairs, where elements are named entity pairs and it could share the same cluster. The named entity strings of each pair element should be disposed, where left element is followed by right element like on `clusters` data frame. Both elements also should be followed.\r\n* `cannot.link` - vectors with strings of constraint pairs, where elements are named entity pairs and it couldn't share the same cluster. The named entity strings of each pair element should be disposed, where left element is followed by right element like on `clusters` data frame. Both elements also should be followed.\r\n* `logging` - if `TRUE`, constraint pairs, respective alerts of matching and values of precision/recall/F1 are showed. Otherwise, nothing is showed.\r\nA value of double type with F1 score is returned.\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliaad%2Fentityrelationsnelson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliaad%2Fentityrelationsnelson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliaad%2Fentityrelationsnelson/lists"}