This repository is for the source codes of master thesis: "Optimizing Domain-specific Regulation Comparison with Semantic Text Matching & Relation Extraction", the goals of which is to examine the potential for Natural Language Processing technologies to optimize current manual regulation maintenance process in an automotive manufacturer enterprise and proposes concepts of architecture and implementation of a text-matching as well as a relation extraction mechanism that integrates entity recognition to extract key information that is interested by experts from the regulations that could accelerate the manual information processes.
The directory includes following files:
- main
- CorpusGenerator.py
- config
- config.yml
- trained models
- para_similarity.py
- TW_EU_tf_idf.py
- TW_EU_LSI.py
- TW_EU_w2v.py
- TW_EU_d2v.py
- Evaluate.py
- evaluation_plot.ipynb
Paragraph matching mechanism supports four alternive text representation approaches:
- TF-IDF
- LSI
- word2vec
- doc2vec
correspondent configurations can be done under config YAML file in config directory. Supported Configuations include:
- File location
- data folder
- document pairing file folder
- result output folder
- groud truth folder
- list of approaches that need to be generated in one execution
- Preprocessing approaches (boolean values)
- bigram / trigram
- porter stemming / wordnet lemmatization
- Modeling For each approach:
- parameters
- similarity metrics 1. cosine similarity 2. word mover distance
- if the embedding needs to be pretrained
an example can be seen under example config
modelling of relation extration consists of following steps:
- Recognition of defined "Quantitative Value" Entity: pretrained customized SpaCy model under "ner" folder
- extraction of tokens with "noun" as Part of Speech under same tree in dependency parsing with named entity in the last step and pairing with named entity
- classification of above entity pairs into four defined classes: MinValue, MaxValue, IsValue, NoRelation
The architecture is summarized as follow:
A model consisting of BERT embedding and Bi-LSTM is trained by train.py by calling help functions in Relation_Extraction.py Demo is available at [example config](relation_extraction/Relation Extraction.ipynb)