Below is a model card from huggingface. Can this model be used to separate content words…
- User
Below is a model card from huggingface. Can this model be used to separate content words and function words?
""" from transformers import AutoModel, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('dicta-il/dictabert-morph') model = AutoModel.from_pretrained('dicta-il/dictabert-morph', trust_remote_code=True)
model.eval()
sentence = 'בשנת 1948 השלים אפרים קישון את לימודיו בפיסול מתכת ובתולדות האמנות והחל לפרסם מאמרים הומוריסטיים' print(model.predict([sentence], tokenizer))
Output:
[{ "text": "בשנת 1948 השלים אפרים קישון את לימודיו בפיסול מתכת ובתולדות האמנות והחל לפרסם מאמרים הומוריסטיים", "tokens": [{ "token": "בשנת", "pos": "NOUN", "feats": { "Gender": "Fem", "Number": "Sing" }, "prefixes": ["ADP"], "suffix": false }, { "token": "1948", "pos": "NUM", "feats": {}, "prefixes": [], "suffix": false }, { "token": "השלים", "pos": "VERB", "feats": { "Gender": "Masc", "Number": "Sing", "Person": "3", "Tense": "Past" }, "prefixes": [], "suffix": false }, { "token": "אפרים", "pos": "PROPN", "feats": {}, "prefixes": [], "suffix": false }, { "token": "קישון", "pos": "PROPN", "feats": {}, "prefixes": [], "suffix": false }, { "token": "את", "pos": "ADP", "feats": {}, "prefixes": [], "suffix": false }, { "token": "לימודיו", "pos": "NOUN", "feats": { "Gender": "Masc", "Number": "Plur" }, "prefixes": [], "suffix": "PRON", "suffix_feats": { "Gender": "Masc", "Number": "Sing", "Person": "3" } }, { "token": "בפיסול", "pos": "NOUN", "feats": { "Gender": "Masc", "Number": "Sing" }, "prefixes": ["ADP"], "suffix": false }, { "token": "מתכת", "pos": "NOUN", "feats": { "Gender": "Fem", "Number": "Sing" }, "prefixes": [], "suffix": false }, { "token": "ובתולדות", "pos": "NOUN", "feats": { "Gender": "Fem", "Number": "Plur" }, "prefixes": ["CCONJ", "ADP"], "suffix": false }, { "token": "האמנות", "pos": "NOUN", "feats": { "Gender": "Fem", "Number": "Sing" }, "prefixes": ["DET"], "suffix": false }, { "token": "והחל", "pos": "VERB", "feats": { "Gender": "Masc", "Number": "Sing", "Person": "3", "Tense": "Past" }, "prefixes": ["CCONJ"], "suffix": false }, { "token": "לפרסם", "pos": "VERB", "feats": {}, "prefixes": [], "suffix": false }, { "token": "מאמרים", "pos": "NOUN", "feats": { "Gender": "Masc", "Number": "Plur" }, "prefixes": [], "suffix": false }, { "token": "הומוריסטיים", "pos": "ADJ", "feats": { "Gender": "Masc", "Number": "Plur" }, "prefixes": [], "suffix": false }] }] """
- Assistant
Yes — you can use dicta-il/dictabert-morph to separate content words from function words, but the model doesn’t directly give you that label. What it does give you is:
POS tag (pos)
morphological features (feats)
prefix/suffix segmentation, including clitics (like prepositions, conjunctions, determiners, pronoun suffixes)
With this, you can map POS tags into your two classes: Typical mapping
Content words → NOUN, VERB, ADJ, ADV, PROPN, sometimes NUM
Function words → ADP (prepositions), CCONJ/SCONJ (conjunctions), DET (articles), PRON (independent pronouns), particles, auxiliaries, etc.
Prefixes like ADP, CCONJ, DET attached to words are also function words.
Suffix pronouns (suffix: "PRON") are function-like as well.
Example from your output
"בשנת" → token NOUN with prefix ADP.
Content = "שנת" (year), Function = "ב" (in).
"את" → ADP → function word.
"השלים" → VERB → content word.
"והחל" → VERB with prefix CCONJ.
Content = "החל" (began), Function = "ו" (and).
- User
Yes. The function should return two lists of tuples, the first entry is each tuple is the word, and the second is its POS
- Assistant
Perfect 👍 Here’s a Python function that takes the model’s predict output and separates content words vs. function words, returning them as two lists of (word, pos) tuples. pythonCopy codedef separate_content_function_words(model_output): # Define mapping of POS to content/function categories content_pos = {"NOUN", "VERB", "ADJ", "ADV", "PROPN", "NUM"} function_pos = {"ADP", "CCONJ", "SCONJ", "DET", "PRON", "PART", "AUX"}
- User
Ignore prefixes
- Assistant
Got it 👍 If we ignore prefixes and only classify based on the token’s main POS (plus suffix pronouns), here’s a cleaner version: pythonCopy codedef separate_content_function_words(model_output): # Define mapping of POS to content/function categories content_pos = {"NOUN", "VERB", "ADJ", "ADV", "PROPN", "NUM"} function_pos = {"ADP", "CCONJ", "SCONJ", "DET", "PRON", "PART", "AUX"}
content_words = [] function_words = [] for sentence in model_output: for token in sentence["tokens"]: tok = token["token"] pos = token["pos"] # Handle suffix pronouns (function morphemes) if token.get("suffix") == "PRON": function_words.append((tok, "PRON")) # Classify by POS if pos in content_pos: content_words.append((tok, pos)) elif pos in function_pos: function_words.append((tok, pos)) else: # fallback: treat as content content_words.append((tok, pos)) return content_words, function_wordsThis way:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.