infinity-context 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- infinity_context-0.1.0.dist-info/METADATA +239 -0
- infinity_context-0.1.0.dist-info/RECORD +1053 -0
- infinity_context-0.1.0.dist-info/WHEEL +5 -0
- infinity_context-0.1.0.dist-info/entry_points.txt +9 -0
- infinity_context-0.1.0.dist-info/licenses/LICENSE +201 -0
- infinity_context-0.1.0.dist-info/top_level.txt +8 -0
- infinity_context_adapters/__init__.py +1 -0
- infinity_context_adapters/cognee/__init__.py +5 -0
- infinity_context_adapters/cognee/adapter.py +364 -0
- infinity_context_adapters/embeddings/__init__.py +6 -0
- infinity_context_adapters/embeddings/noop_adapter.py +5 -0
- infinity_context_adapters/embeddings/openai_adapter.py +104 -0
- infinity_context_adapters/extraction/__init__.py +41 -0
- infinity_context_adapters/extraction/content.py +828 -0
- infinity_context_adapters/extraction/docling_engine.py +255 -0
- infinity_context_adapters/extraction/document_normalization.py +434 -0
- infinity_context_adapters/extraction/factory.py +69 -0
- infinity_context_adapters/extraction/fallback_context.py +137 -0
- infinity_context_adapters/extraction/file_detection.py +378 -0
- infinity_context_adapters/extraction/image_evidence.py +319 -0
- infinity_context_adapters/extraction/media_tools.py +579 -0
- infinity_context_adapters/extraction/openai_json.py +356 -0
- infinity_context_adapters/extraction/openai_vision.py +722 -0
- infinity_context_adapters/extraction/prompts/__init__.py +1 -0
- infinity_context_adapters/extraction/prompts/semantic_memory_v1.md +20 -0
- infinity_context_adapters/extraction/schemas/__init__.py +1 -0
- infinity_context_adapters/extraction/schemas/semantic_memory_v1.json +62 -0
- infinity_context_adapters/extraction/transcription/__init__.py +11 -0
- infinity_context_adapters/extraction/transcription/openai_adapter.py +400 -0
- infinity_context_adapters/extraction/transcription_engine.py +544 -0
- infinity_context_adapters/extraction/video_evidence.py +129 -0
- infinity_context_adapters/extraction/whisper_engine.py +386 -0
- infinity_context_adapters/features/__init__.py +7 -0
- infinity_context_adapters/features/context_building/__init__.py +53 -0
- infinity_context_adapters/features/context_building/candidate_provider_chain.py +68 -0
- infinity_context_adapters/features/context_building/graphiti_candidate_provider.py +44 -0
- infinity_context_adapters/features/context_building/in_memory_candidate_provider.py +62 -0
- infinity_context_adapters/features/context_building/postgres_candidate_provider.py +44 -0
- infinity_context_adapters/features/context_building/qdrant_candidate_provider.py +44 -0
- infinity_context_adapters/features/context_building/query_request.py +99 -0
- infinity_context_adapters/features/context_building/records.py +113 -0
- infinity_context_adapters/features/document_ingestion/__init__.py +74 -0
- infinity_context_adapters/features/document_ingestion/composition.py +69 -0
- infinity_context_adapters/features/document_ingestion/extraction_adapter.py +114 -0
- infinity_context_adapters/features/document_ingestion/in_memory_chunk_index.py +67 -0
- infinity_context_adapters/features/document_ingestion/in_memory_document_store.py +176 -0
- infinity_context_adapters/features/document_ingestion/postgres_document_store.py +110 -0
- infinity_context_adapters/features/document_ingestion/qdrant_chunk_index.py +49 -0
- infinity_context_adapters/features/document_ingestion/records.py +88 -0
- infinity_context_adapters/features/memory_facts/__init__.py +53 -0
- infinity_context_adapters/features/memory_facts/graphiti_fact_projection.py +111 -0
- infinity_context_adapters/features/memory_facts/in_memory_fact_store.py +200 -0
- infinity_context_adapters/features/memory_facts/postgres_fact_store.py +126 -0
- infinity_context_adapters/features/memory_facts/qdrant_fact_projection.py +100 -0
- infinity_context_adapters/features/memory_scopes/__init__.py +44 -0
- infinity_context_adapters/features/memory_scopes/in_memory_scope_store.py +189 -0
- infinity_context_adapters/features/memory_scopes/postgres_scope_store.py +121 -0
- infinity_context_adapters/features/memory_scopes/records.py +86 -0
- infinity_context_adapters/graphiti/__init__.py +5 -0
- infinity_context_adapters/graphiti/adapter.py +613 -0
- infinity_context_adapters/graphiti/identity_evidence.py +711 -0
- infinity_context_adapters/graphiti/scope_identity.py +31 -0
- infinity_context_adapters/local_blob.py +101 -0
- infinity_context_adapters/noop/__init__.py +16 -0
- infinity_context_adapters/noop/adapters.py +156 -0
- infinity_context_adapters/noop/runtime.py +21 -0
- infinity_context_adapters/postgres/__init__.py +19 -0
- infinity_context_adapters/postgres/asset_mappers.py +348 -0
- infinity_context_adapters/postgres/asset_repositories.py +865 -0
- infinity_context_adapters/postgres/benchmark_projection_schema.py +241 -0
- infinity_context_adapters/postgres/benchmark_run_completion.py +645 -0
- infinity_context_adapters/postgres/benchmark_run_repositories.py +908 -0
- infinity_context_adapters/postgres/benchmark_writer_fence.py +139 -0
- infinity_context_adapters/postgres/canonical_keyword_trigram.py +31 -0
- infinity_context_adapters/postgres/canonical_retrieval_batching.py +388 -0
- infinity_context_adapters/postgres/fact_repositories.py +766 -0
- infinity_context_adapters/postgres/mappers.py +745 -0
- infinity_context_adapters/postgres/migrations/0001_core_facts.sql +95 -0
- infinity_context_adapters/postgres/migrations/0002_threads_documents_chunks.sql +97 -0
- infinity_context_adapters/postgres/migrations/0003_suggestions.sql +24 -0
- infinity_context_adapters/postgres/migrations/0004_service_tokens.sql +16 -0
- infinity_context_adapters/postgres/migrations/0005_data_classification_lite.sql +8 -0
- infinity_context_adapters/postgres/migrations/0006_service_token_usage_metadata.sql +5 -0
- infinity_context_adapters/postgres/migrations/0007_service_token_permissions.sql +2 -0
- infinity_context_adapters/postgres/migrations/0008_service_token_memory_scope.sql +2 -0
- infinity_context_adapters/postgres/migrations/0009_outbox_lifecycle_hardening.sql +15 -0
- infinity_context_adapters/postgres/migrations/0010_fact_taxonomy.sql +14 -0
- infinity_context_adapters/postgres/migrations/0011_asset_extractions.sql +66 -0
- infinity_context_adapters/postgres/migrations/0012_asset_extraction_execution_hardening.sql +20 -0
- infinity_context_adapters/postgres/migrations/0012_usage_governance.sql +33 -0
- infinity_context_adapters/postgres/migrations/0013_context_link_suggestions.sql +44 -0
- infinity_context_adapters/postgres/migrations/0014_memory_anchors.sql +26 -0
- infinity_context_adapters/postgres/migrations/0015_users_acl.sql +36 -0
- infinity_context_adapters/postgres/migrations/0016_managed_benchmark_runs.sql +27 -0
- infinity_context_adapters/postgres/migrations/0017_managed_benchmark_writer_fence.sql +104 -0
- infinity_context_adapters/postgres/migrations/0018_benchmark_projection_manifest.sql +51 -0
- infinity_context_adapters/postgres/migrations/0019_managed_benchmark_sealed_fence.sql +131 -0
- infinity_context_adapters/postgres/migrations/0020_benchmark_cleanup_completion.sql +219 -0
- infinity_context_adapters/postgres/migrations/0021_benchmark_unsealed_abort.sql +64 -0
- infinity_context_adapters/postgres/migrations/0022_canonical_keyword_trigram.sql +5 -0
- infinity_context_adapters/postgres/models.py +878 -0
- infinity_context_adapters/postgres/projection_fence.py +80 -0
- infinity_context_adapters/postgres/repositories.py +906 -0
- infinity_context_adapters/postgres/repository_helpers.py +115 -0
- infinity_context_adapters/postgres/scope_repositories.py +540 -0
- infinity_context_adapters/postgres/unit_of_work.py +785 -0
- infinity_context_adapters/postgres/usage_repositories.py +128 -0
- infinity_context_adapters/postgres/user_repositories.py +164 -0
- infinity_context_adapters/provider_errors.py +73 -0
- infinity_context_adapters/qdrant/__init__.py +5 -0
- infinity_context_adapters/qdrant/identity_evidence.py +504 -0
- infinity_context_adapters/qdrant/vector_adapter.py +718 -0
- infinity_context_adapters/s3_blob.py +242 -0
- infinity_context_cli/__init__.py +5 -0
- infinity_context_cli/__main__.py +6 -0
- infinity_context_cli/cli.py +964 -0
- infinity_context_cli/config.py +184 -0
- infinity_context_cli/doctor.py +397 -0
- infinity_context_cli/local_experience.py +250 -0
- infinity_context_cli/mcp_config.py +124 -0
- infinity_context_cli/onboarding.py +542 -0
- infinity_context_cli/runtime.py +179 -0
- infinity_context_contracts/__init__.py +16 -0
- infinity_context_contracts/_json.py +32 -0
- infinity_context_contracts/capabilities.py +67 -0
- infinity_context_contracts/common.py +54 -0
- infinity_context_contracts/features/__init__.py +12 -0
- infinity_context_contracts/features/context_building.py +248 -0
- infinity_context_contracts/features/document_ingestion.py +277 -0
- infinity_context_contracts/features/memory_facts.py +236 -0
- infinity_context_contracts/features/memory_scopes.py +329 -0
- infinity_context_contracts/health.py +23 -0
- infinity_context_core/__init__.py +76 -0
- infinity_context_core/agent_behavior_contract.py +72 -0
- infinity_context_core/application/__init__.py +580 -0
- infinity_context_core/application/anchor_creative_work_filters.py +148 -0
- infinity_context_core/application/anchor_event_extraction.py +1571 -0
- infinity_context_core/application/anchor_extraction.py +1144 -0
- infinity_context_core/application/anchor_identity_normalization.py +90 -0
- infinity_context_core/application/anchor_relation_projection.py +203 -0
- infinity_context_core/application/anchor_temporal_window.py +172 -0
- infinity_context_core/application/asset_extraction_mapping.py +236 -0
- infinity_context_core/application/asset_upload_policy.py +952 -0
- infinity_context_core/application/auto_apply.py +72 -0
- infinity_context_core/application/auto_memory.py +527 -0
- infinity_context_core/application/capture_policy.py +61 -0
- infinity_context_core/application/chunker.py +93 -0
- infinity_context_core/application/context_action_role_evidence.py +890 -0
- infinity_context_core/application/context_action_role_labels.py +176 -0
- infinity_context_core/application/context_action_roles.py +2365 -0
- infinity_context_core/application/context_action_subject_policy.py +71 -0
- infinity_context_core/application/context_activity_companion.py +120 -0
- infinity_context_core/application/context_activity_duration_rerank.py +118 -0
- infinity_context_core/application/context_activity_participant_grounding.py +87 -0
- infinity_context_core/application/context_aggregation_answer_slots.py +586 -0
- infinity_context_core/application/context_aggregation_evidence_text.py +409 -0
- infinity_context_core/application/context_aggregation_rerank.py +145 -0
- infinity_context_core/application/context_aggregation_subject.py +137 -0
- infinity_context_core/application/context_allergy_condition_inference.py +146 -0
- infinity_context_core/application/context_anchor_identity.py +157 -0
- infinity_context_core/application/context_anchor_intent_ranking.py +84 -0
- infinity_context_core/application/context_anchor_relations.py +67 -0
- infinity_context_core/application/context_anchors.py +393 -0
- infinity_context_core/application/context_answer_evidence_types.py +14 -0
- infinity_context_core/application/context_answer_unit_shapes.py +207 -0
- infinity_context_core/application/context_artifact_evidence.py +893 -0
- infinity_context_core/application/context_attribution_lexicon.py +254 -0
- infinity_context_core/application/context_awareness_cause_rerank.py +109 -0
- infinity_context_core/application/context_baby_birth_evidence.py +91 -0
- infinity_context_core/application/context_birdwatching_schedule_rerank.py +130 -0
- infinity_context_core/application/context_bm25_ranking.py +450 -0
- infinity_context_core/application/context_book_author_preference_exact_turns.py +110 -0
- infinity_context_core/application/context_building_legacy_candidate_adapter.py +530 -0
- infinity_context_core/application/context_canonical_fact_retrieval.py +409 -0
- infinity_context_core/application/context_causal_reason_rerank.py +145 -0
- infinity_context_core/application/context_choice_reason_rerank.py +109 -0
- infinity_context_core/application/context_collectors.py +931 -0
- infinity_context_core/application/context_commonality_rerank.py +428 -0
- infinity_context_core/application/context_community_membership_inference.py +139 -0
- infinity_context_core/application/context_competition_count_exact_turns.py +383 -0
- infinity_context_core/application/context_conflicting_evidence_rerank.py +282 -0
- infinity_context_core/application/context_conversation_counterparty.py +260 -0
- infinity_context_core/application/context_count_cardinality.py +164 -0
- infinity_context_core/application/context_creative_work_count_exact_turns.py +517 -0
- infinity_context_core/application/context_diagnostics.py +55 -0
- infinity_context_core/application/context_diagnostics_bundle_keys.py +433 -0
- infinity_context_core/application/context_diagnostics_bundle_projection.py +711 -0
- infinity_context_core/application/context_diagnostics_item_projection.py +410 -0
- infinity_context_core/application/context_diagnostics_primitives.py +131 -0
- infinity_context_core/application/context_diagnostics_ranking.py +143 -0
- infinity_context_core/application/context_diagnostics_signals.py +209 -0
- infinity_context_core/application/context_diagnostics_sources.py +82 -0
- infinity_context_core/application/context_dialogue_authority.py +382 -0
- infinity_context_core/application/context_distinct_set_evidence.py +994 -0
- infinity_context_core/application/context_distinct_set_selection.py +335 -0
- infinity_context_core/application/context_domain_rerank_apply.py +310 -0
- infinity_context_core/application/context_domain_rerank_signals.py +2391 -0
- infinity_context_core/application/context_domain_rerank_types.py +14 -0
- infinity_context_core/application/context_english_activity_displacement_answer_support.py +128 -0
- infinity_context_core/application/context_english_lifestyle_inference.py +122 -0
- infinity_context_core/application/context_english_lifestyle_inference_answer_support.py +291 -0
- infinity_context_core/application/context_english_temporal_dates.py +53 -0
- infinity_context_core/application/context_evidence_priority.py +262 -0
- infinity_context_core/application/context_evidence_reservation_safety.py +208 -0
- infinity_context_core/application/context_exercise_performance_rerank.py +71 -0
- infinity_context_core/application/context_food_inventory_exact_turns.py +583 -0
- infinity_context_core/application/context_frequency_rerank.py +109 -0
- infinity_context_core/application/context_future_plan_timing_rerank.py +110 -0
- infinity_context_core/application/context_generic_behavior_inference.py +348 -0
- infinity_context_core/application/context_geo_residence_aliases.py +149 -0
- infinity_context_core/application/context_hydration.py +329 -0
- infinity_context_core/application/context_identity_fact_rerank.py +362 -0
- infinity_context_core/application/context_identity_rerank.py +76 -0
- infinity_context_core/application/context_identity_terms.py +15 -0
- infinity_context_core/application/context_inference_evidence.py +484 -0
- infinity_context_core/application/context_inference_evidence_terms.py +744 -0
- infinity_context_core/application/context_internal_diagnostics.py +61 -0
- infinity_context_core/application/context_item_evidence.py +108 -0
- infinity_context_core/application/context_item_purchase_evidence.py +49 -0
- infinity_context_core/application/context_keyword_aggregation_prefilter.py +63 -0
- infinity_context_core/application/context_keyword_ranking.py +178 -0
- infinity_context_core/application/context_lexical.py +750 -0
- infinity_context_core/application/context_lifecycle_rerank.py +502 -0
- infinity_context_core/application/context_link_candidate_policy.py +864 -0
- infinity_context_core/application/context_link_expansion.py +727 -0
- infinity_context_core/application/context_link_expansion_items.py +441 -0
- infinity_context_core/application/context_link_policy.py +451 -0
- infinity_context_core/application/context_link_source_enrichment.py +120 -0
- infinity_context_core/application/context_media_time.py +368 -0
- infinity_context_core/application/context_museum_visit_policy.py +66 -0
- infinity_context_core/application/context_named_person_preference.py +313 -0
- infinity_context_core/application/context_national_park_inference.py +93 -0
- infinity_context_core/application/context_object_attribute_rerank.py +416 -0
- infinity_context_core/application/context_object_mismatch.py +63 -0
- infinity_context_core/application/context_occupational_role_identity.py +961 -0
- infinity_context_core/application/context_ordinal_sequence.py +134 -0
- infinity_context_core/application/context_owner_grounding.py +408 -0
- infinity_context_core/application/context_packer.py +858 -0
- infinity_context_core/application/context_packer_answer_slots.py +733 -0
- infinity_context_core/application/context_packer_answer_support.py +3101 -0
- infinity_context_core/application/context_packer_answer_support_patterns.py +1267 -0
- infinity_context_core/application/context_packer_answer_support_slots.py +1209 -0
- infinity_context_core/application/context_packer_answer_support_utils.py +473 -0
- infinity_context_core/application/context_packer_diagnostics.py +48 -0
- infinity_context_core/application/context_packer_exact_literal_turns.py +697 -0
- infinity_context_core/application/context_packer_exact_prepasses.py +758 -0
- infinity_context_core/application/context_packer_exact_turn_utils.py +133 -0
- infinity_context_core/application/context_packer_identity_policy.py +155 -0
- infinity_context_core/application/context_packer_inference_reservation.py +113 -0
- infinity_context_core/application/context_packer_inventory_prepasses.py +359 -0
- infinity_context_core/application/context_packer_inventory_slots.py +771 -0
- infinity_context_core/application/context_packer_marker_coverage.py +409 -0
- infinity_context_core/application/context_packer_rendering.py +338 -0
- infinity_context_core/application/context_packer_selection.py +487 -0
- infinity_context_core/application/context_packer_source_policy.py +123 -0
- infinity_context_core/application/context_paired_evidence_requirements.py +78 -0
- infinity_context_core/application/context_paired_evidence_roles.py +64 -0
- infinity_context_core/application/context_person_activity_exact_turns.py +375 -0
- infinity_context_core/application/context_person_aliases.py +49 -0
- infinity_context_core/application/context_person_kinship.py +296 -0
- infinity_context_core/application/context_person_occupation.py +240 -0
- infinity_context_core/application/context_person_relation_inventory.py +755 -0
- infinity_context_core/application/context_person_residence.py +398 -0
- infinity_context_core/application/context_person_team_membership.py +305 -0
- infinity_context_core/application/context_pet_ownership.py +223 -0
- infinity_context_core/application/context_polarity_rerank.py +338 -0
- infinity_context_core/application/context_policy.py +107 -0
- infinity_context_core/application/context_political_inference.py +128 -0
- infinity_context_core/application/context_possession_source.py +161 -0
- infinity_context_core/application/context_precise_temporal_evidence.py +156 -0
- infinity_context_core/application/context_preference_goal_rerank.py +428 -0
- infinity_context_core/application/context_preference_inference.py +335 -0
- infinity_context_core/application/context_property_interaction_evidence.py +659 -0
- infinity_context_core/application/context_provider_retrieval_terms.py +95 -0
- infinity_context_core/application/context_quality.py +488 -0
- infinity_context_core/application/context_quantity_evidence_patterns.py +254 -0
- infinity_context_core/application/context_quantity_evidence_slots.py +750 -0
- infinity_context_core/application/context_quantity_pending_clothing.py +200 -0
- infinity_context_core/application/context_query_artifact_inventory_expansions.py +76 -0
- infinity_context_core/application/context_query_decomposition.py +879 -0
- infinity_context_core/application/context_query_decomposition_answer_policy.py +707 -0
- infinity_context_core/application/context_query_decomposition_contracts.py +28 -0
- infinity_context_core/application/context_query_decomposition_event_policy.py +535 -0
- infinity_context_core/application/context_query_decomposition_inventory_policy.py +767 -0
- infinity_context_core/application/context_query_decomposition_shared.py +300 -0
- infinity_context_core/application/context_query_duration.py +171 -0
- infinity_context_core/application/context_query_entity_relation_expansions.py +212 -0
- infinity_context_core/application/context_query_event_summary_expansions.py +80 -0
- infinity_context_core/application/context_query_expansion.py +200 -0
- infinity_context_core/application/context_query_expansion_rule_catalog_part1.py +1279 -0
- infinity_context_core/application/context_query_expansion_rule_catalog_part2.py +770 -0
- infinity_context_core/application/context_query_expansion_rule_catalog_part3.py +982 -0
- infinity_context_core/application/context_query_expansion_rule_catalog_part4.py +1334 -0
- infinity_context_core/application/context_query_expansion_rule_catalog_part5.py +517 -0
- infinity_context_core/application/context_query_expansion_rule_terms.py +269 -0
- infinity_context_core/application/context_query_expansion_rules.py +66 -0
- infinity_context_core/application/context_query_expansion_selection.py +892 -0
- infinity_context_core/application/context_query_financial_resources_inference.py +92 -0
- infinity_context_core/application/context_query_food_expansions.py +89 -0
- infinity_context_core/application/context_query_frequency.py +194 -0
- infinity_context_core/application/context_query_game_expansions.py +141 -0
- infinity_context_core/application/context_query_health_lifestyle_expansions.py +178 -0
- infinity_context_core/application/context_query_identity_terms.py +81 -0
- infinity_context_core/application/context_query_intent.py +33 -0
- infinity_context_core/application/context_query_intent_common.py +29 -0
- infinity_context_core/application/context_query_intent_contracts.py +92 -0
- infinity_context_core/application/context_query_intent_extraction.py +614 -0
- infinity_context_core/application/context_query_intent_keys.py +499 -0
- infinity_context_core/application/context_query_intent_matching.py +407 -0
- infinity_context_core/application/context_query_organization_summary_expansions.py +75 -0
- infinity_context_core/application/context_query_personal_fact_expansions.py +314 -0
- infinity_context_core/application/context_query_pet_activity_expansions.py +329 -0
- infinity_context_core/application/context_query_preference_expansions.py +97 -0
- infinity_context_core/application/context_query_project_summary_expansions.py +60 -0
- infinity_context_core/application/context_query_relevance_ranking.py +76 -0
- infinity_context_core/application/context_query_sports_expansions.py +48 -0
- infinity_context_core/application/context_query_state_transition.py +53 -0
- infinity_context_core/application/context_query_support_role.py +165 -0
- infinity_context_core/application/context_query_temporal_expansions.py +18 -0
- infinity_context_core/application/context_query_travel_expansions.py +134 -0
- infinity_context_core/application/context_query_vehicle_expansions.py +79 -0
- infinity_context_core/application/context_query_workflow_expansions.py +233 -0
- infinity_context_core/application/context_query_workflow_intent.py +65 -0
- infinity_context_core/application/context_quote_scanner.py +342 -0
- infinity_context_core/application/context_rank_dedupe.py +171 -0
- infinity_context_core/application/context_rank_fusion.py +191 -0
- infinity_context_core/application/context_ranked_activity_reservation.py +586 -0
- infinity_context_core/application/context_ranked_evidence_coverage_reservation.py +427 -0
- infinity_context_core/application/context_ranked_evidence_priority_reservation.py +37 -0
- infinity_context_core/application/context_ranked_evidence_selection.py +260 -0
- infinity_context_core/application/context_ranking.py +3681 -0
- infinity_context_core/application/context_ranking_reason_policy.py +31 -0
- infinity_context_core/application/context_ranking_reason_priorities.py +859 -0
- infinity_context_core/application/context_ranking_reason_scores.py +519 -0
- infinity_context_core/application/context_recommendation_answer_support.py +358 -0
- infinity_context_core/application/context_recommendation_exact_turns.py +360 -0
- infinity_context_core/application/context_relation_requirement.py +498 -0
- infinity_context_core/application/context_relationship_status_evidence.py +83 -0
- infinity_context_core/application/context_relative_duration_evidence.py +61 -0
- infinity_context_core/application/context_relevance.py +430 -0
- infinity_context_core/application/context_reported_obligation_attribution.py +416 -0
- infinity_context_core/application/context_reporting_frames.py +338 -0
- infinity_context_core/application/context_requirement_coverage.py +767 -0
- infinity_context_core/application/context_requirement_guard.py +503 -0
- infinity_context_core/application/context_requirement_patterns.py +943 -0
- infinity_context_core/application/context_requirement_ranking.py +181 -0
- infinity_context_core/application/context_requirement_signals.py +101 -0
- infinity_context_core/application/context_rerank_domain_heuristics.py +433 -0
- infinity_context_core/application/context_rerank_evidence_signals.py +400 -0
- infinity_context_core/application/context_rerank_relevance.py +131 -0
- infinity_context_core/application/context_retrieval_performance.py +153 -0
- infinity_context_core/application/context_review_items.py +338 -0
- infinity_context_core/application/context_score_signal_rerank.py +21 -0
- infinity_context_core/application/context_short_story_progress_evidence.py +119 -0
- infinity_context_core/application/context_snippets.py +545 -0
- infinity_context_core/application/context_social_education_inference.py +265 -0
- infinity_context_core/application/context_social_inventory_rerank.py +329 -0
- infinity_context_core/application/context_source_family.py +100 -0
- infinity_context_core/application/context_source_grounding.py +277 -0
- infinity_context_core/application/context_source_sibling_answer_evidence_repair.py +1983 -0
- infinity_context_core/application/context_source_sibling_contracts.py +35 -0
- infinity_context_core/application/context_source_sibling_evidence.py +405 -0
- infinity_context_core/application/context_source_sibling_evidence_rules.py +798 -0
- infinity_context_core/application/context_source_sibling_evidence_shared.py +449 -0
- infinity_context_core/application/context_source_sibling_identity.py +114 -0
- infinity_context_core/application/context_source_sibling_inventory_evidence.py +28 -0
- infinity_context_core/application/context_source_sibling_patterns.py +946 -0
- infinity_context_core/application/context_source_sibling_place_evidence.py +561 -0
- infinity_context_core/application/context_source_sibling_policy.py +988 -0
- infinity_context_core/application/context_source_sibling_scoring.py +721 -0
- infinity_context_core/application/context_source_siblings.py +363 -0
- infinity_context_core/application/context_speaker_attribution.py +574 -0
- infinity_context_core/application/context_speaker_disambiguation.py +108 -0
- infinity_context_core/application/context_stage_diagnostics.py +111 -0
- infinity_context_core/application/context_state_evidence.py +196 -0
- infinity_context_core/application/context_state_residence_inference.py +163 -0
- infinity_context_core/application/context_state_transition_pairing.py +401 -0
- infinity_context_core/application/context_temporal_answer_grounding.py +187 -0
- infinity_context_core/application/context_temporal_hints.py +485 -0
- infinity_context_core/application/context_temporal_intent_policy.py +146 -0
- infinity_context_core/application/context_temporal_interval_requirements.py +107 -0
- infinity_context_core/application/context_temporal_metadata.py +29 -0
- infinity_context_core/application/context_temporal_query.py +1358 -0
- infinity_context_core/application/context_temporal_ranges.py +471 -0
- infinity_context_core/application/context_temporal_session_order.py +439 -0
- infinity_context_core/application/context_temporal_source_identity.py +426 -0
- infinity_context_core/application/context_temporal_source_turn.py +1290 -0
- infinity_context_core/application/context_temporal_source_turn_labels.py +265 -0
- infinity_context_core/application/context_temporal_source_turn_patterns.py +186 -0
- infinity_context_core/application/context_temporal_source_turn_types.py +62 -0
- infinity_context_core/application/context_travel_hobby_writing_evidence.py +176 -0
- infinity_context_core/application/context_travel_place_evidence.py +23 -0
- infinity_context_core/application/document_fragments.py +206 -0
- infinity_context_core/application/document_text.py +203 -0
- infinity_context_core/application/dto.py +311 -0
- infinity_context_core/application/dto_anchors.py +143 -0
- infinity_context_core/application/dto_assets.py +234 -0
- infinity_context_core/application/dto_benchmark_runs.py +114 -0
- infinity_context_core/application/dto_context.py +176 -0
- infinity_context_core/application/dto_context_links.py +170 -0
- infinity_context_core/application/dto_facts.py +275 -0
- infinity_context_core/application/dto_suggestions_capture.py +199 -0
- infinity_context_core/application/dto_workspace.py +101 -0
- infinity_context_core/application/extraction_coordinates.py +56 -0
- infinity_context_core/application/extraction_resource_policy.py +796 -0
- infinity_context_core/application/extractor.py +147 -0
- infinity_context_core/application/memory_digest_renderer.py +215 -0
- infinity_context_core/application/multimodal_manifest.py +418 -0
- infinity_context_core/application/normalize.py +29 -0
- infinity_context_core/application/observed_anchor_resolution.py +243 -0
- infinity_context_core/application/related_facts.py +144 -0
- infinity_context_core/application/review_payloads.py +104 -0
- infinity_context_core/application/safe_payload.py +86 -0
- infinity_context_core/application/semantic_dedupe.py +943 -0
- infinity_context_core/application/sensitive_text.py +39 -0
- infinity_context_core/application/source_refs.py +263 -0
- infinity_context_core/application/storage_key_safety.py +13 -0
- infinity_context_core/application/temporal_validity.py +31 -0
- infinity_context_core/application/use_cases/__init__.py +1 -0
- infinity_context_core/application/use_cases/anchors.py +1165 -0
- infinity_context_core/application/use_cases/asset_extraction_support.py +273 -0
- infinity_context_core/application/use_cases/asset_extractions.py +1454 -0
- infinity_context_core/application/use_cases/assets.py +463 -0
- infinity_context_core/application/use_cases/benchmark_runs.py +877 -0
- infinity_context_core/application/use_cases/benchmark_unsealed_abort.py +147 -0
- infinity_context_core/application/use_cases/blob_storage_cleanup.py +289 -0
- infinity_context_core/application/use_cases/blob_storage_integrity.py +351 -0
- infinity_context_core/application/use_cases/build_context.py +995 -0
- infinity_context_core/application/use_cases/build_context_final_packing.py +59 -0
- infinity_context_core/application/use_cases/build_context_item_projection.py +839 -0
- infinity_context_core/application/use_cases/build_context_keyword_aggregation.py +908 -0
- infinity_context_core/application/use_cases/build_context_keyword_aggregation_seeds.py +132 -0
- infinity_context_core/application/use_cases/build_context_keyword_aggregation_selection.py +280 -0
- infinity_context_core/application/use_cases/build_context_keyword_aggregation_support.py +161 -0
- infinity_context_core/application/use_cases/build_context_requirement_guard.py +156 -0
- infinity_context_core/application/use_cases/build_context_source_selection.py +935 -0
- infinity_context_core/application/use_cases/build_memory_digest.py +203 -0
- infinity_context_core/application/use_cases/build_memory_insights.py +979 -0
- infinity_context_core/application/use_cases/consolidate_capture.py +806 -0
- infinity_context_core/application/use_cases/context_link_crud.py +196 -0
- infinity_context_core/application/use_cases/context_link_reviews.py +441 -0
- infinity_context_core/application/use_cases/context_link_suggestions.py +1060 -0
- infinity_context_core/application/use_cases/context_link_visibility.py +106 -0
- infinity_context_core/application/use_cases/context_links.py +33 -0
- infinity_context_core/application/use_cases/delete_document.py +71 -0
- infinity_context_core/application/use_cases/delete_thread_memory.py +55 -0
- infinity_context_core/application/use_cases/duplicate_merge_resolution.py +307 -0
- infinity_context_core/application/use_cases/ensure_scope.py +29 -0
- infinity_context_core/application/use_cases/expire_suggestions.py +36 -0
- infinity_context_core/application/use_cases/export_graph.py +684 -0
- infinity_context_core/application/use_cases/fact_relations.py +204 -0
- infinity_context_core/application/use_cases/forget_fact.py +43 -0
- infinity_context_core/application/use_cases/get_capabilities.py +213 -0
- infinity_context_core/application/use_cases/get_capture.py +16 -0
- infinity_context_core/application/use_cases/get_session_status.py +23 -0
- infinity_context_core/application/use_cases/ingest_document.py +376 -0
- infinity_context_core/application/use_cases/ingest_episode.py +263 -0
- infinity_context_core/application/use_cases/list_captures.py +25 -0
- infinity_context_core/application/use_cases/memory_browser.py +414 -0
- infinity_context_core/application/use_cases/operations_console.py +293 -0
- infinity_context_core/application/use_cases/process_document.py +83 -0
- infinity_context_core/application/use_cases/purge_capture.py +34 -0
- infinity_context_core/application/use_cases/query_documents.py +42 -0
- infinity_context_core/application/use_cases/query_facts.py +57 -0
- infinity_context_core/application/use_cases/receive_capture.py +238 -0
- infinity_context_core/application/use_cases/related_facts.py +47 -0
- infinity_context_core/application/use_cases/remember_fact.py +145 -0
- infinity_context_core/application/use_cases/spaces_memory_scopes.py +134 -0
- infinity_context_core/application/use_cases/suggestions.py +804 -0
- infinity_context_core/application/use_cases/update_fact.py +43 -0
- infinity_context_core/application/use_cases/usage.py +49 -0
- infinity_context_core/application/use_cases/users.py +138 -0
- infinity_context_core/domain/__init__.py +1 -0
- infinity_context_core/domain/aggregation_admission.py +200 -0
- infinity_context_core/domain/anchor_entities.py +316 -0
- infinity_context_core/domain/assets.py +654 -0
- infinity_context_core/domain/capture.py +321 -0
- infinity_context_core/domain/distinct_set_membership.py +69 -0
- infinity_context_core/domain/entities.py +103 -0
- infinity_context_core/domain/entity_policies.py +119 -0
- infinity_context_core/domain/entity_types.py +150 -0
- infinity_context_core/domain/errors.py +53 -0
- infinity_context_core/domain/events.py +14 -0
- infinity_context_core/domain/extraction.py +529 -0
- infinity_context_core/domain/idempotency.py +12 -0
- infinity_context_core/domain/memory_item_entities.py +426 -0
- infinity_context_core/domain/source_refs.py +91 -0
- infinity_context_core/domain/suggestion_entities.py +236 -0
- infinity_context_core/domain/taxonomy.py +121 -0
- infinity_context_core/domain/usage.py +221 -0
- infinity_context_core/domain/workspace_entities.py +269 -0
- infinity_context_core/features/__init__.py +7 -0
- infinity_context_core/features/context_building/__init__.py +3 -0
- infinity_context_core/features/context_building/application/__init__.py +92 -0
- infinity_context_core/features/context_building/application/candidate_fusion.py +136 -0
- infinity_context_core/features/context_building/application/coverage_reservation_selector.py +212 -0
- infinity_context_core/features/context_building/application/handlers.py +155 -0
- infinity_context_core/features/context_building/application/inference_evidence_reservation.py +592 -0
- infinity_context_core/features/context_building/application/provider_pipeline.py +61 -0
- infinity_context_core/features/context_building/application/queries.py +107 -0
- infinity_context_core/features/context_building/application/use_cases.py +78 -0
- infinity_context_core/features/context_building/domain/__init__.py +95 -0
- infinity_context_core/features/context_building/domain/budget.py +97 -0
- infinity_context_core/features/context_building/domain/context.py +157 -0
- infinity_context_core/features/context_building/domain/evidence_obligations.py +60 -0
- infinity_context_core/features/context_building/domain/feature.py +15 -0
- infinity_context_core/features/context_building/domain/prompt_sections.py +150 -0
- infinity_context_core/features/context_building/domain/query_pipeline.py +276 -0
- infinity_context_core/features/context_building/domain/rendering.py +102 -0
- infinity_context_core/features/context_building/ports/__init__.py +8 -0
- infinity_context_core/features/context_building/ports/candidates.py +36 -0
- infinity_context_core/features/context_building/public.py +165 -0
- infinity_context_core/features/context_building/tests/test_application_ports_public_skeleton.py +575 -0
- infinity_context_core/features/context_building/tests/test_domain_context_building_skeleton.py +402 -0
- infinity_context_core/features/document_ingestion/__init__.py +3 -0
- infinity_context_core/features/document_ingestion/application/__init__.py +31 -0
- infinity_context_core/features/document_ingestion/application/commands.py +62 -0
- infinity_context_core/features/document_ingestion/application/use_cases.py +273 -0
- infinity_context_core/features/document_ingestion/domain/__init__.py +61 -0
- infinity_context_core/features/document_ingestion/domain/chunking.py +297 -0
- infinity_context_core/features/document_ingestion/domain/errors.py +22 -0
- infinity_context_core/features/document_ingestion/domain/feature.py +18 -0
- infinity_context_core/features/document_ingestion/domain/source_document.py +228 -0
- infinity_context_core/features/document_ingestion/ports/__init__.py +21 -0
- infinity_context_core/features/document_ingestion/ports/indexing.py +51 -0
- infinity_context_core/features/document_ingestion/ports/repositories.py +56 -0
- infinity_context_core/features/document_ingestion/public.py +95 -0
- infinity_context_core/features/document_ingestion/tests/test_application_handlers.py +226 -0
- infinity_context_core/features/document_ingestion/tests/test_application_ports_public_skeleton.py +334 -0
- infinity_context_core/features/document_ingestion/tests/test_domain_chunking_skeleton.py +79 -0
- infinity_context_core/features/document_ingestion/tests/test_domain_source_document_skeleton.py +101 -0
- infinity_context_core/features/memory_facts/__init__.py +3 -0
- infinity_context_core/features/memory_facts/application/__init__.py +37 -0
- infinity_context_core/features/memory_facts/application/commands.py +89 -0
- infinity_context_core/features/memory_facts/application/handlers.py +241 -0
- infinity_context_core/features/memory_facts/application/use_cases.py +47 -0
- infinity_context_core/features/memory_facts/domain/__init__.py +35 -0
- infinity_context_core/features/memory_facts/domain/fact.py +98 -0
- infinity_context_core/features/memory_facts/domain/feature.py +15 -0
- infinity_context_core/features/memory_facts/ports/__init__.py +31 -0
- infinity_context_core/features/memory_facts/ports/clock.py +14 -0
- infinity_context_core/features/memory_facts/ports/ids.py +19 -0
- infinity_context_core/features/memory_facts/ports/outbox.py +26 -0
- infinity_context_core/features/memory_facts/ports/repositories.py +30 -0
- infinity_context_core/features/memory_facts/ports/unit_of_work.py +43 -0
- infinity_context_core/features/memory_facts/public.py +79 -0
- infinity_context_core/features/memory_facts/tests/test_application_handlers.py +332 -0
- infinity_context_core/features/memory_facts/tests/test_application_ports_public_skeleton.py +318 -0
- infinity_context_core/features/memory_facts/tests/test_domain_fact_skeleton.py +222 -0
- infinity_context_core/features/memory_scopes/__init__.py +3 -0
- infinity_context_core/features/memory_scopes/application/__init__.py +55 -0
- infinity_context_core/features/memory_scopes/application/commands.py +102 -0
- infinity_context_core/features/memory_scopes/application/errors.py +27 -0
- infinity_context_core/features/memory_scopes/application/handlers.py +226 -0
- infinity_context_core/features/memory_scopes/application/use_cases.py +68 -0
- infinity_context_core/features/memory_scopes/domain/__init__.py +59 -0
- infinity_context_core/features/memory_scopes/domain/errors.py +22 -0
- infinity_context_core/features/memory_scopes/domain/feature.py +18 -0
- infinity_context_core/features/memory_scopes/domain/policies.py +197 -0
- infinity_context_core/features/memory_scopes/domain/scope.py +178 -0
- infinity_context_core/features/memory_scopes/ports/__init__.py +25 -0
- infinity_context_core/features/memory_scopes/ports/clock.py +14 -0
- infinity_context_core/features/memory_scopes/ports/ids.py +13 -0
- infinity_context_core/features/memory_scopes/ports/repositories.py +40 -0
- infinity_context_core/features/memory_scopes/ports/unit_of_work.py +39 -0
- infinity_context_core/features/memory_scopes/public.py +111 -0
- infinity_context_core/features/memory_scopes/tests/test_application_ports_public_skeleton.py +824 -0
- infinity_context_core/features/memory_scopes/tests/test_domain_scope_skeleton.py +428 -0
- infinity_context_core/memory_scope_snapshot_preview.py +863 -0
- infinity_context_core/memory_scope_snapshots.py +206 -0
- infinity_context_core/ports/__init__.py +164 -0
- infinity_context_core/ports/adapters.py +217 -0
- infinity_context_core/ports/assets.py +270 -0
- infinity_context_core/ports/auth.py +68 -0
- infinity_context_core/ports/auto_memory.py +71 -0
- infinity_context_core/ports/benchmark_runs.py +205 -0
- infinity_context_core/ports/capabilities.py +324 -0
- infinity_context_core/ports/captures.py +53 -0
- infinity_context_core/ports/clock.py +11 -0
- infinity_context_core/ports/derived_projection_policy.py +72 -0
- infinity_context_core/ports/extraction.py +201 -0
- infinity_context_core/ports/graph_evidence.py +170 -0
- infinity_context_core/ports/ids.py +11 -0
- infinity_context_core/ports/projection_fence.py +27 -0
- infinity_context_core/ports/repositories.py +563 -0
- infinity_context_core/ports/transcription.py +63 -0
- infinity_context_core/ports/unit_of_work.py +77 -0
- infinity_context_core/ports/usage.py +36 -0
- infinity_context_core/ports/vector_projection_evidence.py +230 -0
- infinity_context_core/ports/vision.py +36 -0
- infinity_context_core/processes/__init__.py +3 -0
- infinity_context_core/processes/document_memory_pipeline/__init__.py +3 -0
- infinity_context_core/processes/document_memory_pipeline/contracts.py +44 -0
- infinity_context_core/processes/document_memory_pipeline/process.py +72 -0
- infinity_context_core/processes/document_memory_pipeline/public.py +21 -0
- infinity_context_core/reporting.py +105 -0
- infinity_context_mcp/__init__.py +5 -0
- infinity_context_mcp/__main__.py +6 -0
- infinity_context_mcp/adapters/__init__.py +1 -0
- infinity_context_mcp/adapters/http_gateway.py +940 -0
- infinity_context_mcp/agent_behavior_bench.py +1731 -0
- infinity_context_mcp/agent_behavior_bench_metrics.py +419 -0
- infinity_context_mcp/agent_behavior_bench_redaction.py +149 -0
- infinity_context_mcp/agent_behavior_bench_types.py +127 -0
- infinity_context_mcp/agent_behavior_scenarios.py +35 -0
- infinity_context_mcp/agent_behavior_scenarios_core.py +484 -0
- infinity_context_mcp/agent_behavior_scenarios_realistic.py +473 -0
- infinity_context_mcp/agent_behavior_scenarios_transcript.py +196 -0
- infinity_context_mcp/agent_behavior_transcripts.py +231 -0
- infinity_context_mcp/agent_behavior_types.py +66 -0
- infinity_context_mcp/agent_behavior_utils.py +29 -0
- infinity_context_mcp/application/__init__.py +1 -0
- infinity_context_mcp/application/context_link_review.py +109 -0
- infinity_context_mcp/application/local_runtime.py +473 -0
- infinity_context_mcp/application/normalization.py +36 -0
- infinity_context_mcp/application/obsidian.py +568 -0
- infinity_context_mcp/application/policy.py +160 -0
- infinity_context_mcp/application/ports.py +324 -0
- infinity_context_mcp/application/prepare.py +254 -0
- infinity_context_mcp/application/readiness.py +71 -0
- infinity_context_mcp/application/review_batch.py +62 -0
- infinity_context_mcp/application/service.py +701 -0
- infinity_context_mcp/application/service_base.py +29 -0
- infinity_context_mcp/application/service_constants.py +89 -0
- infinity_context_mcp/application/service_context_links.py +224 -0
- infinity_context_mcp/application/service_duplicates.py +62 -0
- infinity_context_mcp/application/service_facts.py +461 -0
- infinity_context_mcp/application/service_helpers.py +179 -0
- infinity_context_mcp/application/service_lifecycle.py +348 -0
- infinity_context_mcp/application/service_policy.py +74 -0
- infinity_context_mcp/application/service_query.py +384 -0
- infinity_context_mcp/application/service_resources.py +192 -0
- infinity_context_mcp/application/service_response.py +95 -0
- infinity_context_mcp/application/service_scope.py +132 -0
- infinity_context_mcp/application/service_suggestions.py +820 -0
- infinity_context_mcp/application/suggest_batch.py +71 -0
- infinity_context_mcp/application/usage_guide.py +74 -0
- infinity_context_mcp/bench.py +279 -0
- infinity_context_mcp/config.py +213 -0
- infinity_context_mcp/domain/__init__.py +1 -0
- infinity_context_mcp/domain/context_links.py +117 -0
- infinity_context_mcp/domain/local_runtime_models.py +56 -0
- infinity_context_mcp/domain/memory_browser.py +35 -0
- infinity_context_mcp/domain/models.py +1036 -0
- infinity_context_mcp/domain/obsidian_models.py +67 -0
- infinity_context_mcp/domain/policy.py +112 -0
- infinity_context_mcp/domain/prepare_models.py +24 -0
- infinity_context_mcp/plugin_hook.py +873 -0
- infinity_context_mcp/plugin_hook_settings.py +253 -0
- infinity_context_mcp/server.py +133 -0
- infinity_context_mcp/server_context_tools.py +404 -0
- infinity_context_mcp/server_fact_tools.py +928 -0
- infinity_context_mcp/server_hardening.py +54 -0
- infinity_context_mcp/server_local_runtime_tools.py +164 -0
- infinity_context_mcp/server_obsidian_tools.py +380 -0
- infinity_context_mcp/server_query_tools.py +626 -0
- infinity_context_mcp/server_request_mapping.py +73 -0
- infinity_context_mcp/server_resources.py +187 -0
- infinity_context_mcp/server_response.py +26 -0
- infinity_context_obsidian/__init__.py +5 -0
- infinity_context_obsidian/cli.py +594 -0
- infinity_context_obsidian/conflicts.py +110 -0
- infinity_context_obsidian/doctor.py +319 -0
- infinity_context_obsidian/domain.py +92 -0
- infinity_context_obsidian/frontmatter.py +68 -0
- infinity_context_obsidian/gateway.py +66 -0
- infinity_context_obsidian/layout.py +179 -0
- infinity_context_obsidian/note_format.py +159 -0
- infinity_context_obsidian/plugin_bundle/__init__.py +1 -0
- infinity_context_obsidian/plugin_bundle/main.js +5 -0
- infinity_context_obsidian/plugin_bundle/manifest.json +10 -0
- infinity_context_obsidian/plugin_bundle/styles.css +123 -0
- infinity_context_obsidian/plugin_install.py +139 -0
- infinity_context_obsidian/ports.py +72 -0
- infinity_context_obsidian/setup.py +202 -0
- infinity_context_obsidian/state.py +85 -0
- infinity_context_obsidian/sync.py +741 -0
- infinity_context_obsidian/vault.py +61 -0
- infinity_context_sdk/__init__.py +1049 -0
- infinity_context_sdk/_payloads.py +401 -0
- infinity_context_sdk/_redaction.py +31 -0
- infinity_context_sdk/anchors.py +249 -0
- infinity_context_sdk/assets.py +554 -0
- infinity_context_sdk/capabilities.py +199 -0
- infinity_context_sdk/context.py +540 -0
- infinity_context_sdk/context_bundle_diagnostics.py +905 -0
- infinity_context_sdk/context_payload_utils.py +219 -0
- infinity_context_sdk/export.py +123 -0
- infinity_context_sdk/scopes.py +74 -0
- infinity_context_sdk/thread_memory.py +55 -0
- infinity_context_server/__init__.py +5 -0
- infinity_context_server/__main__.py +19 -0
- infinity_context_server/admin.py +832 -0
- infinity_context_server/admin_invariants.py +388 -0
- infinity_context_server/admin_outbox.py +130 -0
- infinity_context_server/admin_projection_repair.py +374 -0
- infinity_context_server/api/__init__.py +1 -0
- infinity_context_server/api/auth.py +432 -0
- infinity_context_server/api/dependencies.py +9 -0
- infinity_context_server/api/errors.py +94 -0
- infinity_context_server/api/legacy_client.py +356 -0
- infinity_context_server/api/policy.py +35 -0
- infinity_context_server/api/public_payload.py +27 -0
- infinity_context_server/api/v1/__init__.py +54 -0
- infinity_context_server/api/v1/anchors.py +469 -0
- infinity_context_server/api/v1/assets.py +409 -0
- infinity_context_server/api/v1/capabilities.py +144 -0
- infinity_context_server/api/v1/captures.py +329 -0
- infinity_context_server/api/v1/context.py +362 -0
- infinity_context_server/api/v1/context_links.py +611 -0
- infinity_context_server/api/v1/diagnostics.py +333 -0
- infinity_context_server/api/v1/digest.py +107 -0
- infinity_context_server/api/v1/documents.py +164 -0
- infinity_context_server/api/v1/episodes.py +146 -0
- infinity_context_server/api/v1/export.py +184 -0
- infinity_context_server/api/v1/facts.py +265 -0
- infinity_context_server/api/v1/health.py +24 -0
- infinity_context_server/api/v1/insights.py +100 -0
- infinity_context_server/api/v1/internal_memory_comparison_runs.py +406 -0
- infinity_context_server/api/v1/memory_browser.py +183 -0
- infinity_context_server/api/v1/operations.py +81 -0
- infinity_context_server/api/v1/scope_resolution.py +389 -0
- infinity_context_server/api/v1/source_refs.py +111 -0
- infinity_context_server/api/v1/spaces_memory_scopes.py +141 -0
- infinity_context_server/api/v1/suggestions.py +237 -0
- infinity_context_server/api/v1/thread_memory.py +74 -0
- infinity_context_server/api/v1/usage.py +75 -0
- infinity_context_server/api/v1/users.py +164 -0
- infinity_context_server/auth_scope.py +492 -0
- infinity_context_server/auth_tokens.py +283 -0
- infinity_context_server/backpressure.py +47 -0
- infinity_context_server/benchmark_projection_absence.py +155 -0
- infinity_context_server/benchmark_projection_delete_outbox.py +162 -0
- infinity_context_server/composition.py +897 -0
- infinity_context_server/config.py +223 -0
- infinity_context_server/db.py +39 -0
- infinity_context_server/deployment_readiness.py +205 -0
- infinity_context_server/derived_identity_evidence.py +987 -0
- infinity_context_server/derived_identity_target.py +39 -0
- infinity_context_server/derived_projection_policy.py +85 -0
- infinity_context_server/diagnostics.py +536 -0
- infinity_context_server/doctor.py +71 -0
- infinity_context_server/eval.py +3066 -0
- infinity_context_server/eval_auto_memory.py +1735 -0
- infinity_context_server/eval_auto_memory_metrics.py +224 -0
- infinity_context_server/eval_auto_memory_types.py +75 -0
- infinity_context_server/eval_case_catalog.py +1590 -0
- infinity_context_server/eval_case_runner.py +1100 -0
- infinity_context_server/eval_common.py +336 -0
- infinity_context_server/eval_constants.py +310 -0
- infinity_context_server/eval_fixtures.py +150 -0
- infinity_context_server/eval_graph.py +92 -0
- infinity_context_server/eval_hybrid.py +99 -0
- infinity_context_server/eval_multimodal_offline.py +697 -0
- infinity_context_server/eval_prompt_contract.py +402 -0
- infinity_context_server/eval_scorecard.py +2627 -0
- infinity_context_server/eval_semantic_linking.py +1526 -0
- infinity_context_server/eval_semantic_retrieval_api_canary.py +405 -0
- infinity_context_server/eval_semantic_retrieval_canary.py +359 -0
- infinity_context_server/eval_types.py +88 -0
- infinity_context_server/evidence_bundle.py +523 -0
- infinity_context_server/extraction_capabilities.py +1234 -0
- infinity_context_server/features/__init__.py +3 -0
- infinity_context_server/features/context_building/__init__.py +5 -0
- infinity_context_server/features/context_building/benchmark_budget.py +29 -0
- infinity_context_server/features/context_building/composition.py +49 -0
- infinity_context_server/features/context_building/context_requests.py +151 -0
- infinity_context_server/features/context_building/contracts.py +96 -0
- infinity_context_server/features/context_building/digest_api_responses.py +225 -0
- infinity_context_server/features/context_building/digest_requests.py +65 -0
- infinity_context_server/features/context_building/insights_api_responses.py +132 -0
- infinity_context_server/features/context_building/legacy_api_responses.py +875 -0
- infinity_context_server/features/context_building/mappers.py +205 -0
- infinity_context_server/features/context_building/public.py +66 -0
- infinity_context_server/features/context_building/routes.py +44 -0
- infinity_context_server/features/document_ingestion/__init__.py +5 -0
- infinity_context_server/features/document_ingestion/asset_requests.py +45 -0
- infinity_context_server/features/document_ingestion/asset_responses.py +365 -0
- infinity_context_server/features/document_ingestion/composition.py +49 -0
- infinity_context_server/features/document_ingestion/contracts.py +104 -0
- infinity_context_server/features/document_ingestion/mappers.py +386 -0
- infinity_context_server/features/document_ingestion/public.py +58 -0
- infinity_context_server/features/document_ingestion/routes.py +44 -0
- infinity_context_server/features/memory_facts/__init__.py +7 -0
- infinity_context_server/features/memory_facts/compatibility.py +204 -0
- infinity_context_server/features/memory_facts/composition.py +72 -0
- infinity_context_server/features/memory_facts/contracts.py +187 -0
- infinity_context_server/features/memory_facts/mappers.py +620 -0
- infinity_context_server/features/memory_facts/public.py +168 -0
- infinity_context_server/features/memory_facts/routes.py +118 -0
- infinity_context_server/features/memory_facts/suggestion_requests.py +283 -0
- infinity_context_server/features/memory_facts/suggestion_responses.py +382 -0
- infinity_context_server/features/memory_scopes/__init__.py +5 -0
- infinity_context_server/features/memory_scopes/compatibility.py +231 -0
- infinity_context_server/features/memory_scopes/composition.py +49 -0
- infinity_context_server/features/memory_scopes/contracts.py +103 -0
- infinity_context_server/features/memory_scopes/graph_export_responses.py +93 -0
- infinity_context_server/features/memory_scopes/mappers.py +290 -0
- infinity_context_server/features/memory_scopes/public.py +136 -0
- infinity_context_server/features/memory_scopes/routes.py +185 -0
- infinity_context_server/features/memory_scopes/snapshot_compatibility.py +146 -0
- infinity_context_server/features/memory_scopes/thread_memory_requests.py +127 -0
- infinity_context_server/llm_provider_readiness.py +267 -0
- infinity_context_server/longmemeval_session_identity.py +167 -0
- infinity_context_server/main.py +68 -0
- infinity_context_server/mem0_benchmark_auth_challenge.py +160 -0
- infinity_context_server/memora_comparison.py +658 -0
- infinity_context_server/memory_comparison_answer_context.py +2442 -0
- infinity_context_server/memory_comparison_answer_context_backfill.py +1027 -0
- infinity_context_server/memory_comparison_answer_context_diagnostics.py +694 -0
- infinity_context_server/memory_comparison_answer_context_inspection.py +103 -0
- infinity_context_server/memory_comparison_answer_context_retrieval_slice.py +175 -0
- infinity_context_server/memory_comparison_answer_context_risks.py +223 -0
- infinity_context_server/memory_comparison_backend_target.py +41 -0
- infinity_context_server/memory_comparison_benchmark.py +651 -0
- infinity_context_server/memory_comparison_benchmark_compact.py +387 -0
- infinity_context_server/memory_comparison_benchmark_compact_fast_gate.py +387 -0
- infinity_context_server/memory_comparison_benchmark_compact_samples.py +931 -0
- infinity_context_server/memory_comparison_benchmark_config.py +105 -0
- infinity_context_server/memory_comparison_benchmark_control.py +215 -0
- infinity_context_server/memory_comparison_benchmark_execution.py +238 -0
- infinity_context_server/memory_comparison_benchmark_identity.py +65 -0
- infinity_context_server/memory_comparison_benchmark_metrics.py +686 -0
- infinity_context_server/memory_comparison_benchmark_replay.py +400 -0
- infinity_context_server/memory_comparison_benchmark_shared.py +284 -0
- infinity_context_server/memory_comparison_bounded_provider.py +295 -0
- infinity_context_server/memory_comparison_bundle_partial_support.py +107 -0
- infinity_context_server/memory_comparison_bundle_planner.py +3521 -0
- infinity_context_server/memory_comparison_bundle_source_windows.py +247 -0
- infinity_context_server/memory_comparison_candidate_features.py +2014 -0
- infinity_context_server/memory_comparison_candidate_fusion.py +893 -0
- infinity_context_server/memory_comparison_candidate_risks.py +124 -0
- infinity_context_server/memory_comparison_canonical_source_hash.py +109 -0
- infinity_context_server/memory_comparison_case_identity.py +100 -0
- infinity_context_server/memory_comparison_case_loader.py +123 -0
- infinity_context_server/memory_comparison_chat_completions.py +402 -0
- infinity_context_server/memory_comparison_clean_state.py +607 -0
- infinity_context_server/memory_comparison_clean_state_http.py +120 -0
- infinity_context_server/memory_comparison_clean_state_runner.py +103 -0
- infinity_context_server/memory_comparison_cli.py +295 -0
- infinity_context_server/memory_comparison_codex_canary.py +315 -0
- infinity_context_server/memory_comparison_codex_llm.py +345 -0
- infinity_context_server/memory_comparison_compact_gap_report.py +289 -0
- infinity_context_server/memory_comparison_comparative_preference.py +71 -0
- infinity_context_server/memory_comparison_conversation_ingestion.py +198 -0
- infinity_context_server/memory_comparison_evidence.py +877 -0
- infinity_context_server/memory_comparison_evidence_commitment.py +20 -0
- infinity_context_server/memory_comparison_failure_diagnostics.py +809 -0
- infinity_context_server/memory_comparison_full_canonical_evidence.py +746 -0
- infinity_context_server/memory_comparison_full_canonical_source_evidence_trust.py +450 -0
- infinity_context_server/memory_comparison_full_delete_evidence.py +670 -0
- infinity_context_server/memory_comparison_full_delete_evidence_trust.py +441 -0
- infinity_context_server/memory_comparison_full_delete_evidence_witnesses.py +308 -0
- infinity_context_server/memory_comparison_full_execution_validation.py +697 -0
- infinity_context_server/memory_comparison_full_execution_validation_slots.py +655 -0
- infinity_context_server/memory_comparison_full_methodology.py +556 -0
- infinity_context_server/memory_comparison_full_policy_component_validation.py +899 -0
- infinity_context_server/memory_comparison_full_profiles.py +398 -0
- infinity_context_server/memory_comparison_full_run_component_sets.py +304 -0
- infinity_context_server/memory_comparison_full_run_components.py +787 -0
- infinity_context_server/memory_comparison_full_run_evidence.py +759 -0
- infinity_context_server/memory_comparison_full_scope.py +244 -0
- infinity_context_server/memory_comparison_full_source_evidence.py +866 -0
- infinity_context_server/memory_comparison_full_verdict.py +252 -0
- infinity_context_server/memory_comparison_gold_blind.py +654 -0
- infinity_context_server/memory_comparison_gold_blind_answer_contract.py +492 -0
- infinity_context_server/memory_comparison_gold_blind_contract.py +760 -0
- infinity_context_server/memory_comparison_gold_blind_dispatch_models.py +34 -0
- infinity_context_server/memory_comparison_gold_blind_execution_validation.py +170 -0
- infinity_context_server/memory_comparison_gold_blind_judge_binding.py +167 -0
- infinity_context_server/memory_comparison_gold_blind_judge_capability.py +387 -0
- infinity_context_server/memory_comparison_gold_blind_retrieval_contract.py +413 -0
- infinity_context_server/memory_comparison_gold_blind_run_proof.py +880 -0
- infinity_context_server/memory_comparison_gold_blind_run_validation.py +109 -0
- infinity_context_server/memory_comparison_gold_blind_validation.py +319 -0
- infinity_context_server/memory_comparison_http.py +921 -0
- infinity_context_server/memory_comparison_http_ingest_observation.py +710 -0
- infinity_context_server/memory_comparison_http_ingest_request.py +204 -0
- infinity_context_server/memory_comparison_intent.py +2925 -0
- infinity_context_server/memory_comparison_latency.py +455 -0
- infinity_context_server/memory_comparison_llm.py +473 -0
- infinity_context_server/memory_comparison_location_roles.py +169 -0
- infinity_context_server/memory_comparison_locomo_cases.py +328 -0
- infinity_context_server/memory_comparison_locomo_expected_turn.py +297 -0
- infinity_context_server/memory_comparison_locomo_transport.py +873 -0
- infinity_context_server/memory_comparison_longmemeval_cases.py +339 -0
- infinity_context_server/memory_comparison_managed_attestation.py +771 -0
- infinity_context_server/memory_comparison_managed_benchmark_registry_abort_http.py +120 -0
- infinity_context_server/memory_comparison_managed_benchmark_registry_contracts.py +715 -0
- infinity_context_server/memory_comparison_managed_benchmark_registry_http.py +855 -0
- infinity_context_server/memory_comparison_managed_benchmark_registry_recovery_http.py +164 -0
- infinity_context_server/memory_comparison_managed_benchmark_registry_wire.py +890 -0
- infinity_context_server/memory_comparison_managed_composite_assembler.py +524 -0
- infinity_context_server/memory_comparison_managed_corpus_projection.py +653 -0
- infinity_context_server/memory_comparison_managed_execution_receipts.py +991 -0
- infinity_context_server/memory_comparison_managed_http_derived_evidence.py +724 -0
- infinity_context_server/memory_comparison_managed_http_exact_cleanup.py +476 -0
- infinity_context_server/memory_comparison_managed_http_execution.py +673 -0
- infinity_context_server/memory_comparison_managed_http_lifecycle.py +905 -0
- infinity_context_server/memory_comparison_managed_http_lifecycle_credentials.py +83 -0
- infinity_context_server/memory_comparison_managed_http_lifecycle_evidence.py +366 -0
- infinity_context_server/memory_comparison_managed_http_lifecycle_registration.py +106 -0
- infinity_context_server/memory_comparison_managed_http_policy_lifecycle.py +894 -0
- infinity_context_server/memory_comparison_managed_http_policy_material_projection.py +315 -0
- infinity_context_server/memory_comparison_managed_http_policy_receipts.py +219 -0
- infinity_context_server/memory_comparison_managed_http_policy_registry_evidence.py +177 -0
- infinity_context_server/memory_comparison_managed_http_policy_requirements.py +824 -0
- infinity_context_server/memory_comparison_managed_http_policy_support.py +108 -0
- infinity_context_server/memory_comparison_managed_http_policy_validation.py +762 -0
- infinity_context_server/memory_comparison_managed_ingest_manifest.py +449 -0
- infinity_context_server/memory_comparison_managed_live_admission.py +886 -0
- infinity_context_server/memory_comparison_managed_live_cli.py +536 -0
- infinity_context_server/memory_comparison_managed_live_composition.py +636 -0
- infinity_context_server/memory_comparison_managed_llm_execution.py +850 -0
- infinity_context_server/memory_comparison_managed_llm_execution_dispatch.py +269 -0
- infinity_context_server/memory_comparison_managed_llm_execution_ports.py +225 -0
- infinity_context_server/memory_comparison_managed_mem0_auth.py +65 -0
- infinity_context_server/memory_comparison_managed_mem0_runtime_authority.py +241 -0
- infinity_context_server/memory_comparison_managed_mem0_runtime_http.py +541 -0
- infinity_context_server/memory_comparison_managed_plan_builder.py +685 -0
- infinity_context_server/memory_comparison_managed_preflight.py +907 -0
- infinity_context_server/memory_comparison_managed_preflight_cli.py +431 -0
- infinity_context_server/memory_comparison_managed_production_cli.py +325 -0
- infinity_context_server/memory_comparison_managed_production_composition.py +140 -0
- infinity_context_server/memory_comparison_managed_production_ports.py +194 -0
- infinity_context_server/memory_comparison_managed_production_runner.py +450 -0
- infinity_context_server/memory_comparison_managed_projection_manifest.py +438 -0
- infinity_context_server/memory_comparison_managed_provider_calls.py +450 -0
- infinity_context_server/memory_comparison_managed_quality_projection.py +347 -0
- infinity_context_server/memory_comparison_managed_registry_policy_lifecycle.py +677 -0
- infinity_context_server/memory_comparison_managed_run.py +892 -0
- infinity_context_server/memory_comparison_managed_run_contract.py +454 -0
- infinity_context_server/memory_comparison_managed_run_ports.py +79 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials.py +916 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials_capability.py +361 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials_context.py +132 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials_integrity.py +213 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials_models.py +81 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials_targets.py +28 -0
- infinity_context_server/memory_comparison_mem0_contract.py +491 -0
- infinity_context_server/memory_comparison_mem0_http_observation.py +296 -0
- infinity_context_server/memory_comparison_mem0_locomo_prompts.py +328 -0
- infinity_context_server/memory_comparison_mem0_longmemeval_prompts.py +365 -0
- infinity_context_server/memory_comparison_mem0_official_chat.py +504 -0
- infinity_context_server/memory_comparison_mem0_official_prompt_renderer.py +307 -0
- infinity_context_server/memory_comparison_mem0_oss_contract.py +456 -0
- infinity_context_server/memory_comparison_mem0_oss_manifest.py +563 -0
- infinity_context_server/memory_comparison_mem0_platform_contract.py +467 -0
- infinity_context_server/memory_comparison_mem0_runtime_attestation.py +861 -0
- infinity_context_server/memory_comparison_models.py +398 -0
- infinity_context_server/memory_comparison_openai_official_transport.py +525 -0
- infinity_context_server/memory_comparison_preflight.py +1147 -0
- infinity_context_server/memory_comparison_probe_transport.py +154 -0
- infinity_context_server/memory_comparison_prompt_policy.py +603 -0
- infinity_context_server/memory_comparison_provider_provenance.py +392 -0
- infinity_context_server/memory_comparison_quality_accessors.py +339 -0
- infinity_context_server/memory_comparison_quality_actionable_gaps.py +2038 -0
- infinity_context_server/memory_comparison_quality_answer_context_gaps.py +450 -0
- infinity_context_server/memory_comparison_quality_answer_context_risks.py +75 -0
- infinity_context_server/memory_comparison_quality_bundle_gaps.py +860 -0
- infinity_context_server/memory_comparison_quality_bundle_table.py +805 -0
- infinity_context_server/memory_comparison_quality_diagnostics.py +2798 -0
- infinity_context_server/memory_comparison_quality_fusion.py +241 -0
- infinity_context_server/memory_comparison_quality_query_plan_gaps.py +533 -0
- infinity_context_server/memory_comparison_quality_query_role_gaps.py +845 -0
- infinity_context_server/memory_comparison_quality_query_roles.py +815 -0
- infinity_context_server/memory_comparison_quality_rerank_gaps.py +492 -0
- infinity_context_server/memory_comparison_quality_selected_weakness.py +544 -0
- infinity_context_server/memory_comparison_quality_support.py +921 -0
- infinity_context_server/memory_comparison_query_integrity.py +301 -0
- infinity_context_server/memory_comparison_query_plan.py +524 -0
- infinity_context_server/memory_comparison_query_terms.py +2055 -0
- infinity_context_server/memory_comparison_relation_support.py +2100 -0
- infinity_context_server/memory_comparison_rerank.py +3209 -0
- infinity_context_server/memory_comparison_rerank_intents.py +405 -0
- infinity_context_server/memory_comparison_rerank_policies.py +1726 -0
- infinity_context_server/memory_comparison_rerank_policy.py +675 -0
- infinity_context_server/memory_comparison_rerank_shapes.py +152 -0
- infinity_context_server/memory_comparison_rerank_terms.py +973 -0
- infinity_context_server/memory_comparison_rerank_text.py +722 -0
- infinity_context_server/memory_comparison_retrieval_policy.py +108 -0
- infinity_context_server/memory_comparison_retrieval_width.py +383 -0
- infinity_context_server/memory_comparison_service_probe.py +278 -0
- infinity_context_server/memory_comparison_service_probes.py +547 -0
- infinity_context_server/memory_comparison_session_identity_contract.py +328 -0
- infinity_context_server/memory_comparison_source_identity.py +1655 -0
- infinity_context_server/memory_comparison_subscription_chat.py +717 -0
- infinity_context_server/memory_comparison_subscription_live_probe.py +323 -0
- infinity_context_server/memory_comparison_subscription_probe.py +368 -0
- infinity_context_server/memory_comparison_target_identity.py +42 -0
- infinity_context_server/memory_comparison_temporal_grounding.py +771 -0
- infinity_context_server/memory_comparison_token_budget_contract.py +665 -0
- infinity_context_server/memory_comparison_token_latency.py +136 -0
- infinity_context_server/memory_scope_transfer.py +933 -0
- infinity_context_server/memory_scope_transfer_assets.py +181 -0
- infinity_context_server/memory_scope_transfer_conflicts.py +565 -0
- infinity_context_server/memory_scope_transfer_context.py +295 -0
- infinity_context_server/memory_scope_transfer_extractions.py +390 -0
- infinity_context_server/memory_scope_transfer_facts.py +65 -0
- infinity_context_server/memory_scope_transfer_records.py +630 -0
- infinity_context_server/memory_scope_transfer_relations.py +84 -0
- infinity_context_server/memory_scope_transfer_remap.py +710 -0
- infinity_context_server/memory_scope_transfer_scope.py +267 -0
- infinity_context_server/memory_scope_transfer_support.py +108 -0
- infinity_context_server/memory_scope_transfer_temporal.py +24 -0
- infinity_context_server/metrics.py +264 -0
- infinity_context_server/official_public_benchmark.py +979 -0
- infinity_context_server/pagination.py +60 -0
- infinity_context_server/processes/__init__.py +38 -0
- infinity_context_server/processes/extractions.py +40 -0
- infinity_context_server/processes/outbox.py +47 -0
- infinity_context_server/processes/projections.py +372 -0
- infinity_context_server/provider_budget.py +59 -0
- infinity_context_server/provider_circuit.py +333 -0
- infinity_context_server/public_benchmark.py +2532 -0
- infinity_context_server/public_benchmark_artifacts.py +91 -0
- infinity_context_server/public_benchmark_case_diagnostics.py +231 -0
- infinity_context_server/public_benchmark_checkpoint.py +751 -0
- infinity_context_server/public_benchmark_environment.py +102 -0
- infinity_context_server/public_benchmark_execution.py +445 -0
- infinity_context_server/public_benchmark_http.py +39 -0
- infinity_context_server/public_benchmark_manifest.py +129 -0
- infinity_context_server/public_benchmark_metrics.py +645 -0
- infinity_context_server/public_benchmark_metrics_policy.py +117 -0
- infinity_context_server/public_benchmark_models.py +112 -0
- infinity_context_server/public_benchmark_progress.py +224 -0
- infinity_context_server/public_benchmark_results.py +76 -0
- infinity_context_server/public_benchmark_run_diagnostics.py +163 -0
- infinity_context_server/public_benchmark_selection.py +379 -0
- infinity_context_server/public_benchmark_transport.py +62 -0
- infinity_context_server/public_benchmark_unsupported.py +228 -0
- infinity_context_server/ranked_evidence_answer_support.py +665 -0
- infinity_context_server/ranked_evidence_document_seed_contract.py +30 -0
- infinity_context_server/ranked_evidence_evaluator_helpers.py +135 -0
- infinity_context_server/ranked_evidence_retrieval_request.py +36 -0
- infinity_context_server/ranked_evidence_seed_case.py +109 -0
- infinity_context_server/ranked_evidence_semantic_gate.py +980 -0
- infinity_context_server/ranked_evidence_semantic_gate_cli.py +137 -0
- infinity_context_server/ranked_evidence_semantic_gate_decision.py +163 -0
- infinity_context_server/ranked_evidence_semantic_metrics.py +375 -0
- infinity_context_server/ranked_evidence_session_identity.py +100 -0
- infinity_context_server/storage_maintenance.py +187 -0
- infinity_context_server/top_evidence_dataset_profile.py +442 -0
- infinity_context_server/top_evidence_policy.py +274 -0
- infinity_context_server/top_evidence_preflight.py +693 -0
- infinity_context_server/web/assets/memory-browser-capture.js +252 -0
- infinity_context_server/web/assets/memory-browser-operations.js +143 -0
- infinity_context_server/web/assets/memory-browser-review.js +687 -0
- infinity_context_server/web/assets/memory-browser.css +854 -0
- infinity_context_server/web/assets/memory-browser.js +3299 -0
- infinity_context_server/web/index.html +261 -0
- infinity_context_server/web_ui.py +29 -0
- infinity_context_server/worker.py +380 -0
|
@@ -0,0 +1,2055 @@
|
|
|
1
|
+
"""Question-only query-term planning helpers for memory comparison."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Sequence
|
|
6
|
+
|
|
7
|
+
from infinity_context_server.memory_comparison_rerank_text import (
|
|
8
|
+
QUERY_STOPWORDS as _QUERY_STOPWORDS,
|
|
9
|
+
)
|
|
10
|
+
from infinity_context_server.memory_comparison_rerank_text import (
|
|
11
|
+
QUERY_TOKEN_ALIASES as _QUERY_TOKEN_ALIASES,
|
|
12
|
+
)
|
|
13
|
+
from infinity_context_server.memory_comparison_rerank_text import (
|
|
14
|
+
normalized_terms as _normalized_terms,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
_HIGH_SIGNAL_RELATION_VARIANTS = {
|
|
18
|
+
"amazing",
|
|
19
|
+
"awesome",
|
|
20
|
+
"camping",
|
|
21
|
+
"care",
|
|
22
|
+
"cancel",
|
|
23
|
+
"cancelled",
|
|
24
|
+
"classical",
|
|
25
|
+
"conservative",
|
|
26
|
+
"brother",
|
|
27
|
+
"boyfriend",
|
|
28
|
+
"cousin",
|
|
29
|
+
"dating",
|
|
30
|
+
"daughter",
|
|
31
|
+
"dinosaur",
|
|
32
|
+
"engaged",
|
|
33
|
+
"faith",
|
|
34
|
+
"fiance",
|
|
35
|
+
"fiancee",
|
|
36
|
+
"girlfriend",
|
|
37
|
+
"grandfather",
|
|
38
|
+
"grandmother",
|
|
39
|
+
"husband",
|
|
40
|
+
"father",
|
|
41
|
+
"inclusive",
|
|
42
|
+
"inclusivity",
|
|
43
|
+
"hiking",
|
|
44
|
+
"known",
|
|
45
|
+
"lgbtq",
|
|
46
|
+
"love",
|
|
47
|
+
"mental",
|
|
48
|
+
"mom",
|
|
49
|
+
"mother",
|
|
50
|
+
"nature",
|
|
51
|
+
"important",
|
|
52
|
+
"parent",
|
|
53
|
+
"partner",
|
|
54
|
+
"real",
|
|
55
|
+
"reschedule",
|
|
56
|
+
"rescheduled",
|
|
57
|
+
"right",
|
|
58
|
+
"rights",
|
|
59
|
+
"self-care",
|
|
60
|
+
"sister",
|
|
61
|
+
"son",
|
|
62
|
+
"spouse",
|
|
63
|
+
"strength",
|
|
64
|
+
"sunrise",
|
|
65
|
+
"transgender",
|
|
66
|
+
"trail",
|
|
67
|
+
"trip",
|
|
68
|
+
"wed",
|
|
69
|
+
"wedding",
|
|
70
|
+
"wife",
|
|
71
|
+
"writing",
|
|
72
|
+
"year",
|
|
73
|
+
}
|
|
74
|
+
_CONTRAST_RELATION_MARKER_TERMS = frozenset(
|
|
75
|
+
{"compare", "different", "difference", "former", "previous"}
|
|
76
|
+
)
|
|
77
|
+
_CONTRAST_SUPPORT_QUERY_SURFACES = frozenset(
|
|
78
|
+
{
|
|
79
|
+
"alternative",
|
|
80
|
+
"before",
|
|
81
|
+
"chang",
|
|
82
|
+
"change",
|
|
83
|
+
"changed",
|
|
84
|
+
"compare",
|
|
85
|
+
"current",
|
|
86
|
+
"currently",
|
|
87
|
+
"difference",
|
|
88
|
+
"different",
|
|
89
|
+
"earlier",
|
|
90
|
+
"former",
|
|
91
|
+
"formerly",
|
|
92
|
+
"instead",
|
|
93
|
+
"less",
|
|
94
|
+
"more",
|
|
95
|
+
"now",
|
|
96
|
+
"ongoing",
|
|
97
|
+
"prefer",
|
|
98
|
+
"preferred",
|
|
99
|
+
"previous",
|
|
100
|
+
"previously",
|
|
101
|
+
"used",
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
_CONTRAST_QUERY_VARIANT_BLOCKLIST = frozenset(
|
|
105
|
+
{"been", "existing", "known", "year", "years"}
|
|
106
|
+
)
|
|
107
|
+
_CONTRAST_CURRENTNESS_BACKFILL = ("current", "now", "ongoing")
|
|
108
|
+
_CONTRAST_STALE_BACKFILL = ("previous", "before", "earlier", "used")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _support_query_terms(
|
|
112
|
+
*,
|
|
113
|
+
relation_terms: tuple[str, ...],
|
|
114
|
+
relation_variant_terms: tuple[str, ...],
|
|
115
|
+
lexical_terms: tuple[str, ...],
|
|
116
|
+
entity_surfaces: tuple[str, ...],
|
|
117
|
+
action_support: bool,
|
|
118
|
+
communication_support: bool,
|
|
119
|
+
commitment_support: bool,
|
|
120
|
+
contact_support: bool,
|
|
121
|
+
diet_support: bool,
|
|
122
|
+
education_support: bool,
|
|
123
|
+
employment_support: bool,
|
|
124
|
+
age_support: bool,
|
|
125
|
+
alias_support: bool,
|
|
126
|
+
health_support: bool,
|
|
127
|
+
pet_support: bool,
|
|
128
|
+
preference_support: bool,
|
|
129
|
+
skill_support: bool,
|
|
130
|
+
vehicle_support: bool,
|
|
131
|
+
) -> tuple[str, ...]:
|
|
132
|
+
if action_support:
|
|
133
|
+
return _action_support_query_terms(
|
|
134
|
+
relation_terms=relation_terms,
|
|
135
|
+
relation_variant_terms=relation_variant_terms,
|
|
136
|
+
lexical_terms=lexical_terms,
|
|
137
|
+
entity_surfaces=entity_surfaces,
|
|
138
|
+
)
|
|
139
|
+
if communication_support:
|
|
140
|
+
return _communication_support_query_terms(
|
|
141
|
+
relation_terms=relation_terms,
|
|
142
|
+
relation_variant_terms=relation_variant_terms,
|
|
143
|
+
lexical_terms=lexical_terms,
|
|
144
|
+
entity_surfaces=entity_surfaces,
|
|
145
|
+
)
|
|
146
|
+
if commitment_support:
|
|
147
|
+
return _commitment_support_query_terms(
|
|
148
|
+
relation_terms=relation_terms,
|
|
149
|
+
relation_variant_terms=relation_variant_terms,
|
|
150
|
+
lexical_terms=lexical_terms,
|
|
151
|
+
entity_surfaces=entity_surfaces,
|
|
152
|
+
)
|
|
153
|
+
if contact_support:
|
|
154
|
+
return _contact_support_query_terms(
|
|
155
|
+
relation_terms=relation_terms,
|
|
156
|
+
relation_variant_terms=relation_variant_terms,
|
|
157
|
+
lexical_terms=lexical_terms,
|
|
158
|
+
entity_surfaces=entity_surfaces,
|
|
159
|
+
)
|
|
160
|
+
if diet_support:
|
|
161
|
+
return _diet_support_query_terms(
|
|
162
|
+
relation_terms=relation_terms,
|
|
163
|
+
relation_variant_terms=relation_variant_terms,
|
|
164
|
+
lexical_terms=lexical_terms,
|
|
165
|
+
entity_surfaces=entity_surfaces,
|
|
166
|
+
)
|
|
167
|
+
if education_support:
|
|
168
|
+
return _education_support_query_terms(
|
|
169
|
+
relation_terms=relation_terms,
|
|
170
|
+
relation_variant_terms=relation_variant_terms,
|
|
171
|
+
lexical_terms=lexical_terms,
|
|
172
|
+
entity_surfaces=entity_surfaces,
|
|
173
|
+
)
|
|
174
|
+
if employment_support:
|
|
175
|
+
return _employment_support_query_terms(
|
|
176
|
+
relation_terms=relation_terms,
|
|
177
|
+
relation_variant_terms=relation_variant_terms,
|
|
178
|
+
lexical_terms=lexical_terms,
|
|
179
|
+
entity_surfaces=entity_surfaces,
|
|
180
|
+
)
|
|
181
|
+
if age_support:
|
|
182
|
+
return _age_support_query_terms(
|
|
183
|
+
relation_terms=relation_terms,
|
|
184
|
+
relation_variant_terms=relation_variant_terms,
|
|
185
|
+
lexical_terms=lexical_terms,
|
|
186
|
+
entity_surfaces=entity_surfaces,
|
|
187
|
+
)
|
|
188
|
+
if alias_support:
|
|
189
|
+
return _alias_support_query_terms(
|
|
190
|
+
relation_terms=relation_terms,
|
|
191
|
+
relation_variant_terms=relation_variant_terms,
|
|
192
|
+
lexical_terms=lexical_terms,
|
|
193
|
+
entity_surfaces=entity_surfaces,
|
|
194
|
+
)
|
|
195
|
+
if health_support:
|
|
196
|
+
return _health_support_query_terms(
|
|
197
|
+
relation_terms=relation_terms,
|
|
198
|
+
relation_variant_terms=relation_variant_terms,
|
|
199
|
+
lexical_terms=lexical_terms,
|
|
200
|
+
entity_surfaces=entity_surfaces,
|
|
201
|
+
)
|
|
202
|
+
if pet_support:
|
|
203
|
+
return _pet_support_query_terms(
|
|
204
|
+
relation_terms=relation_terms,
|
|
205
|
+
relation_variant_terms=relation_variant_terms,
|
|
206
|
+
lexical_terms=lexical_terms,
|
|
207
|
+
entity_surfaces=entity_surfaces,
|
|
208
|
+
)
|
|
209
|
+
if preference_support:
|
|
210
|
+
return _preference_support_query_terms(
|
|
211
|
+
relation_terms=relation_terms,
|
|
212
|
+
relation_variant_terms=relation_variant_terms,
|
|
213
|
+
lexical_terms=lexical_terms,
|
|
214
|
+
entity_surfaces=entity_surfaces,
|
|
215
|
+
)
|
|
216
|
+
if skill_support:
|
|
217
|
+
return _skill_support_query_terms(
|
|
218
|
+
relation_terms=relation_terms,
|
|
219
|
+
relation_variant_terms=relation_variant_terms,
|
|
220
|
+
lexical_terms=lexical_terms,
|
|
221
|
+
entity_surfaces=entity_surfaces,
|
|
222
|
+
)
|
|
223
|
+
if vehicle_support:
|
|
224
|
+
return _vehicle_support_query_terms(
|
|
225
|
+
relation_terms=relation_terms,
|
|
226
|
+
relation_variant_terms=relation_variant_terms,
|
|
227
|
+
lexical_terms=lexical_terms,
|
|
228
|
+
entity_surfaces=entity_surfaces,
|
|
229
|
+
)
|
|
230
|
+
relation_term_set = set(relation_terms)
|
|
231
|
+
if (
|
|
232
|
+
(
|
|
233
|
+
{"live", "move", "relocate", "relocated"}
|
|
234
|
+
& relation_term_set
|
|
235
|
+
or (
|
|
236
|
+
"stay" in relation_term_set
|
|
237
|
+
and {"where", "from", "city", "country", "place", "origin"}
|
|
238
|
+
& set(lexical_terms)
|
|
239
|
+
)
|
|
240
|
+
)
|
|
241
|
+
and not {"current", "plan", "want"} & relation_term_set
|
|
242
|
+
):
|
|
243
|
+
return _location_support_query_terms(
|
|
244
|
+
relation_terms=relation_terms,
|
|
245
|
+
relation_variant_terms=relation_variant_terms,
|
|
246
|
+
lexical_terms=lexical_terms,
|
|
247
|
+
)
|
|
248
|
+
if {"sign", "enroll", "register", "conference"} & relation_term_set:
|
|
249
|
+
return _topical_relation_query_terms(
|
|
250
|
+
relation_terms=relation_terms,
|
|
251
|
+
relation_variant_terms=relation_variant_terms,
|
|
252
|
+
lexical_terms=lexical_terms,
|
|
253
|
+
entity_surfaces=entity_surfaces,
|
|
254
|
+
topic_after=1 if "conference" in relation_terms else 4,
|
|
255
|
+
)
|
|
256
|
+
return _relation_query_terms(relation_terms, relation_variant_terms)
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def _action_support_query_terms(
|
|
260
|
+
*,
|
|
261
|
+
relation_terms: tuple[str, ...],
|
|
262
|
+
relation_variant_terms: tuple[str, ...],
|
|
263
|
+
lexical_terms: tuple[str, ...],
|
|
264
|
+
entity_surfaces: tuple[str, ...],
|
|
265
|
+
) -> tuple[str, ...]:
|
|
266
|
+
entity_tokens = {
|
|
267
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
268
|
+
}
|
|
269
|
+
action_surfaces = {
|
|
270
|
+
"action",
|
|
271
|
+
"book",
|
|
272
|
+
"booked",
|
|
273
|
+
"bring",
|
|
274
|
+
"brought",
|
|
275
|
+
"complete",
|
|
276
|
+
"completed",
|
|
277
|
+
"create",
|
|
278
|
+
"created",
|
|
279
|
+
"draw",
|
|
280
|
+
"drew",
|
|
281
|
+
"fix",
|
|
282
|
+
"fixed",
|
|
283
|
+
"made",
|
|
284
|
+
"make",
|
|
285
|
+
"paint",
|
|
286
|
+
"painted",
|
|
287
|
+
"prepare",
|
|
288
|
+
"prepared",
|
|
289
|
+
"repair",
|
|
290
|
+
"repaired",
|
|
291
|
+
"schedule",
|
|
292
|
+
"scheduled",
|
|
293
|
+
"send",
|
|
294
|
+
"sent",
|
|
295
|
+
"share",
|
|
296
|
+
"shared",
|
|
297
|
+
"take",
|
|
298
|
+
"took",
|
|
299
|
+
}
|
|
300
|
+
lexical_action_terms = tuple(
|
|
301
|
+
term for term in lexical_terms if term in action_surfaces
|
|
302
|
+
)
|
|
303
|
+
topical_terms = tuple(
|
|
304
|
+
term
|
|
305
|
+
for term in lexical_terms
|
|
306
|
+
if term not in _QUERY_STOPWORDS
|
|
307
|
+
and term not in relation_terms
|
|
308
|
+
and term not in relation_variant_terms
|
|
309
|
+
and term not in _QUERY_TOKEN_ALIASES
|
|
310
|
+
and term not in entity_tokens
|
|
311
|
+
)
|
|
312
|
+
return tuple(
|
|
313
|
+
dict.fromkeys(
|
|
314
|
+
(
|
|
315
|
+
*(term for term in relation_terms if term == "action"),
|
|
316
|
+
*lexical_action_terms,
|
|
317
|
+
*topical_terms[:5],
|
|
318
|
+
*(
|
|
319
|
+
term
|
|
320
|
+
for term in relation_variant_terms
|
|
321
|
+
if term in action_surfaces and term not in lexical_action_terms
|
|
322
|
+
),
|
|
323
|
+
)
|
|
324
|
+
)
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def _commitment_support_query_terms(
|
|
329
|
+
*,
|
|
330
|
+
relation_terms: tuple[str, ...],
|
|
331
|
+
relation_variant_terms: tuple[str, ...],
|
|
332
|
+
lexical_terms: tuple[str, ...],
|
|
333
|
+
entity_surfaces: tuple[str, ...],
|
|
334
|
+
) -> tuple[str, ...]:
|
|
335
|
+
entity_tokens = {
|
|
336
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
337
|
+
}
|
|
338
|
+
commitment_terms = {
|
|
339
|
+
"bring",
|
|
340
|
+
"cancel",
|
|
341
|
+
"canceled",
|
|
342
|
+
"cancelled",
|
|
343
|
+
"commit",
|
|
344
|
+
"committed",
|
|
345
|
+
"complete",
|
|
346
|
+
"date",
|
|
347
|
+
"deadline",
|
|
348
|
+
"due",
|
|
349
|
+
"finish",
|
|
350
|
+
"need",
|
|
351
|
+
"promise",
|
|
352
|
+
"promised",
|
|
353
|
+
"remember",
|
|
354
|
+
"reminder",
|
|
355
|
+
"reschedule",
|
|
356
|
+
"rescheduled",
|
|
357
|
+
"task",
|
|
358
|
+
"to-do",
|
|
359
|
+
"todo",
|
|
360
|
+
}
|
|
361
|
+
topical_terms = tuple(
|
|
362
|
+
term
|
|
363
|
+
for term in lexical_terms
|
|
364
|
+
if term not in _QUERY_STOPWORDS
|
|
365
|
+
and term not in relation_terms
|
|
366
|
+
and term not in relation_variant_terms
|
|
367
|
+
and term not in entity_tokens
|
|
368
|
+
)
|
|
369
|
+
return tuple(
|
|
370
|
+
dict.fromkeys(
|
|
371
|
+
(
|
|
372
|
+
*(
|
|
373
|
+
term
|
|
374
|
+
for term in relation_terms
|
|
375
|
+
if term
|
|
376
|
+
in {
|
|
377
|
+
"cancel",
|
|
378
|
+
"deadline",
|
|
379
|
+
"promise",
|
|
380
|
+
"remember",
|
|
381
|
+
"reschedule",
|
|
382
|
+
"task",
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
*(term for term in relation_variant_terms if term in commitment_terms),
|
|
386
|
+
*topical_terms[:4],
|
|
387
|
+
)
|
|
388
|
+
)
|
|
389
|
+
)
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def _contact_support_query_terms(
|
|
393
|
+
*,
|
|
394
|
+
relation_terms: tuple[str, ...],
|
|
395
|
+
relation_variant_terms: tuple[str, ...],
|
|
396
|
+
lexical_terms: tuple[str, ...],
|
|
397
|
+
entity_surfaces: tuple[str, ...],
|
|
398
|
+
) -> tuple[str, ...]:
|
|
399
|
+
entity_tokens = {
|
|
400
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
401
|
+
}
|
|
402
|
+
contact_terms = {
|
|
403
|
+
"address",
|
|
404
|
+
"cell",
|
|
405
|
+
"contact",
|
|
406
|
+
"e-mail",
|
|
407
|
+
"email",
|
|
408
|
+
"mobile",
|
|
409
|
+
"number",
|
|
410
|
+
"phone",
|
|
411
|
+
"reach",
|
|
412
|
+
"reached",
|
|
413
|
+
"telephone",
|
|
414
|
+
}
|
|
415
|
+
social_contact_terms = {
|
|
416
|
+
"emergency",
|
|
417
|
+
"handle",
|
|
418
|
+
"instagram",
|
|
419
|
+
"signal",
|
|
420
|
+
"slack",
|
|
421
|
+
"telegram",
|
|
422
|
+
"username",
|
|
423
|
+
"whatsapp",
|
|
424
|
+
}
|
|
425
|
+
topical_terms = tuple(
|
|
426
|
+
term
|
|
427
|
+
for term in lexical_terms
|
|
428
|
+
if term not in _QUERY_STOPWORDS
|
|
429
|
+
and term not in relation_terms
|
|
430
|
+
and term not in relation_variant_terms
|
|
431
|
+
and (term in social_contact_terms or term not in entity_tokens)
|
|
432
|
+
)
|
|
433
|
+
return tuple(
|
|
434
|
+
dict.fromkeys(
|
|
435
|
+
(
|
|
436
|
+
*(term for term in relation_terms if term == "contact"),
|
|
437
|
+
*(term for term in topical_terms if term in social_contact_terms),
|
|
438
|
+
*(term for term in relation_variant_terms if term in contact_terms),
|
|
439
|
+
*(
|
|
440
|
+
term
|
|
441
|
+
for term in topical_terms[:4]
|
|
442
|
+
if term not in social_contact_terms
|
|
443
|
+
),
|
|
444
|
+
*(
|
|
445
|
+
term
|
|
446
|
+
for term in _relation_query_terms(
|
|
447
|
+
relation_terms,
|
|
448
|
+
relation_variant_terms,
|
|
449
|
+
)
|
|
450
|
+
if term not in contact_terms and term not in _QUERY_STOPWORDS
|
|
451
|
+
),
|
|
452
|
+
)
|
|
453
|
+
)
|
|
454
|
+
)
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
def _diet_support_query_terms(
|
|
458
|
+
*,
|
|
459
|
+
relation_terms: tuple[str, ...],
|
|
460
|
+
relation_variant_terms: tuple[str, ...],
|
|
461
|
+
lexical_terms: tuple[str, ...],
|
|
462
|
+
entity_surfaces: tuple[str, ...],
|
|
463
|
+
) -> tuple[str, ...]:
|
|
464
|
+
entity_tokens = {
|
|
465
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
466
|
+
}
|
|
467
|
+
diet_terms = {
|
|
468
|
+
"avoid",
|
|
469
|
+
"dairy",
|
|
470
|
+
"diet",
|
|
471
|
+
"dietary",
|
|
472
|
+
"eat",
|
|
473
|
+
"egg",
|
|
474
|
+
"eggs",
|
|
475
|
+
"food",
|
|
476
|
+
"gluten",
|
|
477
|
+
"lactose",
|
|
478
|
+
"meat",
|
|
479
|
+
"pork",
|
|
480
|
+
"restriction",
|
|
481
|
+
"seafood",
|
|
482
|
+
"soy",
|
|
483
|
+
"vegan",
|
|
484
|
+
"vegetarian",
|
|
485
|
+
}
|
|
486
|
+
topical_terms = tuple(
|
|
487
|
+
term
|
|
488
|
+
for term in lexical_terms
|
|
489
|
+
if term not in _QUERY_STOPWORDS
|
|
490
|
+
and term not in relation_terms
|
|
491
|
+
and term not in relation_variant_terms
|
|
492
|
+
and term not in entity_tokens
|
|
493
|
+
)
|
|
494
|
+
return tuple(
|
|
495
|
+
dict.fromkeys(
|
|
496
|
+
(
|
|
497
|
+
*(term for term in relation_terms if term == "diet"),
|
|
498
|
+
*(term for term in relation_variant_terms if term in diet_terms),
|
|
499
|
+
*topical_terms[:4],
|
|
500
|
+
*(
|
|
501
|
+
term
|
|
502
|
+
for term in _relation_query_terms(
|
|
503
|
+
relation_terms,
|
|
504
|
+
relation_variant_terms,
|
|
505
|
+
)
|
|
506
|
+
if term not in diet_terms and term not in _QUERY_STOPWORDS
|
|
507
|
+
),
|
|
508
|
+
)
|
|
509
|
+
)
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
def _education_support_query_terms(
|
|
514
|
+
*,
|
|
515
|
+
relation_terms: tuple[str, ...],
|
|
516
|
+
relation_variant_terms: tuple[str, ...],
|
|
517
|
+
lexical_terms: tuple[str, ...],
|
|
518
|
+
entity_surfaces: tuple[str, ...],
|
|
519
|
+
) -> tuple[str, ...]:
|
|
520
|
+
entity_tokens = {
|
|
521
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
522
|
+
}
|
|
523
|
+
education_terms = {
|
|
524
|
+
"campu",
|
|
525
|
+
"campus",
|
|
526
|
+
"class",
|
|
527
|
+
"college",
|
|
528
|
+
"course",
|
|
529
|
+
"degree",
|
|
530
|
+
"education",
|
|
531
|
+
"graduat",
|
|
532
|
+
"graduate",
|
|
533
|
+
"graduated",
|
|
534
|
+
"graduation",
|
|
535
|
+
"major",
|
|
536
|
+
"majoring",
|
|
537
|
+
"school",
|
|
538
|
+
"studies",
|
|
539
|
+
"study",
|
|
540
|
+
"studying",
|
|
541
|
+
"university",
|
|
542
|
+
}
|
|
543
|
+
credential_terms = {"degree", "major", "majoring"}
|
|
544
|
+
credential_focus = bool(credential_terms & set(lexical_terms))
|
|
545
|
+
graduate_terms = {"graduat", "graduate", "graduated", "graduation"}
|
|
546
|
+
graduate_focus = bool(graduate_terms & set(lexical_terms))
|
|
547
|
+
relation_action_terms = {"attend", "education", "go", "school"}
|
|
548
|
+
topical_terms = tuple(
|
|
549
|
+
term
|
|
550
|
+
for term in lexical_terms
|
|
551
|
+
if term not in _QUERY_STOPWORDS
|
|
552
|
+
and term not in relation_terms
|
|
553
|
+
and term not in relation_variant_terms
|
|
554
|
+
and term not in entity_tokens
|
|
555
|
+
)
|
|
556
|
+
return tuple(
|
|
557
|
+
dict.fromkeys(
|
|
558
|
+
(
|
|
559
|
+
*(term for term in relation_terms if term in relation_action_terms),
|
|
560
|
+
*(
|
|
561
|
+
term
|
|
562
|
+
for term in relation_variant_terms
|
|
563
|
+
if graduate_focus and term in graduate_terms
|
|
564
|
+
),
|
|
565
|
+
*(
|
|
566
|
+
term
|
|
567
|
+
for term in relation_variant_terms
|
|
568
|
+
if credential_focus and term in credential_terms
|
|
569
|
+
),
|
|
570
|
+
*(
|
|
571
|
+
term
|
|
572
|
+
for term in relation_variant_terms
|
|
573
|
+
if term in education_terms
|
|
574
|
+
and not (credential_focus and term in credential_terms)
|
|
575
|
+
and not (graduate_focus and term in graduate_terms)
|
|
576
|
+
),
|
|
577
|
+
*topical_terms[:4],
|
|
578
|
+
*(
|
|
579
|
+
term
|
|
580
|
+
for term in _relation_query_terms(
|
|
581
|
+
relation_terms,
|
|
582
|
+
relation_variant_terms,
|
|
583
|
+
)
|
|
584
|
+
if term not in education_terms and term not in _QUERY_STOPWORDS
|
|
585
|
+
),
|
|
586
|
+
)
|
|
587
|
+
)
|
|
588
|
+
)
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
def _employment_support_query_terms(
|
|
592
|
+
*,
|
|
593
|
+
relation_terms: tuple[str, ...],
|
|
594
|
+
relation_variant_terms: tuple[str, ...],
|
|
595
|
+
lexical_terms: tuple[str, ...],
|
|
596
|
+
entity_surfaces: tuple[str, ...],
|
|
597
|
+
) -> tuple[str, ...]:
|
|
598
|
+
entity_tokens = {
|
|
599
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
600
|
+
}
|
|
601
|
+
employment_terms = {
|
|
602
|
+
"career",
|
|
603
|
+
"company",
|
|
604
|
+
"employer",
|
|
605
|
+
"employment",
|
|
606
|
+
"job",
|
|
607
|
+
"occupation",
|
|
608
|
+
"office",
|
|
609
|
+
"pay",
|
|
610
|
+
"profession",
|
|
611
|
+
"rate",
|
|
612
|
+
"role",
|
|
613
|
+
"salary",
|
|
614
|
+
"wage",
|
|
615
|
+
"work",
|
|
616
|
+
"worked",
|
|
617
|
+
"working",
|
|
618
|
+
"workplace",
|
|
619
|
+
}
|
|
620
|
+
compensation_terms = {"hourly", "pay", "rate", "salary", "wage"}
|
|
621
|
+
compensation_focus = bool(compensation_terms & set(lexical_terms))
|
|
622
|
+
topical_terms = tuple(
|
|
623
|
+
term
|
|
624
|
+
for term in lexical_terms
|
|
625
|
+
if term not in _QUERY_STOPWORDS
|
|
626
|
+
and term not in relation_terms
|
|
627
|
+
and term not in relation_variant_terms
|
|
628
|
+
and term not in entity_tokens
|
|
629
|
+
)
|
|
630
|
+
return tuple(
|
|
631
|
+
dict.fromkeys(
|
|
632
|
+
(
|
|
633
|
+
*(term for term in relation_terms if term == "employment"),
|
|
634
|
+
*(
|
|
635
|
+
term
|
|
636
|
+
for term in relation_variant_terms
|
|
637
|
+
if compensation_focus and term in compensation_terms
|
|
638
|
+
),
|
|
639
|
+
*(
|
|
640
|
+
term
|
|
641
|
+
for term in relation_variant_terms
|
|
642
|
+
if term in employment_terms
|
|
643
|
+
and not (compensation_focus and term in compensation_terms)
|
|
644
|
+
and (compensation_focus or term not in compensation_terms)
|
|
645
|
+
),
|
|
646
|
+
*(
|
|
647
|
+
term
|
|
648
|
+
for term in topical_terms[:4]
|
|
649
|
+
if term not in compensation_terms
|
|
650
|
+
),
|
|
651
|
+
*(
|
|
652
|
+
term
|
|
653
|
+
for term in _relation_query_terms(
|
|
654
|
+
relation_terms,
|
|
655
|
+
relation_variant_terms,
|
|
656
|
+
)
|
|
657
|
+
if term not in employment_terms and term not in _QUERY_STOPWORDS
|
|
658
|
+
),
|
|
659
|
+
)
|
|
660
|
+
)
|
|
661
|
+
)
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
def _age_support_query_terms(
|
|
665
|
+
*,
|
|
666
|
+
relation_terms: tuple[str, ...],
|
|
667
|
+
relation_variant_terms: tuple[str, ...],
|
|
668
|
+
lexical_terms: tuple[str, ...],
|
|
669
|
+
entity_surfaces: tuple[str, ...],
|
|
670
|
+
) -> tuple[str, ...]:
|
|
671
|
+
entity_tokens = {
|
|
672
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
673
|
+
}
|
|
674
|
+
age_terms = {
|
|
675
|
+
"age",
|
|
676
|
+
"birthday",
|
|
677
|
+
"born",
|
|
678
|
+
"old",
|
|
679
|
+
"turn",
|
|
680
|
+
"turned",
|
|
681
|
+
"turning",
|
|
682
|
+
"turns",
|
|
683
|
+
"year",
|
|
684
|
+
"years",
|
|
685
|
+
}
|
|
686
|
+
topical_terms = tuple(
|
|
687
|
+
term
|
|
688
|
+
for term in lexical_terms
|
|
689
|
+
if term not in _QUERY_STOPWORDS
|
|
690
|
+
and term not in relation_terms
|
|
691
|
+
and term not in relation_variant_terms
|
|
692
|
+
and term not in entity_tokens
|
|
693
|
+
)
|
|
694
|
+
return tuple(
|
|
695
|
+
dict.fromkeys(
|
|
696
|
+
(
|
|
697
|
+
*(term for term in relation_terms if term == "age"),
|
|
698
|
+
*(term for term in relation_variant_terms if term in age_terms),
|
|
699
|
+
*topical_terms[:4],
|
|
700
|
+
)
|
|
701
|
+
)
|
|
702
|
+
)
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
def _alias_support_query_terms(
|
|
706
|
+
*,
|
|
707
|
+
relation_terms: tuple[str, ...],
|
|
708
|
+
relation_variant_terms: tuple[str, ...],
|
|
709
|
+
lexical_terms: tuple[str, ...],
|
|
710
|
+
entity_surfaces: tuple[str, ...],
|
|
711
|
+
) -> tuple[str, ...]:
|
|
712
|
+
entity_tokens = {
|
|
713
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
714
|
+
}
|
|
715
|
+
alias_terms = {
|
|
716
|
+
"alias",
|
|
717
|
+
"call",
|
|
718
|
+
"called",
|
|
719
|
+
"calls",
|
|
720
|
+
"full",
|
|
721
|
+
"legal",
|
|
722
|
+
"middle",
|
|
723
|
+
"name",
|
|
724
|
+
"named",
|
|
725
|
+
"nickname",
|
|
726
|
+
}
|
|
727
|
+
name_attribute_terms = {"full", "legal", "middle"}
|
|
728
|
+
name_attribute_focus = bool(name_attribute_terms & set(lexical_terms))
|
|
729
|
+
topical_terms = tuple(
|
|
730
|
+
term
|
|
731
|
+
for term in lexical_terms
|
|
732
|
+
if term not in _QUERY_STOPWORDS
|
|
733
|
+
and term not in relation_terms
|
|
734
|
+
and term not in relation_variant_terms
|
|
735
|
+
and term not in entity_tokens
|
|
736
|
+
)
|
|
737
|
+
return tuple(
|
|
738
|
+
dict.fromkeys(
|
|
739
|
+
(
|
|
740
|
+
*(term for term in relation_terms if term in {"call", "nickname"}),
|
|
741
|
+
*(
|
|
742
|
+
term
|
|
743
|
+
for term in topical_terms
|
|
744
|
+
if name_attribute_focus and term in name_attribute_terms
|
|
745
|
+
),
|
|
746
|
+
*(term for term in relation_variant_terms if term in alias_terms),
|
|
747
|
+
"go by",
|
|
748
|
+
*(
|
|
749
|
+
term
|
|
750
|
+
for term in topical_terms[:4]
|
|
751
|
+
if term not in name_attribute_terms
|
|
752
|
+
),
|
|
753
|
+
)
|
|
754
|
+
)
|
|
755
|
+
)
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
def _health_support_query_terms(
|
|
759
|
+
*,
|
|
760
|
+
relation_terms: tuple[str, ...],
|
|
761
|
+
relation_variant_terms: tuple[str, ...],
|
|
762
|
+
lexical_terms: tuple[str, ...],
|
|
763
|
+
entity_surfaces: tuple[str, ...],
|
|
764
|
+
) -> tuple[str, ...]:
|
|
765
|
+
entity_tokens = {
|
|
766
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
767
|
+
}
|
|
768
|
+
health_terms = {
|
|
769
|
+
"allergic",
|
|
770
|
+
"allergy",
|
|
771
|
+
"appointment",
|
|
772
|
+
"blood",
|
|
773
|
+
"clinic",
|
|
774
|
+
"condition",
|
|
775
|
+
"dental",
|
|
776
|
+
"dentist",
|
|
777
|
+
"doctor",
|
|
778
|
+
"health",
|
|
779
|
+
"medical",
|
|
780
|
+
"medication",
|
|
781
|
+
"medicine",
|
|
782
|
+
"physician",
|
|
783
|
+
"prescription",
|
|
784
|
+
"take",
|
|
785
|
+
"taking",
|
|
786
|
+
"therapist",
|
|
787
|
+
"type",
|
|
788
|
+
}
|
|
789
|
+
blood_type_terms = {
|
|
790
|
+
"blood",
|
|
791
|
+
"type",
|
|
792
|
+
}
|
|
793
|
+
blood_type_focus = blood_type_terms <= set(lexical_terms)
|
|
794
|
+
topical_terms = tuple(
|
|
795
|
+
term
|
|
796
|
+
for term in lexical_terms
|
|
797
|
+
if term not in _QUERY_STOPWORDS
|
|
798
|
+
and term not in relation_terms
|
|
799
|
+
and term not in relation_variant_terms
|
|
800
|
+
and term not in entity_tokens
|
|
801
|
+
)
|
|
802
|
+
return tuple(
|
|
803
|
+
dict.fromkeys(
|
|
804
|
+
(
|
|
805
|
+
*(term for term in relation_terms if term == "health"),
|
|
806
|
+
*(
|
|
807
|
+
term
|
|
808
|
+
for term in relation_variant_terms
|
|
809
|
+
if blood_type_focus and term in blood_type_terms
|
|
810
|
+
),
|
|
811
|
+
*(
|
|
812
|
+
term
|
|
813
|
+
for term in relation_variant_terms
|
|
814
|
+
if term in health_terms
|
|
815
|
+
and not (blood_type_focus and term in blood_type_terms)
|
|
816
|
+
),
|
|
817
|
+
*(
|
|
818
|
+
term
|
|
819
|
+
for term in topical_terms[:4]
|
|
820
|
+
if term not in blood_type_terms
|
|
821
|
+
),
|
|
822
|
+
*(
|
|
823
|
+
term
|
|
824
|
+
for term in _relation_query_terms(
|
|
825
|
+
relation_terms,
|
|
826
|
+
relation_variant_terms,
|
|
827
|
+
)
|
|
828
|
+
if term not in health_terms and term not in _QUERY_STOPWORDS
|
|
829
|
+
),
|
|
830
|
+
)
|
|
831
|
+
)
|
|
832
|
+
)
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
def _pet_support_query_terms(
|
|
836
|
+
*,
|
|
837
|
+
relation_terms: tuple[str, ...],
|
|
838
|
+
relation_variant_terms: tuple[str, ...],
|
|
839
|
+
lexical_terms: tuple[str, ...],
|
|
840
|
+
entity_surfaces: tuple[str, ...],
|
|
841
|
+
) -> tuple[str, ...]:
|
|
842
|
+
entity_tokens = {
|
|
843
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
844
|
+
}
|
|
845
|
+
lexical_term_set = set(lexical_terms)
|
|
846
|
+
pet_terms = {
|
|
847
|
+
"animal",
|
|
848
|
+
"cat",
|
|
849
|
+
"dog",
|
|
850
|
+
"kitten",
|
|
851
|
+
"name",
|
|
852
|
+
"named",
|
|
853
|
+
"pet",
|
|
854
|
+
"puppy",
|
|
855
|
+
}
|
|
856
|
+
if "bre" in lexical_term_set or "breed" in lexical_term_set:
|
|
857
|
+
pet_terms.update({"bre", "breed", "labrador", "retriever"})
|
|
858
|
+
if "microchip" in lexical_term_set:
|
|
859
|
+
pet_terms.update({"microchip", "number"})
|
|
860
|
+
topical_terms = tuple(
|
|
861
|
+
term
|
|
862
|
+
for term in lexical_terms
|
|
863
|
+
if term not in _QUERY_STOPWORDS
|
|
864
|
+
and term not in relation_terms
|
|
865
|
+
and term not in relation_variant_terms
|
|
866
|
+
and term not in entity_tokens
|
|
867
|
+
)
|
|
868
|
+
return tuple(
|
|
869
|
+
dict.fromkeys(
|
|
870
|
+
(
|
|
871
|
+
*(term for term in relation_terms if term == "pet"),
|
|
872
|
+
*(term for term in relation_variant_terms if term in pet_terms),
|
|
873
|
+
*topical_terms[:4],
|
|
874
|
+
*(
|
|
875
|
+
term
|
|
876
|
+
for term in _relation_query_terms(
|
|
877
|
+
relation_terms,
|
|
878
|
+
relation_variant_terms,
|
|
879
|
+
)
|
|
880
|
+
if term not in pet_terms and term not in _QUERY_STOPWORDS
|
|
881
|
+
),
|
|
882
|
+
)
|
|
883
|
+
)
|
|
884
|
+
)
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
def _skill_support_query_terms(
|
|
888
|
+
*,
|
|
889
|
+
relation_terms: tuple[str, ...],
|
|
890
|
+
relation_variant_terms: tuple[str, ...],
|
|
891
|
+
lexical_terms: tuple[str, ...],
|
|
892
|
+
entity_surfaces: tuple[str, ...],
|
|
893
|
+
) -> tuple[str, ...]:
|
|
894
|
+
entity_tokens = {
|
|
895
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
896
|
+
}
|
|
897
|
+
lexical_term_set = set(lexical_terms)
|
|
898
|
+
skill_terms = ["language", "speak", "spoken"]
|
|
899
|
+
if {"certification", "certified", "credential"} & lexical_term_set:
|
|
900
|
+
skill_terms.extend(("certification", "certified", "credential"))
|
|
901
|
+
if {"language", "speak", "know", "fluent", "bilingual"} & lexical_term_set:
|
|
902
|
+
ability_order = {
|
|
903
|
+
"bilingual": ("bilingual", "fluent", "know"),
|
|
904
|
+
"fluent": ("fluent", "know", "bilingual"),
|
|
905
|
+
"know": ("know", "fluent", "bilingual"),
|
|
906
|
+
}
|
|
907
|
+
lexical_ability = next(
|
|
908
|
+
(term for term in ("bilingual", "fluent", "know") if term in lexical_term_set),
|
|
909
|
+
"",
|
|
910
|
+
)
|
|
911
|
+
skill_terms.extend(ability_order.get(lexical_ability, ("know", "fluent")))
|
|
912
|
+
if {
|
|
913
|
+
"drum",
|
|
914
|
+
"drums",
|
|
915
|
+
"guitar",
|
|
916
|
+
"instrument",
|
|
917
|
+
"piano",
|
|
918
|
+
"play",
|
|
919
|
+
"plays",
|
|
920
|
+
"violin",
|
|
921
|
+
} & lexical_term_set:
|
|
922
|
+
skill_terms.extend(("instrument", "play", "plays", "guitar", "piano", "violin", "drums"))
|
|
923
|
+
skill_term_set = set(skill_terms)
|
|
924
|
+
topical_terms = tuple(
|
|
925
|
+
term
|
|
926
|
+
for term in lexical_terms
|
|
927
|
+
if term not in _QUERY_STOPWORDS
|
|
928
|
+
and term not in relation_terms
|
|
929
|
+
and term not in relation_variant_terms
|
|
930
|
+
and term not in entity_tokens
|
|
931
|
+
)
|
|
932
|
+
if "program" in lexical_term_set and "language" in lexical_term_set:
|
|
933
|
+
return tuple(
|
|
934
|
+
dict.fromkeys(
|
|
935
|
+
(
|
|
936
|
+
"skill",
|
|
937
|
+
"language",
|
|
938
|
+
"program",
|
|
939
|
+
*(term for term in ("work", "code", "coding") if term in lexical_term_set),
|
|
940
|
+
"speak",
|
|
941
|
+
"spoken",
|
|
942
|
+
)
|
|
943
|
+
)
|
|
944
|
+
)
|
|
945
|
+
if "learn" in lexical_term_set and (
|
|
946
|
+
"language" in lexical_term_set or "skill" in lexical_term_set
|
|
947
|
+
):
|
|
948
|
+
return tuple(
|
|
949
|
+
dict.fromkeys(
|
|
950
|
+
(
|
|
951
|
+
"skill",
|
|
952
|
+
"language",
|
|
953
|
+
"learn",
|
|
954
|
+
*topical_terms[:4],
|
|
955
|
+
"speak",
|
|
956
|
+
"spoken",
|
|
957
|
+
"know",
|
|
958
|
+
)
|
|
959
|
+
)
|
|
960
|
+
)
|
|
961
|
+
return tuple(
|
|
962
|
+
dict.fromkeys(
|
|
963
|
+
(
|
|
964
|
+
*(term for term in relation_terms if term == "skill"),
|
|
965
|
+
*(term for term in skill_terms if term in relation_variant_terms),
|
|
966
|
+
*topical_terms[:4],
|
|
967
|
+
*(
|
|
968
|
+
term
|
|
969
|
+
for term in _relation_query_terms(
|
|
970
|
+
relation_terms,
|
|
971
|
+
relation_variant_terms,
|
|
972
|
+
)
|
|
973
|
+
if term not in skill_term_set and term not in _QUERY_STOPWORDS
|
|
974
|
+
),
|
|
975
|
+
)
|
|
976
|
+
)
|
|
977
|
+
)
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
def _preference_support_query_terms(
|
|
981
|
+
*,
|
|
982
|
+
relation_terms: tuple[str, ...],
|
|
983
|
+
relation_variant_terms: tuple[str, ...],
|
|
984
|
+
lexical_terms: tuple[str, ...],
|
|
985
|
+
entity_surfaces: tuple[str, ...],
|
|
986
|
+
) -> tuple[str, ...]:
|
|
987
|
+
entity_tokens = {
|
|
988
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
989
|
+
}
|
|
990
|
+
preference_actions = {
|
|
991
|
+
"enjoy",
|
|
992
|
+
"enjoyed",
|
|
993
|
+
"avoid",
|
|
994
|
+
"avoided",
|
|
995
|
+
"avoids",
|
|
996
|
+
"dislik",
|
|
997
|
+
"dislike",
|
|
998
|
+
"disliked",
|
|
999
|
+
"favorite",
|
|
1000
|
+
"favourite",
|
|
1001
|
+
"hat",
|
|
1002
|
+
"hate",
|
|
1003
|
+
"hated",
|
|
1004
|
+
"hates",
|
|
1005
|
+
"interest",
|
|
1006
|
+
"interested",
|
|
1007
|
+
"like",
|
|
1008
|
+
"liked",
|
|
1009
|
+
"love",
|
|
1010
|
+
"prefer",
|
|
1011
|
+
"preferred",
|
|
1012
|
+
}
|
|
1013
|
+
preference_domains = {
|
|
1014
|
+
"animal",
|
|
1015
|
+
"activity",
|
|
1016
|
+
"book",
|
|
1017
|
+
"color",
|
|
1018
|
+
"coffee",
|
|
1019
|
+
"food",
|
|
1020
|
+
"music",
|
|
1021
|
+
"movie",
|
|
1022
|
+
"movies",
|
|
1023
|
+
"park",
|
|
1024
|
+
"restaurant",
|
|
1025
|
+
"song",
|
|
1026
|
+
"sport",
|
|
1027
|
+
"sports",
|
|
1028
|
+
"tea",
|
|
1029
|
+
}
|
|
1030
|
+
lexical_domain_terms = tuple(
|
|
1031
|
+
term
|
|
1032
|
+
for term in lexical_terms
|
|
1033
|
+
if term in preference_domains and term not in entity_tokens
|
|
1034
|
+
)
|
|
1035
|
+
if {"kid", "like"}.issubset(relation_terms) or {
|
|
1036
|
+
"interest",
|
|
1037
|
+
"park",
|
|
1038
|
+
}.issubset(relation_terms) or {"enjoy", "song"}.issubset(relation_terms):
|
|
1039
|
+
return _relation_query_terms(relation_terms, relation_variant_terms)
|
|
1040
|
+
preference_action_variants = tuple(
|
|
1041
|
+
"preferr" if term == "preferred" else term
|
|
1042
|
+
for term in relation_variant_terms
|
|
1043
|
+
if term in preference_actions
|
|
1044
|
+
)
|
|
1045
|
+
if {"favorite", "favourite"} & set(relation_terms):
|
|
1046
|
+
return tuple(
|
|
1047
|
+
dict.fromkeys(
|
|
1048
|
+
(
|
|
1049
|
+
*(term for term in relation_terms if term in preference_actions),
|
|
1050
|
+
*lexical_domain_terms,
|
|
1051
|
+
*preference_action_variants,
|
|
1052
|
+
*(term for term in relation_variant_terms if term in preference_domains),
|
|
1053
|
+
)
|
|
1054
|
+
)
|
|
1055
|
+
)
|
|
1056
|
+
if set(relation_terms) == {"prefer"}:
|
|
1057
|
+
return tuple(
|
|
1058
|
+
dict.fromkeys(
|
|
1059
|
+
(
|
|
1060
|
+
*(term for term in relation_terms if term in preference_actions),
|
|
1061
|
+
*preference_action_variants,
|
|
1062
|
+
*(term for term in relation_variant_terms if term in preference_domains),
|
|
1063
|
+
*lexical_domain_terms,
|
|
1064
|
+
)
|
|
1065
|
+
)
|
|
1066
|
+
)
|
|
1067
|
+
topical_terms = tuple(
|
|
1068
|
+
term
|
|
1069
|
+
for term in lexical_terms
|
|
1070
|
+
if term not in _QUERY_STOPWORDS
|
|
1071
|
+
and term not in relation_terms
|
|
1072
|
+
and term not in relation_variant_terms
|
|
1073
|
+
and term not in entity_tokens
|
|
1074
|
+
)
|
|
1075
|
+
return tuple(
|
|
1076
|
+
dict.fromkeys(
|
|
1077
|
+
(
|
|
1078
|
+
*(term for term in relation_terms if term in preference_actions),
|
|
1079
|
+
*lexical_domain_terms,
|
|
1080
|
+
*preference_action_variants,
|
|
1081
|
+
*(term for term in relation_variant_terms if term in preference_domains),
|
|
1082
|
+
*topical_terms[:4],
|
|
1083
|
+
)
|
|
1084
|
+
)
|
|
1085
|
+
)
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
def _vehicle_support_query_terms(
|
|
1089
|
+
*,
|
|
1090
|
+
relation_terms: tuple[str, ...],
|
|
1091
|
+
relation_variant_terms: tuple[str, ...],
|
|
1092
|
+
lexical_terms: tuple[str, ...],
|
|
1093
|
+
entity_surfaces: tuple[str, ...],
|
|
1094
|
+
) -> tuple[str, ...]:
|
|
1095
|
+
entity_tokens = {
|
|
1096
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
1097
|
+
}
|
|
1098
|
+
vehicle_terms = {
|
|
1099
|
+
"car",
|
|
1100
|
+
"color",
|
|
1101
|
+
"drive",
|
|
1102
|
+
"drives",
|
|
1103
|
+
"driving",
|
|
1104
|
+
"license",
|
|
1105
|
+
"licence",
|
|
1106
|
+
"own",
|
|
1107
|
+
"owns",
|
|
1108
|
+
"plate",
|
|
1109
|
+
"sedan",
|
|
1110
|
+
"suv",
|
|
1111
|
+
"truck",
|
|
1112
|
+
"van",
|
|
1113
|
+
"vehicle",
|
|
1114
|
+
}
|
|
1115
|
+
license_plate_terms = {"license", "licence", "plate"}
|
|
1116
|
+
license_plate_focus = bool({"license", "licence"} & set(lexical_terms)) and (
|
|
1117
|
+
"plate" in lexical_terms
|
|
1118
|
+
)
|
|
1119
|
+
topical_terms = tuple(
|
|
1120
|
+
term
|
|
1121
|
+
for term in lexical_terms
|
|
1122
|
+
if term not in _QUERY_STOPWORDS
|
|
1123
|
+
and term not in relation_terms
|
|
1124
|
+
and term not in relation_variant_terms
|
|
1125
|
+
and term not in entity_tokens
|
|
1126
|
+
)
|
|
1127
|
+
return tuple(
|
|
1128
|
+
dict.fromkeys(
|
|
1129
|
+
(
|
|
1130
|
+
*(term for term in relation_terms if term == "vehicle"),
|
|
1131
|
+
*(
|
|
1132
|
+
term
|
|
1133
|
+
for term in relation_variant_terms
|
|
1134
|
+
if license_plate_focus and term in license_plate_terms
|
|
1135
|
+
),
|
|
1136
|
+
*(
|
|
1137
|
+
term
|
|
1138
|
+
for term in relation_variant_terms
|
|
1139
|
+
if term in vehicle_terms
|
|
1140
|
+
and (
|
|
1141
|
+
term not in license_plate_terms
|
|
1142
|
+
or license_plate_focus
|
|
1143
|
+
)
|
|
1144
|
+
and not (license_plate_focus and term in license_plate_terms)
|
|
1145
|
+
),
|
|
1146
|
+
*(
|
|
1147
|
+
term
|
|
1148
|
+
for term in topical_terms[:4]
|
|
1149
|
+
if term not in license_plate_terms
|
|
1150
|
+
),
|
|
1151
|
+
*(
|
|
1152
|
+
term
|
|
1153
|
+
for term in _relation_query_terms(
|
|
1154
|
+
relation_terms,
|
|
1155
|
+
relation_variant_terms,
|
|
1156
|
+
)
|
|
1157
|
+
if term not in vehicle_terms and term not in _QUERY_STOPWORDS
|
|
1158
|
+
),
|
|
1159
|
+
)
|
|
1160
|
+
)
|
|
1161
|
+
)
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
def _communication_support_query_terms(
|
|
1165
|
+
*,
|
|
1166
|
+
relation_terms: tuple[str, ...],
|
|
1167
|
+
relation_variant_terms: tuple[str, ...],
|
|
1168
|
+
lexical_terms: tuple[str, ...],
|
|
1169
|
+
entity_surfaces: tuple[str, ...],
|
|
1170
|
+
) -> tuple[str, ...]:
|
|
1171
|
+
entity_tokens = {
|
|
1172
|
+
token
|
|
1173
|
+
for surface in entity_surfaces
|
|
1174
|
+
for token in _normalized_terms(surface)
|
|
1175
|
+
}
|
|
1176
|
+
communication_surface_terms = {
|
|
1177
|
+
"advise",
|
|
1178
|
+
"ask",
|
|
1179
|
+
"asked",
|
|
1180
|
+
"call",
|
|
1181
|
+
"called",
|
|
1182
|
+
"chat",
|
|
1183
|
+
"chatted",
|
|
1184
|
+
"conversation",
|
|
1185
|
+
"discuss",
|
|
1186
|
+
"discussed",
|
|
1187
|
+
"invit",
|
|
1188
|
+
"invitation",
|
|
1189
|
+
"invite",
|
|
1190
|
+
"invited",
|
|
1191
|
+
"inviting",
|
|
1192
|
+
"message",
|
|
1193
|
+
"messag",
|
|
1194
|
+
"messaged",
|
|
1195
|
+
"mention",
|
|
1196
|
+
"recommend",
|
|
1197
|
+
"recommended",
|
|
1198
|
+
"remind",
|
|
1199
|
+
"reminded",
|
|
1200
|
+
"request",
|
|
1201
|
+
"said",
|
|
1202
|
+
"send",
|
|
1203
|
+
"sent",
|
|
1204
|
+
"suggest",
|
|
1205
|
+
"suggested",
|
|
1206
|
+
"talk",
|
|
1207
|
+
"talked",
|
|
1208
|
+
"tell",
|
|
1209
|
+
"text",
|
|
1210
|
+
"texted",
|
|
1211
|
+
"told",
|
|
1212
|
+
"warn",
|
|
1213
|
+
"warned",
|
|
1214
|
+
}
|
|
1215
|
+
allowed_communication_terms: set[str] = set()
|
|
1216
|
+
relation_term_set = set(relation_terms)
|
|
1217
|
+
if relation_term_set & {"say", "said", "tell", "mention"}:
|
|
1218
|
+
allowed_communication_terms.update(("mention", "said", "tell", "told"))
|
|
1219
|
+
if relation_term_set & {"chat", "discus", "discuss", "talk"}:
|
|
1220
|
+
allowed_communication_terms.update(
|
|
1221
|
+
(
|
|
1222
|
+
"chat",
|
|
1223
|
+
"chatted",
|
|
1224
|
+
"conversation",
|
|
1225
|
+
"discus",
|
|
1226
|
+
"discuss",
|
|
1227
|
+
"discussed",
|
|
1228
|
+
"talk",
|
|
1229
|
+
"talked",
|
|
1230
|
+
)
|
|
1231
|
+
)
|
|
1232
|
+
if relation_term_set & {"call", "message", "messag", "send", "sent", "text"}:
|
|
1233
|
+
allowed_communication_terms.update(
|
|
1234
|
+
(
|
|
1235
|
+
"call",
|
|
1236
|
+
"called",
|
|
1237
|
+
"message",
|
|
1238
|
+
"messag",
|
|
1239
|
+
"messaged",
|
|
1240
|
+
"send",
|
|
1241
|
+
"sent",
|
|
1242
|
+
"text",
|
|
1243
|
+
"texted",
|
|
1244
|
+
)
|
|
1245
|
+
)
|
|
1246
|
+
if "ask" in relation_term_set:
|
|
1247
|
+
allowed_communication_terms.update(("ask", "asked", "request"))
|
|
1248
|
+
if relation_term_set & {"invit", "invitation", "invite"}:
|
|
1249
|
+
allowed_communication_terms.update(
|
|
1250
|
+
("ask", "asked", "invit", "invitation", "invite", "invited", "inviting")
|
|
1251
|
+
)
|
|
1252
|
+
if relation_term_set & {"remind", "reminded"}:
|
|
1253
|
+
allowed_communication_terms.update(("remind", "reminded", "tell", "told"))
|
|
1254
|
+
if relation_term_set & {"warn", "warned"}:
|
|
1255
|
+
allowed_communication_terms.update(("warn", "warned", "tell", "told"))
|
|
1256
|
+
if relation_term_set & {"recommend", "suggest"}:
|
|
1257
|
+
allowed_communication_terms.update(
|
|
1258
|
+
("advise", "recommend", "recommended", "suggest", "suggested", "told")
|
|
1259
|
+
)
|
|
1260
|
+
if not allowed_communication_terms:
|
|
1261
|
+
allowed_communication_terms.update(communication_surface_terms)
|
|
1262
|
+
relation_specific_variants = tuple(
|
|
1263
|
+
term
|
|
1264
|
+
for term in relation_variant_terms
|
|
1265
|
+
if term not in communication_surface_terms or term in allowed_communication_terms
|
|
1266
|
+
)
|
|
1267
|
+
communication_terms = tuple(
|
|
1268
|
+
term
|
|
1269
|
+
for term in _relation_query_terms(relation_terms, relation_variant_terms)
|
|
1270
|
+
if term in allowed_communication_terms
|
|
1271
|
+
)
|
|
1272
|
+
topical_terms = tuple(
|
|
1273
|
+
term
|
|
1274
|
+
for term in lexical_terms
|
|
1275
|
+
if term not in _QUERY_STOPWORDS
|
|
1276
|
+
and term not in relation_terms
|
|
1277
|
+
and term not in relation_specific_variants
|
|
1278
|
+
and term not in communication_terms
|
|
1279
|
+
and term not in entity_tokens
|
|
1280
|
+
)
|
|
1281
|
+
return tuple(
|
|
1282
|
+
dict.fromkeys(
|
|
1283
|
+
(
|
|
1284
|
+
*relation_terms,
|
|
1285
|
+
*relation_specific_variants[:4],
|
|
1286
|
+
*topical_terms[:6],
|
|
1287
|
+
*communication_terms,
|
|
1288
|
+
*relation_specific_variants,
|
|
1289
|
+
)
|
|
1290
|
+
)
|
|
1291
|
+
)
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
def _topical_relation_query_terms(
|
|
1295
|
+
*,
|
|
1296
|
+
relation_terms: tuple[str, ...],
|
|
1297
|
+
relation_variant_terms: tuple[str, ...],
|
|
1298
|
+
lexical_terms: tuple[str, ...],
|
|
1299
|
+
entity_surfaces: tuple[str, ...],
|
|
1300
|
+
topic_after: int,
|
|
1301
|
+
) -> tuple[str, ...]:
|
|
1302
|
+
entity_tokens = {
|
|
1303
|
+
token for surface in entity_surfaces for token in _normalized_terms(surface)
|
|
1304
|
+
}
|
|
1305
|
+
base_terms = _relation_query_terms(relation_terms, relation_variant_terms)
|
|
1306
|
+
topical_terms = tuple(
|
|
1307
|
+
term
|
|
1308
|
+
for term in lexical_terms
|
|
1309
|
+
if term not in _QUERY_STOPWORDS
|
|
1310
|
+
and term not in relation_terms
|
|
1311
|
+
and term not in relation_variant_terms
|
|
1312
|
+
and term not in _QUERY_TOKEN_ALIASES
|
|
1313
|
+
and term not in entity_tokens
|
|
1314
|
+
)
|
|
1315
|
+
return tuple(
|
|
1316
|
+
dict.fromkeys(
|
|
1317
|
+
(
|
|
1318
|
+
*base_terms[:topic_after],
|
|
1319
|
+
*topical_terms[:4],
|
|
1320
|
+
*base_terms[topic_after:],
|
|
1321
|
+
)
|
|
1322
|
+
)
|
|
1323
|
+
)
|
|
1324
|
+
|
|
1325
|
+
|
|
1326
|
+
|
|
1327
|
+
def _contrast_support_query_terms(
|
|
1328
|
+
*,
|
|
1329
|
+
relation_terms: tuple[str, ...],
|
|
1330
|
+
relation_variant_terms: tuple[str, ...],
|
|
1331
|
+
lexical_terms: tuple[str, ...],
|
|
1332
|
+
) -> tuple[str, ...]:
|
|
1333
|
+
relation_query_terms = _relation_query_terms(
|
|
1334
|
+
relation_terms,
|
|
1335
|
+
relation_variant_terms,
|
|
1336
|
+
)
|
|
1337
|
+
topical_terms = tuple(
|
|
1338
|
+
term
|
|
1339
|
+
for term in relation_terms
|
|
1340
|
+
if term not in _CONTRAST_RELATION_MARKER_TERMS
|
|
1341
|
+
and term not in _CONTRAST_QUERY_VARIANT_BLOCKLIST
|
|
1342
|
+
)
|
|
1343
|
+
explicit_contrast_terms = tuple(
|
|
1344
|
+
term for term in lexical_terms if term in _CONTRAST_SUPPORT_QUERY_SURFACES
|
|
1345
|
+
)
|
|
1346
|
+
contrast_variants = tuple(
|
|
1347
|
+
term
|
|
1348
|
+
for term in relation_query_terms
|
|
1349
|
+
if term in _CONTRAST_SUPPORT_QUERY_SURFACES
|
|
1350
|
+
)
|
|
1351
|
+
topical_variants = tuple(
|
|
1352
|
+
term
|
|
1353
|
+
for term in relation_query_terms
|
|
1354
|
+
if term not in topical_terms
|
|
1355
|
+
and term not in _CONTRAST_SUPPORT_QUERY_SURFACES
|
|
1356
|
+
and term not in _CONTRAST_QUERY_VARIANT_BLOCKLIST
|
|
1357
|
+
and term not in _QUERY_STOPWORDS
|
|
1358
|
+
)
|
|
1359
|
+
backfill_terms: tuple[str, ...] = ()
|
|
1360
|
+
if {"current", "currently", "now"} & set(
|
|
1361
|
+
(*explicit_contrast_terms, *contrast_variants)
|
|
1362
|
+
):
|
|
1363
|
+
backfill_terms = (*backfill_terms, *_CONTRAST_CURRENTNESS_BACKFILL)
|
|
1364
|
+
if explicit_contrast_terms or contrast_variants:
|
|
1365
|
+
backfill_terms = (*backfill_terms, *_CONTRAST_STALE_BACKFILL)
|
|
1366
|
+
return tuple(
|
|
1367
|
+
dict.fromkeys(
|
|
1368
|
+
(
|
|
1369
|
+
*topical_terms[:4],
|
|
1370
|
+
*explicit_contrast_terms,
|
|
1371
|
+
*backfill_terms,
|
|
1372
|
+
*contrast_variants,
|
|
1373
|
+
*topical_variants[:5],
|
|
1374
|
+
)
|
|
1375
|
+
)
|
|
1376
|
+
)
|
|
1377
|
+
|
|
1378
|
+
def _location_support_query_terms(
|
|
1379
|
+
*,
|
|
1380
|
+
relation_terms: tuple[str, ...],
|
|
1381
|
+
relation_variant_terms: tuple[str, ...],
|
|
1382
|
+
lexical_terms: tuple[str, ...],
|
|
1383
|
+
) -> tuple[str, ...]:
|
|
1384
|
+
relation_query_terms = _relation_query_terms(
|
|
1385
|
+
relation_terms,
|
|
1386
|
+
relation_variant_terms,
|
|
1387
|
+
)
|
|
1388
|
+
location_surfaces = (
|
|
1389
|
+
"from",
|
|
1390
|
+
"origin",
|
|
1391
|
+
"home",
|
|
1392
|
+
"country",
|
|
1393
|
+
"city",
|
|
1394
|
+
"place",
|
|
1395
|
+
"location",
|
|
1396
|
+
"destination",
|
|
1397
|
+
"near",
|
|
1398
|
+
"around",
|
|
1399
|
+
"at",
|
|
1400
|
+
"based",
|
|
1401
|
+
"live",
|
|
1402
|
+
"lived",
|
|
1403
|
+
"living",
|
|
1404
|
+
"stay",
|
|
1405
|
+
"stayed",
|
|
1406
|
+
"hotel",
|
|
1407
|
+
"grew",
|
|
1408
|
+
"childhood",
|
|
1409
|
+
"born",
|
|
1410
|
+
"raised",
|
|
1411
|
+
"hometown",
|
|
1412
|
+
"originally",
|
|
1413
|
+
"relocated",
|
|
1414
|
+
"moved",
|
|
1415
|
+
"came",
|
|
1416
|
+
"camp",
|
|
1417
|
+
"camped",
|
|
1418
|
+
"camping",
|
|
1419
|
+
"campsite",
|
|
1420
|
+
"campground",
|
|
1421
|
+
"travel",
|
|
1422
|
+
"traveled",
|
|
1423
|
+
"travelled",
|
|
1424
|
+
"traveling",
|
|
1425
|
+
"travelling",
|
|
1426
|
+
"trip",
|
|
1427
|
+
"visit",
|
|
1428
|
+
"visited",
|
|
1429
|
+
"visiting",
|
|
1430
|
+
"gallery",
|
|
1431
|
+
"museum",
|
|
1432
|
+
"studio",
|
|
1433
|
+
"theater",
|
|
1434
|
+
"theatre",
|
|
1435
|
+
)
|
|
1436
|
+
explicit_location_terms = tuple(
|
|
1437
|
+
term
|
|
1438
|
+
for term in lexical_terms
|
|
1439
|
+
if term in {"from", "where", "which", "country", "city", "place", "origin"}
|
|
1440
|
+
)
|
|
1441
|
+
relation_term_set = set(relation_terms)
|
|
1442
|
+
location_first_terms: tuple[str, ...] = ()
|
|
1443
|
+
if "camp" in relation_term_set:
|
|
1444
|
+
location_first_terms = (
|
|
1445
|
+
"camp",
|
|
1446
|
+
"camping",
|
|
1447
|
+
"place",
|
|
1448
|
+
"location",
|
|
1449
|
+
"campsite",
|
|
1450
|
+
"campground",
|
|
1451
|
+
"outdoor",
|
|
1452
|
+
"trip",
|
|
1453
|
+
)
|
|
1454
|
+
elif {"live", "based"} & relation_term_set:
|
|
1455
|
+
location_first_terms = ("live", "liv", "bas", "home", "city", "place")
|
|
1456
|
+
elif "employment" in relation_term_set:
|
|
1457
|
+
location_first_terms = (
|
|
1458
|
+
"work",
|
|
1459
|
+
"worked",
|
|
1460
|
+
"working",
|
|
1461
|
+
"workplace",
|
|
1462
|
+
"office",
|
|
1463
|
+
"company",
|
|
1464
|
+
"city",
|
|
1465
|
+
"place",
|
|
1466
|
+
"location",
|
|
1467
|
+
)
|
|
1468
|
+
elif "attend" in relation_term_set:
|
|
1469
|
+
location_first_terms = (
|
|
1470
|
+
"attend",
|
|
1471
|
+
"attended",
|
|
1472
|
+
"event",
|
|
1473
|
+
"venue",
|
|
1474
|
+
"place",
|
|
1475
|
+
"location",
|
|
1476
|
+
"gallery",
|
|
1477
|
+
"museum",
|
|
1478
|
+
"theater",
|
|
1479
|
+
)
|
|
1480
|
+
elif "venue" in relation_term_set:
|
|
1481
|
+
location_first_terms = (
|
|
1482
|
+
"venue",
|
|
1483
|
+
"place",
|
|
1484
|
+
"location",
|
|
1485
|
+
"event",
|
|
1486
|
+
"wedding",
|
|
1487
|
+
"ceremony",
|
|
1488
|
+
"reception",
|
|
1489
|
+
"hall",
|
|
1490
|
+
)
|
|
1491
|
+
elif {"origin", "from"} & relation_term_set:
|
|
1492
|
+
location_first_terms = ("origin", "home", "city", "country", "grew", "born")
|
|
1493
|
+
return tuple(
|
|
1494
|
+
dict.fromkeys(
|
|
1495
|
+
(
|
|
1496
|
+
*location_first_terms,
|
|
1497
|
+
*(
|
|
1498
|
+
term
|
|
1499
|
+
for term in relation_query_terms
|
|
1500
|
+
if term not in _QUERY_STOPWORDS
|
|
1501
|
+
),
|
|
1502
|
+
*location_surfaces,
|
|
1503
|
+
)
|
|
1504
|
+
)
|
|
1505
|
+
)
|
|
1506
|
+
elif {"stay"} & relation_term_set:
|
|
1507
|
+
location_first_terms = ("stay", "stayed", "hotel", "place", "location")
|
|
1508
|
+
return tuple(
|
|
1509
|
+
dict.fromkeys(
|
|
1510
|
+
(
|
|
1511
|
+
*location_first_terms,
|
|
1512
|
+
*explicit_location_terms,
|
|
1513
|
+
*location_surfaces,
|
|
1514
|
+
*(
|
|
1515
|
+
term
|
|
1516
|
+
for term in relation_query_terms
|
|
1517
|
+
if term not in _QUERY_STOPWORDS
|
|
1518
|
+
),
|
|
1519
|
+
)
|
|
1520
|
+
)
|
|
1521
|
+
)
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
|
|
1525
|
+
def _relation_query_terms(
|
|
1526
|
+
relation_terms: Sequence[str],
|
|
1527
|
+
relation_variant_terms: Sequence[str],
|
|
1528
|
+
) -> tuple[str, ...]:
|
|
1529
|
+
relation_terms = tuple(relation_terms)
|
|
1530
|
+
generic_relation_terms = {"consider"}
|
|
1531
|
+
if "receive" in relation_terms and "grow" in relation_terms:
|
|
1532
|
+
generic_relation_terms.add("career")
|
|
1533
|
+
if {"personality", "trait", "say"} <= set(relation_terms):
|
|
1534
|
+
generic_relation_terms.add("say")
|
|
1535
|
+
if {"personality", "trait", "said"} <= set(relation_terms):
|
|
1536
|
+
generic_relation_terms.add("said")
|
|
1537
|
+
base_terms = (
|
|
1538
|
+
tuple(term for term in relation_terms if term not in generic_relation_terms)
|
|
1539
|
+
if len(relation_terms) > 1
|
|
1540
|
+
else relation_terms
|
|
1541
|
+
)
|
|
1542
|
+
delayed_base_terms: tuple[str, ...] = ()
|
|
1543
|
+
relation_term_set = set(relation_terms)
|
|
1544
|
+
if {"excite", "adoption", "process"}.issubset(relation_term_set):
|
|
1545
|
+
delayed_base_terms = tuple(
|
|
1546
|
+
term for term in base_terms if term in {"adoption", "process"}
|
|
1547
|
+
)
|
|
1548
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1549
|
+
elif {"think", "decision", "adopt"}.issubset(relation_term_set):
|
|
1550
|
+
delayed_base_terms = tuple(
|
|
1551
|
+
term for term in base_terms if term in {"decision", "adopt"}
|
|
1552
|
+
)
|
|
1553
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1554
|
+
elif {"receive", "support", "grow"}.issubset(relation_term_set):
|
|
1555
|
+
delayed_base_terms = tuple(
|
|
1556
|
+
term for term in base_terms if term in {"pursue", "receive", "grow"}
|
|
1557
|
+
)
|
|
1558
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1559
|
+
elif {"career", "path", "pursue"}.issubset(relation_term_set):
|
|
1560
|
+
delayed_base_terms = tuple(
|
|
1561
|
+
term for term in base_terms if term in {"decide", "pursue"}
|
|
1562
|
+
)
|
|
1563
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1564
|
+
elif {"write", "career"}.issubset(relation_term_set):
|
|
1565
|
+
delayed_base_terms = tuple(term for term in base_terms if term == "pursue")
|
|
1566
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1567
|
+
elif {"realize", "charity", "race"}.issubset(relation_term_set):
|
|
1568
|
+
delayed_base_terms = tuple(
|
|
1569
|
+
term for term in base_terms if term in {"charity", "race"}
|
|
1570
|
+
)
|
|
1571
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1572
|
+
elif {"individual", "adoption", "support"}.issubset(relation_term_set):
|
|
1573
|
+
delayed_base_terms = tuple(
|
|
1574
|
+
term for term in base_terms if term in {"agency", "individual"}
|
|
1575
|
+
)
|
|
1576
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1577
|
+
elif {"choose", "adoption", "agency"}.issubset(relation_term_set):
|
|
1578
|
+
delayed_base_terms = tuple(
|
|
1579
|
+
term for term in base_terms if term in {"choose", "agency"}
|
|
1580
|
+
)
|
|
1581
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1582
|
+
elif {"relationship", "status"}.issubset(relation_term_set):
|
|
1583
|
+
delayed_base_terms = base_terms
|
|
1584
|
+
base_terms = ()
|
|
1585
|
+
elif {"charity", "race", "raise"}.issubset(relation_term_set):
|
|
1586
|
+
delayed_base_terms = tuple(term for term in base_terms if term == "raise")
|
|
1587
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1588
|
+
elif {"book", "bookshelf"}.issubset(relation_term_set):
|
|
1589
|
+
delayed_base_terms = tuple(term for term in base_terms if term == "bookshelf")
|
|
1590
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1591
|
+
elif {"lgbtq", "support", "group", "go"}.issubset(relation_term_set):
|
|
1592
|
+
delayed_base_terms = tuple(term for term in base_terms if term == "lgbtq")
|
|
1593
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1594
|
+
elif {"transgender", "conference"}.issubset(relation_term_set):
|
|
1595
|
+
base_terms = tuple(
|
|
1596
|
+
dict.fromkeys(
|
|
1597
|
+
(
|
|
1598
|
+
"conference",
|
|
1599
|
+
"transgender",
|
|
1600
|
+
*(
|
|
1601
|
+
term
|
|
1602
|
+
for term in base_terms
|
|
1603
|
+
if term not in {"conference", "transgender"}
|
|
1604
|
+
),
|
|
1605
|
+
)
|
|
1606
|
+
)
|
|
1607
|
+
)
|
|
1608
|
+
elif "marry" in relation_term_set:
|
|
1609
|
+
delayed_base_terms = base_terms
|
|
1610
|
+
base_terms = ()
|
|
1611
|
+
elif {"field", "pursue"}.issubset(relation_term_set):
|
|
1612
|
+
delayed_base_terms = tuple(
|
|
1613
|
+
term for term in base_terms if term in {"field", "pursue"}
|
|
1614
|
+
)
|
|
1615
|
+
base_terms = tuple(term for term in base_terms if term not in delayed_base_terms)
|
|
1616
|
+
high_signal_variants = tuple(
|
|
1617
|
+
term for term in relation_variant_terms if term in _HIGH_SIGNAL_RELATION_VARIANTS
|
|
1618
|
+
)
|
|
1619
|
+
priority_variant_order: list[str] = []
|
|
1620
|
+
priority_surface_terms: set[str] = set()
|
|
1621
|
+
if "activity" in relation_term_set:
|
|
1622
|
+
priority_variant_order.extend(
|
|
1623
|
+
(
|
|
1624
|
+
"hobby",
|
|
1625
|
+
"hobbies",
|
|
1626
|
+
"partake",
|
|
1627
|
+
"class",
|
|
1628
|
+
"creative",
|
|
1629
|
+
"fun",
|
|
1630
|
+
"interest",
|
|
1631
|
+
"expres",
|
|
1632
|
+
"refresh",
|
|
1633
|
+
"therapeutic",
|
|
1634
|
+
"leisure",
|
|
1635
|
+
)
|
|
1636
|
+
)
|
|
1637
|
+
priority_surface_terms.add("express")
|
|
1638
|
+
if "hike" in relation_term_set:
|
|
1639
|
+
priority_variant_order.extend(
|
|
1640
|
+
(
|
|
1641
|
+
"trail",
|
|
1642
|
+
"hiking",
|
|
1643
|
+
"waterfall",
|
|
1644
|
+
"went",
|
|
1645
|
+
"spot",
|
|
1646
|
+
"weekend",
|
|
1647
|
+
"summer",
|
|
1648
|
+
"photo",
|
|
1649
|
+
)
|
|
1650
|
+
)
|
|
1651
|
+
if {"excite", "adoption", "process"}.issubset(relation_term_set):
|
|
1652
|
+
priority_variant_order.extend(("kid", "make", "create", "thrilled", "process"))
|
|
1653
|
+
priority_surface_terms.add("thrilled")
|
|
1654
|
+
if {"go", "support", "group"}.issubset(relation_term_set):
|
|
1655
|
+
priority_variant_order.extend(("went",))
|
|
1656
|
+
if {"book", "read"}.issubset(relation_term_set):
|
|
1657
|
+
priority_variant_order.extend(("reading",))
|
|
1658
|
+
priority_surface_terms.add("reading")
|
|
1659
|
+
if {"kid", "like"}.issubset(relation_term_set):
|
|
1660
|
+
priority_variant_order.extend(
|
|
1661
|
+
(
|
|
1662
|
+
"animal",
|
|
1663
|
+
"exhibit",
|
|
1664
|
+
"learning",
|
|
1665
|
+
"family",
|
|
1666
|
+
"preference",
|
|
1667
|
+
"children",
|
|
1668
|
+
"like",
|
|
1669
|
+
"love",
|
|
1670
|
+
)
|
|
1671
|
+
)
|
|
1672
|
+
priority_surface_terms.update(("animal", "learning"))
|
|
1673
|
+
if "birthday" in relation_term_set:
|
|
1674
|
+
priority_variant_order.extend(("18th", "year", "ago", "born", "age"))
|
|
1675
|
+
if "camp" in relation_term_set:
|
|
1676
|
+
priority_variant_order.extend(
|
|
1677
|
+
(
|
|
1678
|
+
"camping",
|
|
1679
|
+
"place",
|
|
1680
|
+
"location",
|
|
1681
|
+
"campsite",
|
|
1682
|
+
"campground",
|
|
1683
|
+
"outdoor",
|
|
1684
|
+
"trip",
|
|
1685
|
+
"family",
|
|
1686
|
+
"unplug",
|
|
1687
|
+
"connection",
|
|
1688
|
+
"close",
|
|
1689
|
+
)
|
|
1690
|
+
)
|
|
1691
|
+
if {"book", "bookshelf"}.issubset(relation_term_set):
|
|
1692
|
+
priority_variant_order.extend(("books", "kids", "stories", "reading", "read"))
|
|
1693
|
+
priority_surface_terms.update(("books", "kids", "stories"))
|
|
1694
|
+
if {"receive", "support", "grow"}.issubset(relation_term_set):
|
|
1695
|
+
priority_variant_order.extend(("got", "help", "growing", "journey"))
|
|
1696
|
+
if {"bought", "buy", "purchas", "purchase"} & relation_term_set:
|
|
1697
|
+
priority_variant_order.extend(("got", "purchased", "buy", "bought"))
|
|
1698
|
+
priority_surface_terms.update(("got", "purchased"))
|
|
1699
|
+
if "destress" in relation_term_set:
|
|
1700
|
+
priority_variant_order.extend(
|
|
1701
|
+
(
|
|
1702
|
+
"stress",
|
|
1703
|
+
"relax",
|
|
1704
|
+
"unwind",
|
|
1705
|
+
"class",
|
|
1706
|
+
"clear",
|
|
1707
|
+
"mind",
|
|
1708
|
+
"run",
|
|
1709
|
+
"therapy",
|
|
1710
|
+
"therapeutic",
|
|
1711
|
+
"creative",
|
|
1712
|
+
"expres",
|
|
1713
|
+
"decompress",
|
|
1714
|
+
"self-care",
|
|
1715
|
+
)
|
|
1716
|
+
)
|
|
1717
|
+
if "identity" in relation_term_set:
|
|
1718
|
+
priority_variant_order.extend(
|
|
1719
|
+
(
|
|
1720
|
+
"support",
|
|
1721
|
+
"inspir",
|
|
1722
|
+
"story",
|
|
1723
|
+
"gender",
|
|
1724
|
+
"accept",
|
|
1725
|
+
"courage",
|
|
1726
|
+
"embrace",
|
|
1727
|
+
"pride",
|
|
1728
|
+
"self",
|
|
1729
|
+
)
|
|
1730
|
+
)
|
|
1731
|
+
if {"think", "decision", "adopt"}.issubset(relation_term_set):
|
|
1732
|
+
priority_variant_order.extend(
|
|
1733
|
+
(
|
|
1734
|
+
"reaction",
|
|
1735
|
+
"response",
|
|
1736
|
+
"opinion",
|
|
1737
|
+
"feel",
|
|
1738
|
+
"creating",
|
|
1739
|
+
"family",
|
|
1740
|
+
"lovely",
|
|
1741
|
+
"luck",
|
|
1742
|
+
"support",
|
|
1743
|
+
"kid",
|
|
1744
|
+
)
|
|
1745
|
+
)
|
|
1746
|
+
if {"excite", "feel"} & relation_term_set and not {
|
|
1747
|
+
"adoption",
|
|
1748
|
+
"excite",
|
|
1749
|
+
"process",
|
|
1750
|
+
}.issubset(relation_term_set):
|
|
1751
|
+
priority_variant_order.extend(
|
|
1752
|
+
(
|
|
1753
|
+
"felt",
|
|
1754
|
+
"feeling",
|
|
1755
|
+
"reaction",
|
|
1756
|
+
"response",
|
|
1757
|
+
"excited",
|
|
1758
|
+
"thrilled",
|
|
1759
|
+
"nervous",
|
|
1760
|
+
"relieved",
|
|
1761
|
+
"proud",
|
|
1762
|
+
"worried",
|
|
1763
|
+
"upset",
|
|
1764
|
+
)
|
|
1765
|
+
)
|
|
1766
|
+
priority_surface_terms.update(("excited", "thrilled", "worried"))
|
|
1767
|
+
if "political" in relation_term_set:
|
|
1768
|
+
priority_variant_order.extend(
|
|
1769
|
+
(
|
|
1770
|
+
"rights",
|
|
1771
|
+
"lgbtq",
|
|
1772
|
+
"support",
|
|
1773
|
+
"accept",
|
|
1774
|
+
"belief",
|
|
1775
|
+
"view",
|
|
1776
|
+
"value",
|
|
1777
|
+
"policy",
|
|
1778
|
+
)
|
|
1779
|
+
)
|
|
1780
|
+
priority_surface_terms.add("rights")
|
|
1781
|
+
if "religious" in relation_term_set:
|
|
1782
|
+
priority_variant_order.extend(
|
|
1783
|
+
(
|
|
1784
|
+
"church",
|
|
1785
|
+
"think",
|
|
1786
|
+
"journey",
|
|
1787
|
+
"chang",
|
|
1788
|
+
"acceptance",
|
|
1789
|
+
"faith",
|
|
1790
|
+
"growth",
|
|
1791
|
+
)
|
|
1792
|
+
)
|
|
1793
|
+
if {"career", "path", "pursue"}.issubset(relation_term_set):
|
|
1794
|
+
priority_variant_order.extend(("work", "working", "think", "figur", "option"))
|
|
1795
|
+
priority_surface_terms.add("working")
|
|
1796
|
+
if {"write", "career"}.issubset(relation_term_set):
|
|
1797
|
+
priority_variant_order.extend(
|
|
1798
|
+
(
|
|
1799
|
+
"looking",
|
|
1800
|
+
"work",
|
|
1801
|
+
"working",
|
|
1802
|
+
"jobs",
|
|
1803
|
+
"job",
|
|
1804
|
+
"option",
|
|
1805
|
+
"path",
|
|
1806
|
+
"support",
|
|
1807
|
+
)
|
|
1808
|
+
)
|
|
1809
|
+
priority_surface_terms.add("looking")
|
|
1810
|
+
if {"enjoy", "song"}.issubset(relation_term_set):
|
|
1811
|
+
priority_variant_order.extend(
|
|
1812
|
+
("fan", "piece", "composer", "instrumental", "orchestra", "like")
|
|
1813
|
+
)
|
|
1814
|
+
if {"necklace", "symbolize"}.issubset(relation_term_set):
|
|
1815
|
+
priority_variant_order.extend(
|
|
1816
|
+
(
|
|
1817
|
+
"symbol",
|
|
1818
|
+
"mean",
|
|
1819
|
+
"gift",
|
|
1820
|
+
"reminder",
|
|
1821
|
+
"family",
|
|
1822
|
+
"support",
|
|
1823
|
+
"special",
|
|
1824
|
+
"represent",
|
|
1825
|
+
"message",
|
|
1826
|
+
)
|
|
1827
|
+
)
|
|
1828
|
+
if {"field", "pursue"}.issubset(relation_term_set):
|
|
1829
|
+
priority_variant_order.extend(
|
|
1830
|
+
(
|
|
1831
|
+
"career",
|
|
1832
|
+
"option",
|
|
1833
|
+
"work",
|
|
1834
|
+
"support",
|
|
1835
|
+
"similar",
|
|
1836
|
+
"issue",
|
|
1837
|
+
"keen",
|
|
1838
|
+
"edu",
|
|
1839
|
+
"education",
|
|
1840
|
+
"study",
|
|
1841
|
+
"working",
|
|
1842
|
+
)
|
|
1843
|
+
)
|
|
1844
|
+
priority_surface_terms.add("edu")
|
|
1845
|
+
if {"interest", "park"}.issubset(relation_term_set):
|
|
1846
|
+
priority_variant_order.extend(
|
|
1847
|
+
(
|
|
1848
|
+
"camping",
|
|
1849
|
+
"trip",
|
|
1850
|
+
"story",
|
|
1851
|
+
"sky",
|
|
1852
|
+
"summer",
|
|
1853
|
+
"enjoy",
|
|
1854
|
+
"nature",
|
|
1855
|
+
"outdoor",
|
|
1856
|
+
)
|
|
1857
|
+
)
|
|
1858
|
+
priority_surface_terms.update(("enjoy", "story"))
|
|
1859
|
+
if {"prioritize", "self-care"}.issubset(relation_term_set):
|
|
1860
|
+
priority_variant_order.extend(
|
|
1861
|
+
(
|
|
1862
|
+
"routine",
|
|
1863
|
+
"refreshes",
|
|
1864
|
+
"present",
|
|
1865
|
+
"wellness",
|
|
1866
|
+
"balance",
|
|
1867
|
+
"rest",
|
|
1868
|
+
"relax",
|
|
1869
|
+
)
|
|
1870
|
+
)
|
|
1871
|
+
priority_surface_terms.add("refreshes")
|
|
1872
|
+
if {"realize", "charity", "race"}.issubset(relation_term_set):
|
|
1873
|
+
priority_variant_order.extend(
|
|
1874
|
+
("lesson", "reflection", "thought", "event", "journey")
|
|
1875
|
+
)
|
|
1876
|
+
if {"relationship", "status"}.issubset(relation_term_set):
|
|
1877
|
+
priority_variant_order.extend(
|
|
1878
|
+
(
|
|
1879
|
+
"parent",
|
|
1880
|
+
"breakup",
|
|
1881
|
+
"family",
|
|
1882
|
+
"kid",
|
|
1883
|
+
"friend",
|
|
1884
|
+
"support",
|
|
1885
|
+
"challenge",
|
|
1886
|
+
"dating",
|
|
1887
|
+
"partner",
|
|
1888
|
+
)
|
|
1889
|
+
)
|
|
1890
|
+
if {"charity", "race", "raise"}.issubset(relation_term_set):
|
|
1891
|
+
priority_variant_order.extend(("raising", "raised", "awareness", "fundraiser"))
|
|
1892
|
+
priority_surface_terms.update(("raising", "raised"))
|
|
1893
|
+
if {"run", "charity", "race"}.issubset(relation_term_set):
|
|
1894
|
+
priority_variant_order.extend(("last", "ran", "fundraiser", "awareness"))
|
|
1895
|
+
priority_surface_terms.add("last")
|
|
1896
|
+
if "research" in relation_term_set:
|
|
1897
|
+
priority_variant_order.extend(("researching",))
|
|
1898
|
+
priority_surface_terms.add("researching")
|
|
1899
|
+
if {
|
|
1900
|
+
"advise",
|
|
1901
|
+
"ask",
|
|
1902
|
+
"call",
|
|
1903
|
+
"chat",
|
|
1904
|
+
"discus",
|
|
1905
|
+
"discuss",
|
|
1906
|
+
"message",
|
|
1907
|
+
"messag",
|
|
1908
|
+
"mention",
|
|
1909
|
+
"recommend",
|
|
1910
|
+
"request",
|
|
1911
|
+
"say",
|
|
1912
|
+
"said",
|
|
1913
|
+
"send",
|
|
1914
|
+
"sent",
|
|
1915
|
+
"suggest",
|
|
1916
|
+
"talk",
|
|
1917
|
+
"tell",
|
|
1918
|
+
"text",
|
|
1919
|
+
"told",
|
|
1920
|
+
"invit",
|
|
1921
|
+
"invitation",
|
|
1922
|
+
"invite",
|
|
1923
|
+
"remind",
|
|
1924
|
+
"reminded",
|
|
1925
|
+
"warn",
|
|
1926
|
+
"warned",
|
|
1927
|
+
} & relation_term_set:
|
|
1928
|
+
if relation_term_set & {"call", "message", "messag", "send", "sent", "text"}:
|
|
1929
|
+
priority_variant_order.extend(
|
|
1930
|
+
("message", "sent", "messaged", "texted", "called")
|
|
1931
|
+
)
|
|
1932
|
+
if relation_term_set & {"chat", "discus", "discuss", "talk"}:
|
|
1933
|
+
priority_variant_order.extend(
|
|
1934
|
+
("discussed", "talked", "conversation", "chat")
|
|
1935
|
+
)
|
|
1936
|
+
if relation_term_set & {"mention", "say", "said", "tell", "told"}:
|
|
1937
|
+
priority_variant_order.extend(("told", "said", "mentioned"))
|
|
1938
|
+
if relation_term_set & {"ask", "request"}:
|
|
1939
|
+
priority_variant_order.extend(("asked", "request"))
|
|
1940
|
+
priority_surface_terms.add("asked")
|
|
1941
|
+
if relation_term_set & {"invit", "invitation", "invite"}:
|
|
1942
|
+
priority_variant_order.extend(("invited", "invitation", "invite", "asked"))
|
|
1943
|
+
priority_surface_terms.update(("invited", "invitation", "invite"))
|
|
1944
|
+
if relation_term_set & {"remind", "reminded"}:
|
|
1945
|
+
priority_variant_order.extend(("reminded", "reminder", "told"))
|
|
1946
|
+
priority_surface_terms.update(("reminded", "reminder"))
|
|
1947
|
+
if relation_term_set & {"warn", "warned"}:
|
|
1948
|
+
priority_variant_order.extend(("warned", "told"))
|
|
1949
|
+
priority_surface_terms.add("warned")
|
|
1950
|
+
if relation_term_set & {"advise", "recommend", "suggest"}:
|
|
1951
|
+
priority_variant_order.extend(
|
|
1952
|
+
("advised", "recommended", "suggested", "told")
|
|
1953
|
+
)
|
|
1954
|
+
priority_surface_terms.update(("advised", "recommended", "suggested"))
|
|
1955
|
+
if "visit" in relation_term_set:
|
|
1956
|
+
priority_variant_order.extend(("visited", "studio", "place", "trip", "event"))
|
|
1957
|
+
priority_surface_terms.add("visited")
|
|
1958
|
+
if "attend" in relation_term_set:
|
|
1959
|
+
priority_variant_order.extend(
|
|
1960
|
+
("attended", "event", "meeting", "conference", "class", "workshop")
|
|
1961
|
+
)
|
|
1962
|
+
priority_surface_terms.add("attended")
|
|
1963
|
+
if "join" in relation_term_set:
|
|
1964
|
+
priority_variant_order.extend(
|
|
1965
|
+
("joined", "group", "community", "club", "class", "event")
|
|
1966
|
+
)
|
|
1967
|
+
priority_surface_terms.add("joined")
|
|
1968
|
+
if "participate" in relation_term_set:
|
|
1969
|
+
priority_variant_order.extend(
|
|
1970
|
+
("participated", "event", "group", "class", "workshop", "activity")
|
|
1971
|
+
)
|
|
1972
|
+
priority_surface_terms.add("participated")
|
|
1973
|
+
if "move" in relation_term_set:
|
|
1974
|
+
priority_variant_order.extend(("moved", "home", "country", "relocated"))
|
|
1975
|
+
if "sign" in relation_term_set:
|
|
1976
|
+
priority_variant_order.extend(("signed", "signup", "class", "registered"))
|
|
1977
|
+
priority_surface_terms.add("signed")
|
|
1978
|
+
if {"enroll", "register"} & relation_term_set:
|
|
1979
|
+
priority_variant_order.extend(
|
|
1980
|
+
(
|
|
1981
|
+
"signed",
|
|
1982
|
+
"signup",
|
|
1983
|
+
"class",
|
|
1984
|
+
"registered",
|
|
1985
|
+
"registration",
|
|
1986
|
+
"enrolled",
|
|
1987
|
+
"course",
|
|
1988
|
+
"lesson",
|
|
1989
|
+
)
|
|
1990
|
+
)
|
|
1991
|
+
priority_surface_terms.update(("signed", "registered", "enrolled"))
|
|
1992
|
+
if "conference" in relation_term_set:
|
|
1993
|
+
priority_variant_order.extend(("going", "month", "event", "attend"))
|
|
1994
|
+
priority_surface_terms.add("month")
|
|
1995
|
+
if "roadtrip" in relation_term_set:
|
|
1996
|
+
priority_variant_order.extend(
|
|
1997
|
+
(
|
|
1998
|
+
"trip",
|
|
1999
|
+
"road",
|
|
2000
|
+
"weekend",
|
|
2001
|
+
"past",
|
|
2002
|
+
"soon",
|
|
2003
|
+
"another",
|
|
2004
|
+
)
|
|
2005
|
+
)
|
|
2006
|
+
priority_surface_terms.update(("weekend", "past"))
|
|
2007
|
+
if {"individual", "adoption", "support"}.issubset(relation_term_set):
|
|
2008
|
+
priority_variant_order.extend(
|
|
2009
|
+
("help", "lgbtq", "folks", "inclusivity", "inclusive")
|
|
2010
|
+
)
|
|
2011
|
+
priority_surface_terms.add("folks")
|
|
2012
|
+
if {"choose", "adoption", "agency"}.issubset(relation_term_set):
|
|
2013
|
+
priority_variant_order.extend(
|
|
2014
|
+
("chose", "reason", "cause", "fit", "value", "spoke", "decision")
|
|
2015
|
+
)
|
|
2016
|
+
if {"plan", "summer"}.issubset(relation_term_set):
|
|
2017
|
+
priority_variant_order.extend(
|
|
2018
|
+
(
|
|
2019
|
+
"dream",
|
|
2020
|
+
"family",
|
|
2021
|
+
"lov",
|
|
2022
|
+
"home",
|
|
2023
|
+
"kid",
|
|
2024
|
+
"future",
|
|
2025
|
+
"upcoming",
|
|
2026
|
+
"season",
|
|
2027
|
+
"goal",
|
|
2028
|
+
"want",
|
|
2029
|
+
"going",
|
|
2030
|
+
)
|
|
2031
|
+
)
|
|
2032
|
+
priority_surface_terms.update(("upcoming", "going"))
|
|
2033
|
+
if "marry" in relation_term_set:
|
|
2034
|
+
priority_variant_order.extend(
|
|
2035
|
+
("wed", "year", "already", "bride", "dres", "wedding", "married")
|
|
2036
|
+
)
|
|
2037
|
+
priority_surface_terms.add("already")
|
|
2038
|
+
if {"give", "speech", "school"}.issubset(relation_term_set):
|
|
2039
|
+
priority_variant_order.extend(("event", "talk", "student"))
|
|
2040
|
+
priority_variants = tuple(
|
|
2041
|
+
term
|
|
2042
|
+
for term in priority_variant_order
|
|
2043
|
+
if term in relation_variant_terms or term in priority_surface_terms
|
|
2044
|
+
)
|
|
2045
|
+
return tuple(
|
|
2046
|
+
dict.fromkeys(
|
|
2047
|
+
(
|
|
2048
|
+
*base_terms,
|
|
2049
|
+
*priority_variants,
|
|
2050
|
+
*delayed_base_terms,
|
|
2051
|
+
*high_signal_variants,
|
|
2052
|
+
*relation_variant_terms,
|
|
2053
|
+
)
|
|
2054
|
+
)
|
|
2055
|
+
)
|