Skip to content

Commit

Permalink
Give an option to NOT include analysis in vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
fbanados committed Nov 4, 2024
1 parent b22fe55 commit a8e9c1e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/morphodict/cvd/management/commands/builddefinitionvectors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import logging
from argparse import ArgumentParser
from argparse import ArgumentParser, BooleanOptionalAction
from contextlib import contextmanager
from os import fspath

Expand All @@ -27,7 +27,18 @@ def add_arguments(self, parser: ArgumentParser):
parser.add_argument("--output-file", default=definition_vectors_path())
parser.add_argument("--debug-output-file")

def handle(self, output_file, debug_output_file, **options):
parser.add_argument(
"--include-analysis-in-vector",
action=BooleanOptionalAction,
default=True,
help="""
Include Raw Analysis in vector definitions for entries, by performing a relabelling to plain english.
""",
)

def handle(
self, output_file, debug_output_file, include_analysis_in_vector, **options
):
logger.info("Building definition vectors")
logger.info(output_file)

Expand All @@ -51,7 +62,9 @@ def handle(self, output_file, debug_output_file, **options):
news_vectors,
unknown_words,
analysis=(
d.wordform.raw_analysis[2] if d.wordform.raw_analysis else []
d.wordform.raw_analysis[2]
if d.wordform.raw_analysis and include_analysis_in_vector
else []
),
)
debug_output(
Expand Down

0 comments on commit a8e9c1e

Please sign in to comment.