Skip to content

Commit

Permalink
#70 addresed, #73 done, #68 done
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Jun 4, 2023
1 parent 7f118fa commit 77d62a2
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 52 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Infer sentiment attitudes from a mass-media document(s).

Using the `BERT` fine-tuned model version:
```bash
python3.6 infer_bert.py --from-files ../data/texts-inosmi-rus/e1.txt \
python3.6 -m arelight.run.infer.py --from-files ../data/texts-inosmi-rus/e1.txt \
--labels-count 3 \
--terms-per-context 50 \
--tokens-per-context 128 \
Expand All @@ -49,7 +49,7 @@ python3.6 infer_bert.py --from-files ../data/texts-inosmi-rus/e1.txt \
```
From `CSV` file (you need to have `text` column; sentence parser could be disabled):
```
python3.6 infer_bert.py \
python3.6 arelight.run.infer.py \
--from-dataframe ../data/examples.csv \
--entities-parser bert-ontonotes \
--terms-per-context 50 \
Expand All @@ -66,15 +66,15 @@ python3.6 infer_bert.py \
From list of files
```bash
python3.6 serialize_bert.py --from-files ../data/texts-inosmi-rus/e1.txt \
python3.6 arelight.run.serialize.py --from-files ../data/texts-inosmi-rus/e1.txt \
--entities-parser bert-ontonotes \
--terms-per-context 50 \
--sentence-parser ru \
-o output/e1
```
From `CSV` file (you need to have `text` column; sentence parser could be disabled):
```
python3.6 serialize_bert.py \
python3.6 arelight.run.serialize.py \
--from-dataframe ../data/examples.csv \
--entities-parser bert-ontonotes \
--terms-per-context 50 \
Expand All @@ -86,7 +86,7 @@ python3.6 serialize_bert.py \
<img src="docs/samples-bert.png">
</p>

## Papers
## Reference

* [Nicolay Rusnachenko: Language Models Application in Sentiment Attitude Extraction Task (2021) [RUS]](https://nicolay-r.github.io/website/data/rusnachenko2021language.pdf)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 1 addition & 29 deletions examples/args/common.py → arelight/run/args/common.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import importlib

from arekit.contrib.source.rusentiframes.collection import RuSentiFramesCollection
from arekit.contrib.source.rusentiframes.labels_fmt import RuSentiFramesLabelsFormatter, \
RuSentiFramesEffectLabelsFormatter
from arekit.contrib.source.rusentiframes.types import RuSentiFramesVersionsService, RuSentiFramesVersions
from arekit.contrib.utils.processing.lemmatization.mystem import MystemWrapper

from arelight.pipelines.demo.labels.base import NegativeLabel, PositiveLabel
from arelight.pipelines.items.entities_default import TextEntitiesParser
from arelight.pipelines.items.entities_ner_dp import DeepPavlovNERPipelineItem
from arelight.run.args.base import BaseArg
from arelight.samplers.types import SampleFormattersService

from examples.args.base import BaseArg
from examples.entities.types import EntityFormattersService


class InputTextArg(BaseArg):

Expand All @@ -31,28 +25,6 @@ def add_argument(parser, default):
help='Input text for processing')


class FramesColectionArg(BaseArg):

@staticmethod
def read_argument(args):
if args.frames == "ruattitudes-20":
return RuSentiFramesCollection.read_collection(
version=RuSentiFramesVersions.V20,
labels_fmt=RuSentiFramesLabelsFormatter(
pos_label_type=PositiveLabel, neg_label_type=NegativeLabel),
effect_labels_fmt=RuSentiFramesEffectLabelsFormatter(
pos_label_type=PositiveLabel, neg_label_type=NegativeLabel))

@staticmethod
def add_argument(parser, default="ruattitudes-20"):
parser.add_argument('--frames',
dest='frames',
type=str,
default=default,
nargs='?',
help='Collection for frames annotation in text (Default: {})'.format(default))


class PredictOutputFilepathArg(BaseArg):

@staticmethod
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/args/train.py → arelight/run/args/train.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from examples.args.base import BaseArg
from arelight.run.args.base import BaseArg


class EpochsCountArg(BaseArg):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from arekit.contrib.utils.entities.formatters.str_simple_sharp_prefixed_fmt import SharpPrefixedEntitiesSimpleFormatter
from arekit.contrib.utils.entities.formatters.str_simple_uppercase_fmt import SimpleUppercasedEntityFormatter

from examples.entities.types import EntityFormatterTypes
from arelight.run.entities.types import EntityFormatterTypes


def create_entity_formatter(fmt_type, create_russian_pos_tagger_func=None):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from enum import Enum

from examples.utils import EnumConversionService
from arelight.run.utils import EnumConversionService


class EntityFormatterTypes(Enum):
Expand Down
11 changes: 4 additions & 7 deletions examples/infer_bert.py → arelight/run/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
from arelight.pipelines.demo.infer_bert_rus import demo_infer_texts_bert_pipeline
from arelight.pipelines.items.backend_brat_html import BratHtmlEmbeddingPipelineItem
from arelight.pipelines.items.utils import input_to_docs

from examples.args import common
from examples.args import train
from examples.args import const
from examples.entities.factory import create_entity_formatter
from examples.entities.types import EntityFormatterTypes
from examples.utils import create_labels_scaler, read_synonyms_collection
from arelight.run.args import common, const, train
from arelight.run.entities.factory import create_entity_formatter
from arelight.run.entities.types import EntityFormatterTypes
from arelight.run.utils import create_labels_scaler, read_synonyms_collection

if __name__ == '__main__':

Expand Down
5 changes: 1 addition & 4 deletions examples/serialize_bert.py → arelight/run/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
from arelight.doc_ops import InMemoryDocOperations
from arelight.pipelines.annot_nolabel import create_neutral_annotation_pipeline
from arelight.pipelines.items.utils import input_to_docs
from arelight.run.args import common
from arelight.samplers.bert import create_bert_sample_provider
from arelight.samplers.types import BertSampleProviderTypes

from examples.args import const, common
from examples.entities.factory import create_entity_formatter
from examples.utils import read_synonyms_collection


if __name__ == '__main__':

Expand Down
2 changes: 1 addition & 1 deletion examples/train_bert.py → arelight/run/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from arekit.common.pipeline.base import BasePipeline

from arelight.pipelines.items.train_bert import BertFinetunePipelineItem
from examples.args import train, common, const
from arelight.run.args import common, train, const

if __name__ == '__main__':

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion arelight/samplers/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from enum import Enum

from examples.utils import EnumConversionService
from arelight.run.utils import EnumConversionService


class BertSampleProviderTypes(Enum):
Expand Down
2 changes: 1 addition & 1 deletion download.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from arekit.common import utils

from examples.args import const
from arelight.run.args import const


def download_examples_data():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_requirements(filenames):

setup(
name='arelight',
version='0.23.1',
version='0.23.2',
description='About Mass-media text processing application for your '
'Relation Extraction task, powered by AREkit.',
url='https://github.com/nicolay-r/ARElight',
Expand Down

0 comments on commit 77d62a2

Please sign in to comment.